0

excuse me, anyone understand what I should do to the code? The code is error : BadZipFile: File is not a zip file. But the file in the link i use is already in a zip file.

**The code is : **

import tensorflow as tf
!wget --no-check-certificate \
  https://drive.google.com/file/d/1zBasc3iGhJwCoCvZngcySO-Zxv1Mle59/view?usp=sharing \
  -O /tmp/rockpaperscissors.zip
import zipfile,os
local_zip = '/tmp/rockpaperscissors.zip'
zip_ref = zipfile.ZipFile(local_zip, 'r')
zip_ref.extractall('/tmp')
zip_ref.close()

base_dir = '/tmp/image'
train_dir = os.path.join(base_dir, 'train')
validation_dir = os.path.join(base_dir, 'val')

**The error is : **

BadZipFile                                Traceback (most recent call last)
<ipython-input-7-155df6c2cd43> in <module>
      2 import zipfile,os
      3 local_zip = '/tmp/rockpaperscissors.zip'
----> 4 zip_ref = zipfile.ZipFile(local_zip, 'r')
      5 zip_ref.extractall('/tmp')
      6 zip_ref.close()

1 frames
/usr/lib/python3.7/zipfile.py in _RealGetContents(self)
   1323             raise BadZipFile("File is not a zip file")
   1324         if not endrec:
-> 1325             raise BadZipFile("File is not a zip file")
   1326         if self.debug > 1:
   1327             print(endrec)

BadZipFile: File is not a zip file

And the proof that my file is already in a zip file is : (look at the picture that i inserted

excuse me, anyone understand what I should do to the code? The code is error : BadZipFile: File is not a zip file. But the file in the link i use is already in a zip file. I'm trying to create an Artificial Neural Network for image detection by inserting a folder containing pictures of rock, scissors, and paper hand poses. Thank you very much

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Aya
  • 11
  • You should inspect your downloaded file, it's not actually a zip file, it's an HTML document. At least, it's an HTML document at my end when I try to download it, giving me a Google Drive page where you can download the zip file, but not the zip file itself. – joanis Oct 29 '22 at 14:15
  • Programmatically downloading a document from Google Drive is not trivial, but see here for a simple solution: https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive – joanis Oct 29 '22 at 14:23

0 Answers0