Skip to content

Python Package that detects objects on the field.

Notifications You must be signed in to change notification settings

FRC-Team-1160/Detector

Repository files navigation

Detector

Python Package that detects objects on the field.

Install Anaconda (REQUIRED!)

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!

Install required packages

Make sure to install pip package manager here.

pip3 install -r requirements.txt

Usage

Roboflow API Inference

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)

YOlOv8 Inference

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)

Find the distance of the object

while True:
    img = frame.getFrame()
    detector.detect(img)
	dis = detector.getDistance(frame=frame)

Using a different model

Change the path of the model when creating detector object

Training the model (Google Colab or Nvidia GPU only!)

  1. Open Training/train_yolov8_object_detection.ipynb
  2. Run each cell
  3. BEFORE Custom Training, go to ChargedUp23 folder and change the path of train and val to the folder located in the ChargedUp23 folder
  4. Suggest starting with 50 epochs, and change depends on the training error to prevent from overfitting
  5. SKIP the cells under "deploy model on Roboflow"
  6. The weight file best.pt can be found in the runs/train#/weights folder

About

Python Package that detects objects on the field.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published