Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -341,39 +341,39 @@
|
|
341 |
# ///////////////////////////////////Working
|
342 |
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
# # Suppress warnings
|
351 |
-
# warnings.filterwarnings("ignore", category=FutureWarning)
|
352 |
-
# warnings.filterwarnings("ignore", category=UserWarning)
|
353 |
-
|
354 |
-
# # Try importing TensorFlow
|
355 |
-
# try:
|
356 |
-
# from tensorflow.keras.models import load_model
|
357 |
-
# from tensorflow.keras.preprocessing import image
|
358 |
-
# except ImportError:
|
359 |
-
# st.error("Failed to import TensorFlow. Please make sure it's installed correctly.")
|
360 |
-
|
361 |
-
# # Try importing PyTorch and Detectron2
|
362 |
-
# try:
|
363 |
-
# import torch
|
364 |
-
# import detectron2
|
365 |
-
# except ImportError:
|
366 |
-
# with st.spinner("Installing PyTorch and Detectron2..."):
|
367 |
-
# os.system("pip install torch torchvision")
|
368 |
-
# os.system("pip install 'git+https://github.com/facebookresearch/detectron2.git'")
|
369 |
|
370 |
-
#
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
|
378 |
# # Load the trained models
|
379 |
# @st.cache_resource
|
|
|
341 |
# ///////////////////////////////////Working
|
342 |
|
343 |
|
344 |
+
import streamlit as st
|
345 |
+
import numpy as np
|
346 |
+
import cv2
|
347 |
+
import warnings
|
348 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
+
# Suppress warnings
|
351 |
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
352 |
+
warnings.filterwarnings("ignore", category=UserWarning)
|
353 |
+
|
354 |
+
# Try importing TensorFlow
|
355 |
+
try:
|
356 |
+
from tensorflow.keras.models import load_model
|
357 |
+
from tensorflow.keras.preprocessing import image
|
358 |
+
except ImportError:
|
359 |
+
st.error("Failed to import TensorFlow. Please make sure it's installed correctly.")
|
360 |
+
|
361 |
+
# Try importing PyTorch and Detectron2
|
362 |
+
try:
|
363 |
+
import torch
|
364 |
+
import detectron2
|
365 |
+
except ImportError:
|
366 |
+
with st.spinner("Installing PyTorch and Detectron2..."):
|
367 |
+
os.system("pip install torch torchvision")
|
368 |
+
os.system("pip install 'git+https://github.com/facebookresearch/detectron2.git'")
|
369 |
+
|
370 |
+
import torch
|
371 |
+
import detectron2
|
372 |
|
373 |
+
from detectron2.engine import DefaultPredictor
|
374 |
+
from detectron2.config import get_cfg
|
375 |
+
from detectron2.utils.visualizer import Visualizer
|
376 |
+
from detectron2.data import MetadataCatalog
|
377 |
|
378 |
# # Load the trained models
|
379 |
# @st.cache_resource
|