Получение `EOFError: сжатый файл завершился до того, как был достигнут маркер конца потока` - PullRequest
0 голосов
/ 01 марта 2019

Я написал скрипт на python для загрузки файла, его распаковки и обучения AI.Код приведен ниже:

def maybe_download_and_extract(data_url):
  dest_directory = FLAGS.model_dir
if not os.path.exists(dest_directory):
  os.makedirs(dest_directory)
filename = data_url.split('/')[-1]
filepath = os.path.join(dest_directory, filename)
if not os.path.exists(filepath):
  def _progress(count, block_size, total_size):
  sys.stdout.write('\r>> Downloading %s %.1f%%' %
    (filename, float(count * block_size) / float(total_size) * 100.0))
sys.stdout.flush()

filepath, _ = urllib.request.urlretrieve(data_url, filepath, _progress)
print()
statinfo = os.stat(filepath)
tf.logging.info('Successfully downloaded', filename, statinfo.st_size, 'bytes.')
tarfile.open(filepath, 'r:gz').extractall(dest_directory)

Когда я запускаю его, я получаю эту ошибку:

Traceback (most recent call last):
  File "scripts/retrain.py", line 1326, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File "scripts/retrain.py", line 982, in main
    maybe_download_and_extract(model_info['data_url'])
  File "scripts/retrain.py", line 340, in maybe_download_and_extract
    tarfile.open(filepath, 'r:gz').extractall(dest_directory)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\tarfile.py", line 2010, in extractall
    numeric_owner=numeric_owner)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\tarfile.py", line 2052, in extract
    numeric_owner=numeric_owner)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\tarfile.py", line 2122, in _extract_member
    self.makefile(tarinfo, targetpath)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\tarfile.py", line 2171, in makefile
    copyfileobj(source, target, tarinfo.size, ReadError, bufsize)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\tarfile.py", line 249, in copyfileobj
    buf = src.read(bufsize)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\gzip.py", line 276, in read
    return self._buffer.read(size)
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\_compression.py", line 68, in readinto
    data = self.read(len(byte_view))
  File "C:\Users\kulkaa\AppData\Local\conda\conda\envs\mlcc\lib\gzip.py", line 482, in read
    raise EOFError("Compressed file ended before the "
EOFError: Compressed file ended before the end-of-stream marker was reached  

Кажется, что файл был частично загружен.Где этот файл?Я удалил содержимое папки tmp и снова запустил эту программу, но получил ту же ошибку.

...