fetch() 'ran out of input' fix
If requests.get fails during a download, the incomplete file is passed
without a size check. This causes errors during image/model loading.
Not sure if this is a problem on all systems.
MODIFY
tinygrad/utils.py
tinygrad/utils.py
import numpy as np
+import os
def mask_like(like, mask_inx, mask_value = 1.0):
mask = np.zeros_like(like).reshape(-1)
@@ -12,7 +13,7 @@ def layer_init_uniform(*x):
def fetch(url):
import requests, os, hashlib, tempfile
fp = os.path.join(tempfile.gettempdir(), hashlib.md5(url.encode('utf-8')).hexdigest())
- if os.path.isfile(fp):
+ if os.path.isfile(fp) and os.stat(fp).st_size > 0:
with open(fp, "rb") as f:
dat = f.read()
else:

fetch() 'ran out of input' fix (#65)

If requests.get fails during a download, the incomplete file is passed
without a size check. This causes errors during image/model loading.
Not sure if this is a problem on all systems.