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


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

#mount google drive
from google.colab import drive

#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()}”)
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/
!wget -P /mydrive/yolov9/ https–:–//github------com/WongKinYiu/yolov9/releases/download/v0.1/

#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 =“yolov9”)

!python --img 640 --conf 0.01 --device 0 --weights /mydrive/yolov9/yolov9/runs/train/exp5/weights/ --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 --workers 8 --batch 4 --img 640 --epochs 50 --data /content/DrawingRecAI-1/data.yaml --weights /mydrive/yolov9/ --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


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 block after i trained it the 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?


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)


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