@@ -53,19 +53,24 @@ def load_file_from_url(
5353 :return:
5454 """
5555
56+ CCCV_REMOTE_MODEL_ZOO = os .environ .get (
57+ "CCCV_REMOTE_MODEL_ZOO" , "https://github.com/EutropicAI/cccv/releases/download/model_zoo/"
58+ )
59+ CCCV_CACHE_MODEL_DIR = os .environ .get ("CCCV_CACHE_MODEL_DIR" , str (CACHE_PATH ))
60+
5661 if model_dir is None :
57- model_dir = str (CACHE_PATH )
62+ model_dir = str (CCCV_CACHE_MODEL_DIR )
63+ print (
64+ f"[CCCV] Using default cache model path { model_dir } , override it by setting environment variable CCCV_CACHE_MODEL_DIR"
65+ )
5866
5967 cached_file_path = os .path .abspath (os .path .join (model_dir , config .name ))
6068
6169 if config .url is not None :
6270 _url : str = str (config .url )
6371 else :
64- CCCV_REMOTE_MODEL_ZOO = os .environ .get (
65- "CCCV_REMOTE_MODEL_ZOO" , "https://github.com/EutropicAI/cccv/releases/download/model_zoo/"
66- )
6772 print (
68- f"Fetch models from { CCCV_REMOTE_MODEL_ZOO } , override it by setting environment variable CCCV_REMOTE_MODEL_ZOO"
73+ f"[CCCV] Fetching models from { CCCV_REMOTE_MODEL_ZOO } , override it by setting environment variable CCCV_REMOTE_MODEL_ZOO"
6974 )
7075 if not CCCV_REMOTE_MODEL_ZOO .endswith ("/" ):
7176 CCCV_REMOTE_MODEL_ZOO += "/"
@@ -79,15 +84,15 @@ def load_file_from_url(
7984
8085 if not os .path .exists (cached_file_path ) or force_download :
8186 if _gh_proxy is not None :
82- print (f"Using github proxy: { _gh_proxy } " )
83- print (f"Downloading: { _url } to { cached_file_path } \n " )
87+ print (f"[CCCV] Using github proxy: { _gh_proxy } " )
88+ print (f"[CCCV] Downloading: { _url } to { cached_file_path } \n " )
8489
8590 @retry (wait = wait_random (min = 3 , max = 5 ), stop = stop_after_delay (10 ) | stop_after_attempt (30 ))
8691 def _download () -> None :
8792 try :
8893 download_url_to_file (url = _url , dst = cached_file_path , hash_prefix = None , progress = progress )
8994 except Exception as e :
90- print (f"Download failed: { e } , retrying..." )
95+ print (f"[CCCV] Download failed: { e } , retrying..." )
9196 raise e
9297
9398 _download ()
@@ -96,7 +101,7 @@ def _download() -> None:
96101 get_hash = get_file_sha256 (cached_file_path )
97102 if get_hash != config .hash :
98103 raise ValueError (
99- f"File { cached_file_path } hash mismatched with config hash { config .hash } , compare with { get_hash } "
104+ f"[CCCV] File { cached_file_path } hash mismatched with config hash { config .hash } , compare with { get_hash } "
100105 )
101106
102107 return cached_file_path
@@ -110,4 +115,4 @@ def _download() -> None:
110115 continue
111116 file_path = os .path .join (root , file )
112117 name = os .path .basename (file_path )
113- print (f"{ name } : { get_file_sha256 (file_path )} " )
118+ print (f"[CCCV] { name } : { get_file_sha256 (file_path )} " )
0 commit comments