I'm resizing my image for my thesis on Google colab. But there's a huge time difference when I'm using tqdm and when I'm not using it.
Here's the code when I'm using tqdm:
import glob
import os
from tqdm import tqdm
import math
from PIL import Image
new_width = 224
file = r'path\\*.jpeg'
images = glob.glob(file)
for i in tqdm(range(len(images))):
for image in images:
img = Image.open(image)
width,height = img.size
if width >= new_width:
new = img.resize((224,224))
else:
new = img
new.save('path'+os.path.basename(image))
And here's when I'm not using tqdm:
import glob
import os
import math
from PIL import Image
new_width = 224
file = r'path\\*.jpeg'
images = glob.glob(file)
for image in images:
img = Image.open(image)
width,height = img.size
if width >= new_width:
new = img.resize((224,224))
else:
new = img
new.save('path\\'+os.path.basename(image))
The result with tqdm takes more than 1 hour but when I'm not using it it only take like 10 seconds. What is wrong with my code?