diff --git a/RealESRGAN/model.py b/RealESRGAN/model.py index 3a04daf..3bdc795 100644 --- a/RealESRGAN/model.py +++ b/RealESRGAN/model.py @@ -4,7 +4,7 @@ from PIL import Image import numpy as np import cv2 -from huggingface_hub import hf_hub_url, cached_download +from huggingface_hub import hf_hub_download from .rrdbnet_arch import RRDBNet from .utils import pad_reflect, split_image_into_overlapping_patches, stich_together, \ @@ -42,8 +42,16 @@ def load_weights(self, model_path, download=True): config = HF_MODELS[self.scale] cache_dir = os.path.dirname(model_path) local_filename = os.path.basename(model_path) - config_file_url = hf_hub_url(repo_id=config['repo_id'], filename=config['filename']) - cached_download(config_file_url, cache_dir=cache_dir, force_filename=local_filename) + downloaded_model_path = hf_hub_download( + repo_id=config['repo_id'], + filename=config['filename'], + cache_dir=cache_dir, + local_dir=cache_dir, + local_dir_use_symlinks=False + ) + os.rename(downloaded_model_path, model_path) + print('Weights downloaded to:', model_path) + print('Weights downloaded to:', os.path.join(cache_dir, local_filename)) loadnet = torch.load(model_path)