Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,25 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
import
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
"detections": detections,
|
27 |
-
"thermal": bool(thermal),
|
28 |
-
"shadow_issue": shadow_flag,
|
29 |
-
}
|
30 |
-
|
31 |
-
send_to_salesforce(alert_payload)
|
32 |
-
return frame
|
33 |
-
except StopIteration:
|
34 |
-
return None
|
35 |
-
|
36 |
-
iface = gr.Interface(fn=monitor_feed, inputs=[], outputs="image", live=True, title="VIEP Smart Pole Video Fault Detector")
|
37 |
-
iface.launch()
|
|
|
1 |
+
# Import necessary libraries
|
2 |
+
import warnings
|
3 |
+
from ultralytics import YOLO # Ensure ultralytics is installed
|
4 |
+
from transformers import pipeline, DetrImageProcessor
|
5 |
+
|
6 |
+
# Suppress unnecessary warnings
|
7 |
+
warnings.filterwarnings("ignore", message=".*copying from a non-meta parameter.*")
|
8 |
+
|
9 |
+
# Setup the image processor
|
10 |
+
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", use_fast=True)
|
11 |
+
|
12 |
+
# Load the YOLO model (make sure ultralytics is installed)
|
13 |
+
model = YOLO("yolov5s.pt") # Change to the model you are using
|
14 |
+
|
15 |
+
# Your model inference or other operations
|
16 |
+
# Example detection function
|
17 |
+
def detect_objects(image):
|
18 |
+
# Use your model for object detection
|
19 |
+
results = model(image)
|
20 |
+
return results
|
21 |
+
|
22 |
+
# Call the function
|
23 |
+
image = "path_to_image.jpg" # Replace with your image path
|
24 |
+
detection_results = detect_objects(image)
|
25 |
+
print(detection_results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|