AjaykumarPilla commited on
Commit
3c5c2d2
·
verified ·
1 Parent(s): 3fc982b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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) from a local path
8
- model = torch.load("best.pt", map_location="cpu") # Adjust the path as needed
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)