valhalla commited on
Commit
bcfe90f
1 Parent(s): 93ae670

Update dalle/utils/utils.py

Browse files
Files changed (1) hide show
  1. dalle/utils/utils.py +10 -10
dalle/utils/utils.py CHANGED
@@ -55,16 +55,16 @@ def download(url: str, root: str) -> str:
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')
 
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')