Lines and holes recognition in technical drawings (CAD) in yolov9

Hello,

i have problems to recognise lines in pictures of CAD drawings form my costum data set.
Is yolov9 the best tool for that, or should i use another?

my colab code:

#use GPU
!nvidia-smi

#mount google drive
from google.colab import drive
drive.mount(‘/content/gdrive’)
#drive.flush_and_unmount()

#Import the necessary libraries
import torch
if torch.cuda.is_available():
print(f"GPU Name: {torch.cuda.get_device_name(0)}“)
print(f"GPU is Available: {torch.cuda.is_available()}”)
else:
print(“GPU is not available”)

#create link
!ln -s /content/gdrive/My\ Drive/ /mydrive

#go to directory
%cd /mydrive/yolov9/

#colne a github
!git clone https–://–github-com/WongKinYiu/yolov9----git

#go to directory
%cd yolov9

#install requirements
!pip install -r requirements.txt

#get models
!wget -P /mydrive/yolov9/ https–:–//github----com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-c.pt
!wget -P /mydrive/yolov9/ https–:–//github------com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-e.pt

#get dataset
!pip install roboflow
from roboflow import Roboflow
rf = Roboflow(api_key=“8NQeSTnjAoLJRH77J9bg”)
project = rf.workspace(“solidworksaidrawingrecognation”).project(“drawingrecai”)
version = project.version(1)
dataset = version.download(“yolov9”)

#detect
!python detect.py --img 640 --conf 0.01 --device 0 --weights /mydrive/yolov9/yolov9/runs/train/exp5/weights/best.pt --source /mydrive/yolov9/3_Test.jpg

#show the result
from IPython.display import Image
Image(filename=f"/mydrive/yolov9/yolov9/runs/detect/exp22/3_Test.jpg", width=640)

#train the model
!python train_dual.py --workers 8 --batch 4 --img 640 --epochs 50 --data /content/DrawingRecAI-1/data.yaml --weights /mydrive/yolov9/yolov9-e.pt --device 0 --cfg /mydrive/yolov9/yolov9/models/detect/yolov9_custom.yaml --hyp /mydrive/yolov9/yolov9/data/hyps/hyp.scratch-high.yaml

Yes, YOLOv9 (and any YOLO model) will be useful for your project.

1 Like

Hi.

Do you see a mistake in my code, or in my dataset?
It doesn’t recognize holes or lines in a copy of those pictures when i try the detect.py block after i trained it the train-dual.py block.
(You need to delete the " - " in the http links of my code)

Or do you have a working code for me which detects lines on drawings?

Thanks

Hey @Dan

Did you see an error message? If not, you most likely did not make a mistake. Training computer vision models is an iterative process that requires testing and improvement.

I would suggest increasing your dataset size. Usually, this can be done through some combination of labeling more data, as well as using augmentations to increase your dataset size.

From your linked dataset, it looks like you only have a total of 6 images, with 5 for training, 1 for validation, and 0 for testing. In your case, since you only have one image for the valid split and zero for the test split, I definitely recommend you label more data until there are at least several in each split. (since augmentations only apply to the training split)

See:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.