Om Prakash Singh
commited on
Commit
•
9ca7827
1
Parent(s):
92ce6de
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,10 @@ import subprocess
|
|
2 |
import importlib
|
3 |
|
4 |
# List of required packages
|
5 |
-
packages = ['cv2', 'numpy', 'tensorflow', '
|
|
|
|
|
|
|
6 |
|
7 |
# Check and install packages if needed
|
8 |
for package in packages:
|
@@ -10,12 +13,11 @@ for package in packages:
|
|
10 |
importlib.import_module(package)
|
11 |
except ImportError:
|
12 |
print(f"{package} not found. Installing...")
|
13 |
-
install_command = ['pip', 'install', package]
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
subprocess.run(install_command, check=True)
|
20 |
|
21 |
# Now that all packages are installed, import them
|
@@ -27,6 +29,9 @@ import gradio as gr
|
|
27 |
# Your code using these packages can follow here
|
28 |
|
29 |
|
|
|
|
|
|
|
30 |
def remove_background_deeplab(image_path):
|
31 |
# Load the TensorFlow Lite model
|
32 |
interpreter = tf.lite.Interpreter(model_path="2.tflite")
|
|
|
2 |
import importlib
|
3 |
|
4 |
# List of required packages
|
5 |
+
packages = ['cv2', 'numpy', 'tensorflow', 'gr']
|
6 |
+
|
7 |
+
# Mapping of package names to their PyPI names
|
8 |
+
package_mapping = {'cv2': 'opencv-python-headless'}
|
9 |
|
10 |
# Check and install packages if needed
|
11 |
for package in packages:
|
|
|
13 |
importlib.import_module(package)
|
14 |
except ImportError:
|
15 |
print(f"{package} not found. Installing...")
|
|
|
16 |
|
17 |
+
# Get the correct package name from the mapping
|
18 |
+
install_package = package_mapping.get(package, package)
|
19 |
+
|
20 |
+
install_command = ['pip', 'install', install_package]
|
21 |
subprocess.run(install_command, check=True)
|
22 |
|
23 |
# Now that all packages are installed, import them
|
|
|
29 |
# Your code using these packages can follow here
|
30 |
|
31 |
|
32 |
+
# Your code using these packages can follow here
|
33 |
+
|
34 |
+
|
35 |
def remove_background_deeplab(image_path):
|
36 |
# Load the TensorFlow Lite model
|
37 |
interpreter = tf.lite.Interpreter(model_path="2.tflite")
|