fix broken url fetch in preload_models.py

This commit is contained in:
Lincoln Stein 2022-10-30 17:43:48 -04:00
parent 23d54ee69e
commit 303a2495c7

View File

@ -434,7 +434,7 @@ def download_gfpgan():
if not os.path.exists(model_dest): if not os.path.exists(model_dest):
print(f'Downloading gfpgan model file {model_url}...',end='') print(f'Downloading gfpgan model file {model_url}...',end='')
os.makedirs(os.path.dirname(model_dest), exist_ok=True) os.makedirs(os.path.dirname(model_dest), exist_ok=True)
urllib.request.urlretrieve(model_url,model_dest) request.urlretrieve(model_url,model_dest)
print('...success') print('...success')
except Exception: except Exception:
print('Error loading GFPGAN:') print('Error loading GFPGAN:')
@ -449,7 +449,7 @@ def download_codeformer():
if not os.path.exists(model_dest): if not os.path.exists(model_dest):
print('Downloading codeformer model file...') print('Downloading codeformer model file...')
os.makedirs(os.path.dirname(model_dest), exist_ok=True) os.makedirs(os.path.dirname(model_dest), exist_ok=True)
urllib.request.urlretrieve(model_url,model_dest) request.urlretrieve(model_url,model_dest)
except Exception: except Exception:
print('Error loading CodeFormer:') print('Error loading CodeFormer:')
print(traceback.format_exc()) print(traceback.format_exc())
@ -464,7 +464,7 @@ def download_clipseg():
weights_dir = 'src/clipseg/weights' weights_dir = 'src/clipseg/weights'
if not os.path.exists(weights_dir): if not os.path.exists(weights_dir):
os.makedirs(os.path.dirname(model_dest), exist_ok=True) os.makedirs(os.path.dirname(model_dest), exist_ok=True)
urllib.request.urlretrieve(model_url,model_dest) request.urlretrieve(model_url,model_dest)
with zipfile.ZipFile(model_dest,'r') as zip: with zipfile.ZipFile(model_dest,'r') as zip:
zip.extractall('src/clipseg') zip.extractall('src/clipseg')
os.rename('src/clipseg/clipseg_weights','src/clipseg/weights') os.rename('src/clipseg/clipseg_weights','src/clipseg/weights')
@ -523,7 +523,6 @@ if __name__ == '__main__':
print('\n** DOWNLOADING WEIGHTS **') print('\n** DOWNLOADING WEIGHTS **')
successfully_downloaded = download_weight_datasets(models, access_token) successfully_downloaded = download_weight_datasets(models, access_token)
update_config_file(successfully_downloaded) update_config_file(successfully_downloaded)
else:
print('\n** DOWNLOADING SUPPORT MODELS **') print('\n** DOWNLOADING SUPPORT MODELS **')
download_bert() download_bert()
download_kornia() download_kornia()