fffiloni commited on
Commit
3c57e49
1 Parent(s): 1adeed6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -4,10 +4,22 @@ import tempfile
4
  import gradio as gr
5
  from PIL import Image
6
  from rembg import remove
 
7
  import subprocess
8
  from glob import glob
9
  import requests
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  def remove_background(input_url):
12
  # Create a temporary folder for downloaded and processed images
13
  temp_dir = tempfile.mkdtemp()
 
4
  import gradio as gr
5
  from PIL import Image
6
  from rembg import remove
7
+ import sys
8
  import subprocess
9
  from glob import glob
10
  import requests
11
 
12
+ # Ensure the required package is installed
13
+ def install_dependencies():
14
+ try:
15
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/facebookresearch/pytorch3d.git@75ebeeaea0908c5527e7b1e305fbc7681382db47"])
16
+ except subprocess.CalledProcessError as e:
17
+ print(f"Error installing dependencies: {e}")
18
+ sys.exit(1) # Exit the script if installation fails
19
+
20
+ # Install dependencies at the start
21
+ install_dependencies()
22
+
23
  def remove_background(input_url):
24
  # Create a temporary folder for downloaded and processed images
25
  temp_dir = tempfile.mkdtemp()