How do you images that are in a zip file for an image classifier. I am trying to practice after watching the first few lessons. I am working on a Kaggle image recognition competition where the training images are in a zip file (and a csv file has the filenames and a label for each). How do I use the images in a zip file ?
Do I need to unzip them first and put them in a single folder ?
1 Like
Yes, as per my understanding fastai has no functions implemented for unzipping data (although they have untar_data
. So, you can unzip it manually and provide the path to the unzipped folder.
1 Like
from zipfile import ZipFile
with ZipFile(‘pathtothezipfile.zip’, ‘r’) as archive:
archive.extractall(‘whereyouwant/’)
5 Likes
Thank you. I just went through the first fast.ai lesson and am glad I found this solution.
After realizing the untar_data
function would not work for .zip files, I struggled to find a good solution until searching this forum. You just saved me a lot of headache.