Sanket17 commited on
Commit
6022d56
·
verified ·
1 Parent(s): 1edd912

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -4
main.py CHANGED
@@ -1,13 +1,14 @@
1
  import os
2
  import gdown
3
- from pathlib import Path
4
  from fastapi import FastAPI
5
 
6
  app = FastAPI()
7
 
8
  def download_weights():
9
- # Create directories if they don't exist
10
  os.makedirs("/tmp/.cache/gdown", exist_ok=True)
 
 
11
 
12
  # Set gdown's cache directory to a writable location
13
  os.environ["GDOWN_CACHE"] = "/tmp/.cache/gdown"
@@ -22,8 +23,11 @@ def download_weights():
22
  if not os.path.exists(output_path):
23
  print(f"Downloading {output_path}...")
24
  url = f"https://drive.google.com/uc?id={file_id}"
25
- gdown.download(url, output_path, quiet=False)
26
- print(f"Downloaded {output_path}")
 
 
 
27
  else:
28
  print(f"File {output_path} already exists, skipping download")
29
 
 
1
  import os
2
  import gdown
 
3
  from fastapi import FastAPI
4
 
5
  app = FastAPI()
6
 
7
  def download_weights():
8
+ # Create necessary directories if they don't exist
9
  os.makedirs("/tmp/.cache/gdown", exist_ok=True)
10
+ os.makedirs("/tmp/weights/icon_caption_florence", exist_ok=True)
11
+ os.makedirs("/tmp/weights/icon_detect", exist_ok=True)
12
 
13
  # Set gdown's cache directory to a writable location
14
  os.environ["GDOWN_CACHE"] = "/tmp/.cache/gdown"
 
23
  if not os.path.exists(output_path):
24
  print(f"Downloading {output_path}...")
25
  url = f"https://drive.google.com/uc?id={file_id}"
26
+ try:
27
+ gdown.download(url, output_path, quiet=False)
28
+ print(f"Downloaded {output_path}")
29
+ except Exception as e:
30
+ print(f"Failed to download {output_path}: {e}")
31
  else:
32
  print(f"File {output_path} already exists, skipping download")
33