Ali Mohsin commited on
Commit
19f603d
·
1 Parent(s): 18b2585

refactor: Delegate Python package installation to `requirements.txt` and streamline checkpoint download.

Browse files
Files changed (2) hide show
  1. app.py +10 -20
  2. requirements.txt +3 -1
app.py CHANGED
@@ -12,28 +12,18 @@ import threading
12
  from glob import glob
13
 
14
  # --- Installation Helper ---
15
- def install_dependencies():
16
- print("Checking and installing dependencies...")
17
- try:
18
- # Upgrade build tools first
19
- subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip", "wheel", "setuptools", "ninja"])
20
-
21
- # Install Detectron2
22
- subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-build-isolation", "detectron2@git+https://github.com/facebookresearch/detectron2.git"])
23
- # Install ROMP
24
- subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-build-isolation", "git+https://github.com/ZaiqiangWu/ROMP.git#subdirectory=simple_romp"])
25
-
26
- # Download Checkpoints if not present
27
- if not os.path.exists("./rtv_ckpts"):
28
- print("Downloading checkpoints...")
29
  subprocess.check_call(["git", "clone", "https://huggingface.co/wuzaiqiang/rtv_ckpts"])
30
-
31
- print("Dependencies installed and checkpoints ready.")
32
- except Exception as e:
33
- print(f"Error installing dependencies: {e}")
34
 
35
- # Run installation on startup
36
- install_dependencies()
37
 
38
  # --- App Logic ---
39
 
 
12
  from glob import glob
13
 
14
  # --- Installation Helper ---
15
+ # Dependencies are handled by requirements.txt on Spaces
16
+
17
+ def check_chkpts():
18
+ if not os.path.exists("./rtv_ckpts"):
19
+ print("Downloading checkpoints...")
20
+ try:
 
 
 
 
 
 
 
 
21
  subprocess.check_call(["git", "clone", "https://huggingface.co/wuzaiqiang/rtv_ckpts"])
22
+ print("Checkpoints downloaded.")
23
+ except Exception as e:
24
+ print(f"Error downloading checkpoints: {e}")
 
25
 
26
+ check_chkpts()
 
27
 
28
  # --- App Logic ---
29
 
requirements.txt CHANGED
@@ -3,9 +3,11 @@ opencv-python-headless
3
  onnxruntime
4
  wheel
5
  ninja
6
- setuptools
7
  torch==2.4.0
8
  torchvision==0.19.0
 
 
9
  rembg
10
  openmim
11
  numpy~=1.24.2
 
3
  onnxruntime
4
  wheel
5
  ninja
6
+ setuptools<70
7
  torch==2.4.0
8
  torchvision==0.19.0
9
+ git+https://github.com/facebookresearch/detectron2.git
10
+ git+https://github.com/ZaiqiangWu/ROMP.git#subdirectory=simple_romp
11
  rembg
12
  openmim
13
  numpy~=1.24.2