Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,12 @@ import torch
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import matplotlib.pyplot as plt
|
|
|
6 |
|
7 |
-
# Load the trained YOLOv5 model (best.pt)
|
8 |
-
model =
|
9 |
-
model.eval() # Put the model in evaluation mode
|
10 |
|
11 |
-
# Function to process video and calculate ball trajectory, speed, and visualize the pitch
|
12 |
def process_video(video_file):
|
13 |
# Load video file using OpenCV
|
14 |
video = cv2.VideoCapture(video_file.name)
|
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import matplotlib.pyplot as plt
|
6 |
+
from yolov5 import YOLOv5
|
7 |
|
8 |
+
# Load the trained YOLOv5 model (best.pt) using the YOLOv5 library
|
9 |
+
model = YOLOv5("best.pt") # This will use YOLOv5's internal loading mechanism
|
|
|
10 |
|
11 |
+
# Function to process the video and calculate ball trajectory, speed, and visualize the pitch
|
12 |
def process_video(video_file):
|
13 |
# Load video file using OpenCV
|
14 |
video = cv2.VideoCapture(video_file.name)
|