everyone. i am trying to train yolov9 on some custom data on PyCharm instead of google colab as suggested by many tutorials i have watched. how do i do this?
I installed all the requirements in my virtual environment after cloning the repository into my computer. i then created training scripts which is where i think i feel short.
This is my training script:
import os
import subprocess
dataset_path = 'C:/Users/rsingh/Desktop/Rahul_PDC/Repositories/Smart_Factory/YoloV5_Training/sfd_colorobject'
def train_yolov5(train_images_path, val_images_path, yaml_file_path, weights_path='C:/Users/rsingh/Desktop/Musa_PDC/yolov9-main/yolov9-c.pt', epochs=50):
# Get the absolute path to the yolov5 directory
yolov9_dir = os.path.abspath('C:/Users/rsingh/Desktop/Musa_PDC/yolov9-main')
# Change the current working directory to yolov9 directory
os.chdir(yolov9_dir)
# train yolov9 models
command = f'python train.py --workers 8 --device cpu --batch 16 --data {dataset_path}/sfdV2_musa.yaml --img 640 --cfg models/detect/yolov9-c.yaml --weights yolov9-c --hyp hyp.scratch-high.yaml --min-items 0 --epochs 5 --close-mosaic 15'
# Execute the command
process = subprocess.Popen(command, shell=True)
process.wait()
if __name__ == "__main__":
TRAIN_IMAGES_PATH = (
'C:/Users/rsingh/Desktop/Rahul_PDC/Repositories/Smart_Factory/YoloV5_Training/sfd_colorobject/captured_images/images/train')
VAL_IMAGES_PATH = (
'C:/Users/rsingh/Desktop/Rahul_PDC/Repositories/Smart_Factory/YoloV5_Training/sfd_colorobject/captured_images/images/val')
YAML_FILE_PATH = (
'C:/Users/rsingh/Desktop/Rahul_PDC/Repositories/Smart_Factory/YoloV5_Training/sfd_colorobject/sfdV2_musa.yaml')
# Train the YOLOv9 model
train_yolov5(TRAIN_IMAGES_PATH, VAL_IMAGES_PATH, YAML_FILE_PATH)`
New contributor
Musa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.