Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
#
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
|
32 |
# import streamlit as st
|
|
|
1 |
|
2 |
+
import streamlit as st
|
3 |
+
import numpy as np
|
4 |
+
import cv2
|
5 |
+
import warnings
|
6 |
+
import os
|
7 |
|
8 |
+
# Suppress warnings
|
9 |
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
10 |
+
warnings.filterwarnings("ignore", category=UserWarning)
|
11 |
+
|
12 |
+
# Try importing TensorFlow
|
13 |
+
try:
|
14 |
+
from tensorflow.keras.models import load_model
|
15 |
+
from tensorflow.keras.preprocessing import image
|
16 |
+
except ImportError:
|
17 |
+
st.error("Failed to import TensorFlow. Please make sure it's installed correctly.")
|
18 |
+
|
19 |
+
# Try importing PyTorch and Detectron2
|
20 |
+
try:
|
21 |
+
import torch
|
22 |
+
import detectron2
|
23 |
+
except ImportError:
|
24 |
+
with st.spinner("Installing PyTorch and Detectron2..."):
|
25 |
+
os.system("pip install torch torchvision")
|
26 |
+
os.system("pip install 'git+https://github.com/facebookresearch/detectron2.git'")
|
27 |
+
|
28 |
+
import torch
|
29 |
+
import detectron2
|
30 |
|
31 |
|
32 |
# import streamlit as st
|