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

**URL:** <https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152>\
**Category:** 🤝  Community Help\
**Created:** [April 5, 2024, 4:54am UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152 "2024-04-05T04:54:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/dan/32/4188_2.png) [@Dan](https://discuss.roboflow.com/u/Dan)\
**Post date:** [April 5, 2024, 4:54am UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152/1 "2024-04-05T04:54:27Z")

</div>

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?

> **[DrawingRecAI Object Detection Dataset (v1, 2024-04-04 9:52am) by...](https://universe.roboflow.com/solidworksaidrawingrecognation/drawingrecai/dataset/1)**
>
> 6 open source lines-holes-drawing images and annotations in multiple formats for training computer vision models. DrawingRecAI (v1, 2024-04-04 9:52am), created by SolidworksAIDrawingRecognation

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

---

<div class="post-metadata">

**Author:** ![trevorhlynn](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/trevorhlynn/32/1690_2.png) [@trevorhlynn](https://discuss.roboflow.com/u/trevorhlynn)\
**Post date:** [April 5, 2024, 5:36pm UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152/2 "2024-04-05T17:36:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dan](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/dan/32/4188_2.png) [@Dan](https://discuss.roboflow.com/u/Dan)\
**Post date:** [April 6, 2024, 5:19am UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152/3 "2024-04-06T05:19:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leo/32/2228_2.png) [@leo](https://discuss.roboflow.com/u/leo)\
**Post date:** [April 8, 2024, 2:12pm UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152/4 "2024-04-08T14:12:02Z")

</div>

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:

> **[Launch: Edge Tiling During Inference](https://blog.roboflow.com/edge-tiling-during-inference/)**
>
> Roboflow supports tiling during training to detect small objects in large images, and now you can use tiling during inference on edge devices.

> **[How to Improve Your Computer Vision Model](https://blog.roboflow.com/model-best-practices/)**
>
> In this guide, we review best practices to guide you toward you building high quality computer vision models.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [April 29, 2024, 2:12pm UTC](https://discuss.roboflow.com/t/lines-and-holes-recognition-in-technical-drawings-cad-in-yolov9/5152/5 "2024-04-29T14:12:50Z")

</div>

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