11
22# Standard library imports
3+ import os
34import sys
45from shutil import rmtree as remove_directory
56from timeit import default_timer as timer
134135githubme = "https://github.com/Djdefrag/ReSRScaler"
135136telegramme = "https://linktr.ee/j3ngystudio"
136137
138+ # Remote URL where the AI *.pth assets can be downloaded from.
139+ REMOTE_AI_URL = "https://zackees.github.io/ai-image-video-models"
137140
138141# SRVGGNetCompact
139142SRVGGNetCompact_vram_multiplier = 1.7
190193]
191194
192195
196+ def ensure_downloaded (modelfile : str , outpath : str ) -> None :
197+ """Download a model file if it doesn't exist."""
198+ if os .path .exists (outpath ):
199+ return # Already downloaded
200+ asset_url = f"{ REMOTE_AI_URL } /{ modelfile } "
201+ from download import download # Lazy import
202+ download (asset_url , outpath )
203+
193204
194205# AI models -------------------
195206
@@ -202,7 +213,9 @@ def load_AI_model(
202213 ) -> any :
203214
204215 write_process_status (processing_queue , f"Loading AI model" )
205- model_path = find_by_relative_path (f"AI{ os_separator } { selected_AI_model } .pth" )
216+ model_file = f"{ selected_AI_model } .pth"
217+ model_path = find_by_relative_path (f"AI{ os_separator } { model_file } " )
218+ ensure_downloaded (model_file , model_path )
206219
207220 if selected_AI_model == 'RealESRGANx4' :
208221 model = RealESRGAN_Net ()
0 commit comments