remove invalid downloaded files

This commit is contained in:
Vladimir Mandic
2023-08-12 08:07:13 +00:00
parent 83f38c6333
commit 5d5f22e6e1
2 changed files with 5 additions and 1 deletions
+3
View File
@@ -35,6 +35,9 @@ def download_civit_model(model_url: str, model_name: str, model_path: str, previ
written = written + len(data)
f.write(data)
progress.update(task, advance=block_size, description="Downloading")
if written < 1024 * 1024 * 1024: # min threshold
os.remove(model_file)
raise ValueError(f'removed invalid download: bytes={written}')
if preview is not None:
preview_file = os.path.splitext(model_file)[0] + '.jpg'
preview.save(preview_file)
+2 -1
View File
@@ -18,7 +18,8 @@ local_url = None
errors.log.debug('Loading Torch')
import torch # pylint: disable=C0411
try:
errors.log.debug(f'Torch init: {torch.sum(torch.randn(2, 2)).to(0) > 0}') # fix silly pytorch_lightning issue
rnd = torch.sum(torch.randn(2, 2)).to(0)
errors.log.debug(f'Torch init: {rnd / rnd == 1.0}') # fix silly pytorch_lightning issue
except Exception:
pass
try: