Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,10 @@ import gradio as gr
|
|
5 |
from ultralytics import YOLO
|
6 |
|
7 |
# Check if CUDA (GPU support) is available
|
8 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
# Load the YOLOv8 model
|
11 |
-
model = YOLO('yolov8x-seg.pt')
|
12 |
|
13 |
def process_video(input_video_path):
|
14 |
cap = cv2.VideoCapture(input_video_path)
|
@@ -31,7 +31,7 @@ def process_video(input_video_path):
|
|
31 |
resized_frame = cv2.resize(frame, (640, 640))
|
32 |
|
33 |
# Convert resized frame to torch tensor and move it to GPU
|
34 |
-
frame_tensor = torch.from_numpy(resized_frame).permute(2, 0, 1).unsqueeze(0).float()
|
35 |
|
36 |
threshold = 0.1
|
37 |
frame_copy = frame.copy()
|
|
|
5 |
from ultralytics import YOLO
|
6 |
|
7 |
# Check if CUDA (GPU support) is available
|
8 |
+
# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
# Load the YOLOv8 model
|
11 |
+
model = YOLO('yolov8x-seg.pt')
|
12 |
|
13 |
def process_video(input_video_path):
|
14 |
cap = cv2.VideoCapture(input_video_path)
|
|
|
31 |
resized_frame = cv2.resize(frame, (640, 640))
|
32 |
|
33 |
# Convert resized frame to torch tensor and move it to GPU
|
34 |
+
frame_tensor = torch.from_numpy(resized_frame).permute(2, 0, 1).unsqueeze(0).float() / 255.0
|
35 |
|
36 |
threshold = 0.1
|
37 |
frame_copy = frame.copy()
|