valhalla commited on
Commit
4752874
1 Parent(s): 6bfb424

Update dalle/utils/utils.py

Browse files
Files changed (1) hide show
  1. dalle/utils/utils.py +12 -12
dalle/utils/utils.py CHANGED
@@ -53,21 +53,21 @@ def download(url: str, root: str) -> str:
53
  result_path = os.path.join(root, pathname)
54
 
55
  #if os.path.isfile(download_target) and (os.path.exists(result_path) and not os.path.isfile(result_path)):
56
- # return result_path
57
 
58
- with urllib.request.urlopen(url) as source, open(download_target, 'wb') as output:
59
- with tqdm(total=int(source.info().get('Content-Length')), ncols=80, unit='iB', unit_scale=True,
60
- unit_divisor=1024) as loop:
61
- while True:
62
- buffer = source.read(8192)
63
- if not buffer:
64
- break
65
 
66
- output.write(buffer)
67
- loop.update(len(buffer))
68
 
69
- if hashlib.md5(open(download_target, 'rb').read()).hexdigest() != expected_md5:
70
- raise RuntimeError(f'Model has been downloaded but the md5 checksum does not not match')
71
 
72
  with tarfile.open(download_target, 'r:gz') as f:
73
  pbar = tqdm(f.getmembers(), total=len(f.getmembers()))
 
53
  result_path = os.path.join(root, pathname)
54
 
55
  #if os.path.isfile(download_target) and (os.path.exists(result_path) and not os.path.isfile(result_path)):
56
+ #return result_path
57
 
58
+ # with urllib.request.urlopen(url) as source, open(download_target, 'wb') as output:
59
+ # with tqdm(total=int(source.info().get('Content-Length')), ncols=80, unit='iB', unit_scale=True,
60
+ # unit_divisor=1024) as loop:
61
+ # while True:
62
+ # buffer = source.read(8192)
63
+ # if not buffer:
64
+ # break
65
 
66
+ # output.write(buffer)
67
+ # loop.update(len(buffer))
68
 
69
+ # if hashlib.md5(open(download_target, 'rb').read()).hexdigest() != expected_md5:
70
+ # raise RuntimeError(f'Model has been downloaded but the md5 checksum does not not match')
71
 
72
  with tarfile.open(download_target, 'r:gz') as f:
73
  pbar = tqdm(f.getmembers(), total=len(f.getmembers()))