Spaces:
Runtime error
Runtime error
Commit
·
04f2345
1
Parent(s):
17aa4c9
V1
Browse files- app.py +8 -4
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -22,6 +22,8 @@ import gradio as gr
|
|
| 22 |
from PIL import Image
|
| 23 |
from torchvision import transforms
|
| 24 |
import traceback
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Add current directory to path
|
| 27 |
if not os.getcwd() in sys.path:
|
|
@@ -40,8 +42,7 @@ except ImportError:
|
|
| 40 |
|
| 41 |
# Check for custom models
|
| 42 |
try:
|
| 43 |
-
|
| 44 |
-
from models import *
|
| 45 |
MODELS_IMPORTED = True
|
| 46 |
except ImportError:
|
| 47 |
print("Warning: Custom models couldn't be imported. Only damage detection will work.")
|
|
@@ -120,6 +121,9 @@ def setup_damage_detector(model_path, threshold=0.7):
|
|
| 120 |
return None, None
|
| 121 |
|
| 122 |
try:
|
|
|
|
|
|
|
|
|
|
| 123 |
if model_path is None or not os.path.exists(model_path):
|
| 124 |
print(f"Error: Damage model file not found at {model_path}")
|
| 125 |
return None, None
|
|
@@ -131,8 +135,8 @@ def setup_damage_detector(model_path, threshold=0.7):
|
|
| 131 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = threshold
|
| 132 |
|
| 133 |
# Use CPU if on Mac (MPS)
|
| 134 |
-
|
| 135 |
-
|
| 136 |
|
| 137 |
predictor = DefaultPredictor(cfg)
|
| 138 |
return predictor, cfg
|
|
|
|
| 22 |
from PIL import Image
|
| 23 |
from torchvision import transforms
|
| 24 |
import traceback
|
| 25 |
+
from configs.get_config import load_config
|
| 26 |
+
from models import *
|
| 27 |
|
| 28 |
# Add current directory to path
|
| 29 |
if not os.getcwd() in sys.path:
|
|
|
|
| 42 |
|
| 43 |
# Check for custom models
|
| 44 |
try:
|
| 45 |
+
|
|
|
|
| 46 |
MODELS_IMPORTED = True
|
| 47 |
except ImportError:
|
| 48 |
print("Warning: Custom models couldn't be imported. Only damage detection will work.")
|
|
|
|
| 121 |
return None, None
|
| 122 |
|
| 123 |
try:
|
| 124 |
+
print(f"Checking model path: {model_path}")
|
| 125 |
+
print(f"Model exists: {os.path.exists(model_path)}")
|
| 126 |
+
|
| 127 |
if model_path is None or not os.path.exists(model_path):
|
| 128 |
print(f"Error: Damage model file not found at {model_path}")
|
| 129 |
return None, None
|
|
|
|
| 135 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = threshold
|
| 136 |
|
| 137 |
# Use CPU if on Mac (MPS)
|
| 138 |
+
cfg.MODEL.DEVICE = "cpu"
|
| 139 |
+
print("Forcing Detectron2 to use CPU")
|
| 140 |
|
| 141 |
predictor = DefaultPredictor(cfg)
|
| 142 |
return predictor, cfg
|
requirements.txt
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
torch>=2.0.0
|
| 2 |
torchvision>=0.15.0
|
| 3 |
-
opencv-python
|
| 4 |
numpy>=1.24.0
|
| 5 |
Pillow>=10.0.0
|
| 6 |
gradio>=3.50.0
|
|
|
|
| 7 |
fvcore>=0.1.5.post20221221; platform_system!="Darwin"
|
| 8 |
iopath>=0.1.9; platform_system!="Darwin"
|
| 9 |
pycocotools>=2.0.6; platform_system!="Darwin"
|
|
|
|
| 1 |
torch>=2.0.0
|
| 2 |
torchvision>=0.15.0
|
| 3 |
+
opencv-python
|
| 4 |
numpy>=1.24.0
|
| 5 |
Pillow>=10.0.0
|
| 6 |
gradio>=3.50.0
|
| 7 |
+
python-box>=7.1.1
|
| 8 |
fvcore>=0.1.5.post20221221; platform_system!="Darwin"
|
| 9 |
iopath>=0.1.9; platform_system!="Darwin"
|
| 10 |
pycocotools>=2.0.6; platform_system!="Darwin"
|