File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/fast_langdetect/ft_detect Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -91,9 +91,18 @@ def load_large_model():
9191 return load_local_small_model ()
9292
9393 # Path for the large model
94- model_path = Path (CACHE_DIRECTORY ) / "lid.176.bin"
94+ large_model_name = "lid.176.bin"
95+ model_path = Path (CACHE_DIRECTORY ) / large_model_name
9596
97+ # If the large model is already present, load it
9698 if model_path .exists ():
99+ # Model cant be dir
100+ if model_path .is_dir ():
101+ try :
102+ model_path .rmdir ()
103+ except Exception as e :
104+ logger .error (f"Failed to remove the directory '{ model_path } ': { e } " )
105+ raise DetectError (f"Unexpected directory found in large model file path '{ model_path } ': { e } " )
97106 # Attempt to load large model
98107 loaded_model = load_large_model ()
99108 if loaded_model :
@@ -106,7 +115,7 @@ def load_large_model():
106115 download (
107116 url = model_url ,
108117 folder = CACHE_DIRECTORY ,
109- filename = "lid.176.bin" ,
118+ filename = large_model_name ,
110119 proxy = download_proxy ,
111120 retry_max = 3 ,
112121 timeout = 20
You can’t perform that action at this time.
0 commit comments