Python Package that detects objects on the field.
Pytorch requires a conda environment to work, follow the installation guide here
Follow the instructions here to create a conda environment
MAKE SURE TO ACTIVATE THE ENVIRONMENT!
Make sure to install pip package manager here.
pip3 install -r requirements.txt
Uses Roboflow's API to make predictions with trained model (trained on Roboflow)
import detect_API as detect
import cv2
result = detect.infer(img) # returns a np.ndarray
cv2.imshow(result)
Using the model trained by yolov8 to make predictions
from detector import Detector
from detector import Frame
detector = Detector("model_path",gpu=False) # choose to use CUDA GPU
frame = Frame("CAM_ID(usually 0)", verticalFOV="field of view of the camera" ) # field of view can be found online.
while True:
img = frame.getFrame()
detector.detect(img)
while True:
img = frame.getFrame()
detector.detect(img)
dis = detector.getDistance(frame=frame)
Change the path of the model when creating detector object
- Open Training/train_yolov8_object_detection.ipynb
- Run each cell
- BEFORE Custom Training, go to ChargedUp23 folder and change the path of train and val to the folder located in the ChargedUp23 folder
- Suggest starting with 50 epochs, and change depends on the training error to prevent from overfitting
- SKIP the cells under "deploy model on Roboflow"
- The weight file
best.pt
can be found in the runs/train#/weights folder