Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,9 @@ import sys
|
|
7 |
# and install packages if needed
|
8 |
if not os.path.exists("/.dockerenv") and not os.path.exists("/kaggle"):
|
9 |
try:
|
|
|
|
|
|
|
10 |
# Try importing the required packages
|
11 |
import gradio
|
12 |
import cv2
|
@@ -16,31 +19,24 @@ if not os.path.exists("/.dockerenv") and not os.path.exists("/kaggle"):
|
|
16 |
|
17 |
# Special handling for TensorFlow and DeepFace dependencies
|
18 |
try:
|
|
|
|
|
19 |
import tensorflow as tf
|
20 |
-
tf_version = tf.__version__
|
21 |
-
print(f"TensorFlow version: {tf_version}")
|
22 |
|
23 |
-
# If TensorFlow version is >=2.16, we need to install tf-keras
|
24 |
-
if tf_version >= "2.16.0":
|
25 |
-
print("Installing tf-keras for compatibility with newer TensorFlow...")
|
26 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "tf-keras"])
|
27 |
-
|
28 |
# Now try to import deepface
|
|
|
29 |
import deepface
|
30 |
except ImportError as e:
|
31 |
print(f"Error importing dependencies: {str(e)}")
|
32 |
print("Installing deepface with specific dependencies...")
|
33 |
-
|
34 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "tensorflow<2.16.0"])
|
35 |
-
# Then install deepface
|
36 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "deepface"])
|
37 |
|
38 |
except ImportError:
|
39 |
print("Installing required packages...")
|
40 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install",
|
41 |
-
"gradio", "opencv-python-headless", "
|
42 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "tensorflow
|
43 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "deepface"])
|
44 |
|
45 |
# Now import the required modules
|
46 |
import gradio as gr
|
|
|
7 |
# and install packages if needed
|
8 |
if not os.path.exists("/.dockerenv") and not os.path.exists("/kaggle"):
|
9 |
try:
|
10 |
+
# First ensure numpy is correctly installed
|
11 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "numpy==1.23.5"])
|
12 |
+
|
13 |
# Try importing the required packages
|
14 |
import gradio
|
15 |
import cv2
|
|
|
19 |
|
20 |
# Special handling for TensorFlow and DeepFace dependencies
|
21 |
try:
|
22 |
+
# Install specific TensorFlow version
|
23 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "tensorflow==2.12.0"])
|
24 |
import tensorflow as tf
|
|
|
|
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
# Now try to import deepface
|
27 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "deepface"])
|
28 |
import deepface
|
29 |
except ImportError as e:
|
30 |
print(f"Error importing dependencies: {str(e)}")
|
31 |
print("Installing deepface with specific dependencies...")
|
32 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "deepface"])
|
|
|
|
|
|
|
33 |
|
34 |
except ImportError:
|
35 |
print("Installing required packages...")
|
36 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall",
|
37 |
+
"numpy==1.23.5", "gradio", "opencv-python-headless", "matplotlib", "pillow"])
|
38 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "tensorflow==2.12.0"])
|
39 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "deepface"])
|
40 |
|
41 |
# Now import the required modules
|
42 |
import gradio as gr
|