Spaces:
Running
on
Zero
Running
on
Zero
remove share and debug, add spaces
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from PIL import Image
|
|
| 11 |
import torch
|
| 12 |
from transformers import AutoModelForCausalLM
|
| 13 |
import supervision as sv
|
|
|
|
| 14 |
|
| 15 |
model_id = "moondream/moondream3-preview"
|
| 16 |
|
|
@@ -76,11 +77,9 @@ def create_annotated_image(image, detection_result, object_name="Object"):
|
|
| 76 |
return Image.fromarray(annotated_image)
|
| 77 |
|
| 78 |
|
| 79 |
-
|
| 80 |
def process_video_with_tracking(video_path, prompt, detection_interval=3):
|
| 81 |
-
|
| 82 |
cap = cv2.VideoCapture(video_path)
|
| 83 |
-
|
| 84 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
| 85 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 86 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
@@ -212,6 +211,7 @@ def create_point_annotated_image(image, point_result):
|
|
| 212 |
|
| 213 |
return Image.fromarray(annotated_image)
|
| 214 |
|
|
|
|
| 215 |
def detect_objects(image, prompt, task_type, max_objects):
|
| 216 |
STANDARD_SIZE = (1024, 1024)
|
| 217 |
image.thumbnail(STANDARD_SIZE)
|
|
@@ -436,4 +436,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 436 |
)
|
| 437 |
|
| 438 |
if __name__ == "__main__":
|
| 439 |
-
demo.launch(
|
|
|
|
| 11 |
import torch
|
| 12 |
from transformers import AutoModelForCausalLM
|
| 13 |
import supervision as sv
|
| 14 |
+
import spaces
|
| 15 |
|
| 16 |
model_id = "moondream/moondream3-preview"
|
| 17 |
|
|
|
|
| 77 |
return Image.fromarray(annotated_image)
|
| 78 |
|
| 79 |
|
| 80 |
+
@spaces.GPU()
|
| 81 |
def process_video_with_tracking(video_path, prompt, detection_interval=3):
|
|
|
|
| 82 |
cap = cv2.VideoCapture(video_path)
|
|
|
|
| 83 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
| 84 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 85 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
|
|
| 211 |
|
| 212 |
return Image.fromarray(annotated_image)
|
| 213 |
|
| 214 |
+
@spaces.GPU()
|
| 215 |
def detect_objects(image, prompt, task_type, max_objects):
|
| 216 |
STANDARD_SIZE = (1024, 1024)
|
| 217 |
image.thumbnail(STANDARD_SIZE)
|
|
|
|
| 436 |
)
|
| 437 |
|
| 438 |
if __name__ == "__main__":
|
| 439 |
+
demo.launch()
|