Noursine commited on
Commit
e28c5d2
·
verified ·
1 Parent(s): b53cbe5

Update detectron_infer.py

Browse files
Files changed (1) hide show
  1. detectron_infer.py +15 -6
detectron_infer.py CHANGED
@@ -14,14 +14,23 @@ DRIVE_FILE_ID = "1TNECsdcZ82tLOFxWTQMdLPGlvM3c5JWp"
14
 
15
  def download_model():
16
  if not os.path.exists(MODEL_PATH):
17
- # Use a writable cache directory under /tmp instead of /
18
- gdown_cache = "/tmp/gdown"
19
- os.environ["GDOWN_CACHE_DIR"] = gdown_cache
20
- os.makedirs(gdown_cache, exist_ok=True)
21
-
22
  url = f"https://drive.google.com/uc?id={DRIVE_FILE_ID}"
 
 
 
 
 
 
 
 
23
  print("Downloading Detectron2 model...")
24
- gdown.download(url, MODEL_PATH, quiet=False)
 
 
 
 
 
 
25
  print("Download complete.")
26
 
27
  download_model()
 
14
 
15
  def download_model():
16
  if not os.path.exists(MODEL_PATH):
 
 
 
 
 
17
  url = f"https://drive.google.com/uc?id={DRIVE_FILE_ID}"
18
+
19
+ # Create a writable temporary directory for gdown
20
+ tmp_dir = "/tmp/gdown"
21
+ os.makedirs(tmp_dir, exist_ok=True)
22
+
23
+ # Set GDOWN cache path to a safe location
24
+ os.environ["GDOWN_CACHE_DIR"] = tmp_dir
25
+
26
  print("Downloading Detectron2 model...")
27
+ gdown.download(
28
+ url,
29
+ MODEL_PATH,
30
+ quiet=False,
31
+ fuzzy=True,
32
+ use_cookies=False # Important for Hugging Face
33
+ )
34
  print("Download complete.")
35
 
36
  download_model()