yasirfaizahmed commited on
Commit
10ff447
·
verified ·
1 Parent(s): 7f99a40

Upload train.ipynb

Browse files
Files changed (1) hide show
  1. train.ipynb +856 -0
train.ipynb ADDED
@@ -0,0 +1,856 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 13,
6
+ "id": "c8bdf258",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "New https://pypi.org/project/ultralytics/8.3.172 available 😃 Update with 'pip install -U ultralytics'\n",
14
+ "Ultralytics 8.3.171 🚀 Python-3.12.3 torch-2.7.1+cu126 CUDA:0 (NVIDIA GeForce RTX 3060, 11910MiB)\n",
15
+ "\u001b[34m\u001b[1mengine/trainer: \u001b[0magnostic_nms=False, amp=True, augment=False, auto_augment=randaugment, batch=16, bgr=0.0, box=7.5, cache=False, cfg=None, classes=None, close_mosaic=10, cls=0.5, conf=None, copy_paste=0.0, copy_paste_mode=flip, cos_lr=False, cutmix=0.0, data=/home/xd/Documents/ML_AI/ui_detection_yolo/data.yml, degrees=0.0, deterministic=True, device=0, dfl=1.5, dnn=False, dropout=0.0, dynamic=False, embed=None, epochs=20, erasing=0.4, exist_ok=False, fliplr=0.5, flipud=0.0, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=640, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.01, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=yolov8n.pt, momentum=0.937, mosaic=1.0, multi_scale=False, name=train5, nbs=64, nms=False, opset=None, optimize=False, optimizer=auto, overlap_mask=True, patience=100, perspective=0.0, plots=True, pose=12.0, pretrained=True, profile=False, project=None, rect=False, resume=False, retina_masks=False, save=True, save_conf=False, save_crop=False, save_dir=runs/detect/train5, save_frames=False, save_json=False, save_period=-1, save_txt=False, scale=0.5, seed=0, shear=0.0, show=False, show_boxes=True, show_conf=True, show_labels=True, simplify=True, single_cls=False, source=None, split=val, stream_buffer=False, task=detect, time=None, tracker=botsort.yaml, translate=0.1, val=True, verbose=True, vid_stride=1, visualize=False, warmup_bias_lr=0.1, warmup_epochs=3.0, warmup_momentum=0.8, weight_decay=0.0005, workers=8, workspace=None\n",
16
+ "Overriding model.yaml nc=80 with nc=21\n",
17
+ "\n",
18
+ " from n params module arguments \n",
19
+ " 0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2] \n",
20
+ " 1 -1 1 4672 ultralytics.nn.modules.conv.Conv [16, 32, 3, 2] \n",
21
+ " 2 -1 1 7360 ultralytics.nn.modules.block.C2f [32, 32, 1, True] \n",
22
+ " 3 -1 1 18560 ultralytics.nn.modules.conv.Conv [32, 64, 3, 2] \n",
23
+ " 4 -1 2 49664 ultralytics.nn.modules.block.C2f [64, 64, 2, True] \n",
24
+ " 5 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2] \n",
25
+ " 6 -1 2 197632 ultralytics.nn.modules.block.C2f [128, 128, 2, True] \n",
26
+ " 7 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2] \n",
27
+ " 8 -1 1 460288 ultralytics.nn.modules.block.C2f [256, 256, 1, True] \n",
28
+ " 9 -1 1 164608 ultralytics.nn.modules.block.SPPF [256, 256, 5] \n",
29
+ " 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
30
+ " 11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
31
+ " 12 -1 1 148224 ultralytics.nn.modules.block.C2f [384, 128, 1] \n",
32
+ " 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
33
+ " 14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
34
+ " 15 -1 1 37248 ultralytics.nn.modules.block.C2f [192, 64, 1] \n",
35
+ " 16 -1 1 36992 ultralytics.nn.modules.conv.Conv [64, 64, 3, 2] \n",
36
+ " 17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
37
+ " 18 -1 1 123648 ultralytics.nn.modules.block.C2f [192, 128, 1] \n",
38
+ " 19 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2] \n",
39
+ " 20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
40
+ " 21 -1 1 493056 ultralytics.nn.modules.block.C2f [384, 256, 1] \n",
41
+ " 22 [15, 18, 21] 1 755407 ultralytics.nn.modules.head.Detect [21, [64, 128, 256]] \n",
42
+ "Model summary: 129 layers, 3,014,943 parameters, 3,014,927 gradients, 8.2 GFLOPs\n",
43
+ "\n",
44
+ "Transferred 319/355 items from pretrained weights\n",
45
+ "Freezing layer 'model.22.dfl.conv.weight'\n",
46
+ "\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks...\n",
47
+ "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n",
48
+ "\u001b[34m\u001b[1mtrain: \u001b[0mFast image access ✅ (ping: 0.0±0.0 ms, read: 5872.4±1709.8 MB/s, size: 167.0 KB)\n"
49
+ ]
50
+ },
51
+ {
52
+ "name": "stderr",
53
+ "output_type": "stream",
54
+ "text": [
55
+ "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /home/xd/Documents/ML_AI/ui_detection_yolo/dataset/train/labels... 3845 images, 0 backgrounds, 0 corrupt: 100%|██████████| 3845/3845 [00:03<00:00, 1107.02it/s]"
56
+ ]
57
+ },
58
+ {
59
+ "name": "stdout",
60
+ "output_type": "stream",
61
+ "text": [
62
+ "\u001b[34m\u001b[1mtrain: \u001b[0m/home/xd/Documents/ML_AI/ui_detection_yolo/dataset/train/images/69825a2b08bd43c7a9ca4fcd3cd8c8c2.jpg: 1 duplicate labels removed\n",
63
+ "\u001b[34m\u001b[1mtrain: \u001b[0mNew cache created: /home/xd/Documents/ML_AI/ui_detection_yolo/dataset/train/labels.cache\n"
64
+ ]
65
+ },
66
+ {
67
+ "name": "stderr",
68
+ "output_type": "stream",
69
+ "text": [
70
+ "\n"
71
+ ]
72
+ },
73
+ {
74
+ "name": "stdout",
75
+ "output_type": "stream",
76
+ "text": [
77
+ "\u001b[34m\u001b[1mval: \u001b[0mFast image access ✅ (ping: 0.0±0.0 ms, read: 754.3±135.6 MB/s, size: 109.7 KB)\n"
78
+ ]
79
+ },
80
+ {
81
+ "name": "stderr",
82
+ "output_type": "stream",
83
+ "text": [
84
+ "\u001b[34m\u001b[1mval: \u001b[0mScanning /home/xd/Documents/ML_AI/ui_detection_yolo/dataset/val/labels... 481 images, 0 backgrounds, 0 corrupt: 100%|██████████| 481/481 [00:00<00:00, 1961.08it/s]"
85
+ ]
86
+ },
87
+ {
88
+ "name": "stdout",
89
+ "output_type": "stream",
90
+ "text": [
91
+ "\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /home/xd/Documents/ML_AI/ui_detection_yolo/dataset/val/labels.cache\n"
92
+ ]
93
+ },
94
+ {
95
+ "name": "stderr",
96
+ "output_type": "stream",
97
+ "text": [
98
+ "\n"
99
+ ]
100
+ },
101
+ {
102
+ "name": "stdout",
103
+ "output_type": "stream",
104
+ "text": [
105
+ "Plotting labels to runs/detect/train5/labels.jpg... \n",
106
+ "\u001b[34m\u001b[1moptimizer:\u001b[0m 'optimizer=auto' found, ignoring 'lr0=0.01' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... \n",
107
+ "\u001b[34m\u001b[1moptimizer:\u001b[0m AdamW(lr=0.0004, momentum=0.9) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)\n",
108
+ "Image sizes 640 train, 640 val\n",
109
+ "Using 8 dataloader workers\n",
110
+ "Logging results to \u001b[1mruns/detect/train5\u001b[0m\n",
111
+ "Starting training for 20 epochs...\n",
112
+ "\n",
113
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
114
+ ]
115
+ },
116
+ {
117
+ "name": "stderr",
118
+ "output_type": "stream",
119
+ "text": [
120
+ " 1/20 2.88G 1.154 2.561 1.105 78 640: 100%|██████████| 241/241 [00:30<00:00, 8.00it/s]\n",
121
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 8.99it/s]\n"
122
+ ]
123
+ },
124
+ {
125
+ "name": "stdout",
126
+ "output_type": "stream",
127
+ "text": [
128
+ " all 481 6875 0.827 0.327 0.359 0.282\n",
129
+ "\n",
130
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
131
+ ]
132
+ },
133
+ {
134
+ "name": "stderr",
135
+ "output_type": "stream",
136
+ "text": [
137
+ " 2/20 3.31G 0.8688 1.187 0.9828 103 640: 100%|██████████| 241/241 [00:29<00:00, 8.27it/s]\n",
138
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.55it/s]"
139
+ ]
140
+ },
141
+ {
142
+ "name": "stdout",
143
+ "output_type": "stream",
144
+ "text": [
145
+ " all 481 6875 0.823 0.449 0.501 0.405\n"
146
+ ]
147
+ },
148
+ {
149
+ "name": "stderr",
150
+ "output_type": "stream",
151
+ "text": [
152
+ "\n"
153
+ ]
154
+ },
155
+ {
156
+ "name": "stdout",
157
+ "output_type": "stream",
158
+ "text": [
159
+ "\n",
160
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
161
+ ]
162
+ },
163
+ {
164
+ "name": "stderr",
165
+ "output_type": "stream",
166
+ "text": [
167
+ " 3/20 3.32G 0.784 1.012 0.9498 119 640: 100%|██████████| 241/241 [00:28<00:00, 8.38it/s]\n",
168
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.34it/s]"
169
+ ]
170
+ },
171
+ {
172
+ "name": "stdout",
173
+ "output_type": "stream",
174
+ "text": [
175
+ " all 481 6875 0.856 0.476 0.519 0.428\n"
176
+ ]
177
+ },
178
+ {
179
+ "name": "stderr",
180
+ "output_type": "stream",
181
+ "text": [
182
+ "\n"
183
+ ]
184
+ },
185
+ {
186
+ "name": "stdout",
187
+ "output_type": "stream",
188
+ "text": [
189
+ "\n",
190
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
191
+ ]
192
+ },
193
+ {
194
+ "name": "stderr",
195
+ "output_type": "stream",
196
+ "text": [
197
+ " 4/20 3.56G 0.7496 0.9416 0.9344 106 640: 100%|██████████| 241/241 [00:28<00:00, 8.35it/s]\n",
198
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.47it/s]"
199
+ ]
200
+ },
201
+ {
202
+ "name": "stdout",
203
+ "output_type": "stream",
204
+ "text": [
205
+ " all 481 6875 0.85 0.518 0.597 0.508\n"
206
+ ]
207
+ },
208
+ {
209
+ "name": "stderr",
210
+ "output_type": "stream",
211
+ "text": [
212
+ "\n"
213
+ ]
214
+ },
215
+ {
216
+ "name": "stdout",
217
+ "output_type": "stream",
218
+ "text": [
219
+ "\n",
220
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
221
+ ]
222
+ },
223
+ {
224
+ "name": "stderr",
225
+ "output_type": "stream",
226
+ "text": [
227
+ " 5/20 3.56G 0.7189 0.8863 0.9241 136 640: 100%|██████████| 241/241 [00:28<00:00, 8.38it/s]\n",
228
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.63it/s]"
229
+ ]
230
+ },
231
+ {
232
+ "name": "stdout",
233
+ "output_type": "stream",
234
+ "text": [
235
+ " all 481 6875 0.725 0.59 0.618 0.521\n"
236
+ ]
237
+ },
238
+ {
239
+ "name": "stderr",
240
+ "output_type": "stream",
241
+ "text": [
242
+ "\n"
243
+ ]
244
+ },
245
+ {
246
+ "name": "stdout",
247
+ "output_type": "stream",
248
+ "text": [
249
+ "\n",
250
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
251
+ ]
252
+ },
253
+ {
254
+ "name": "stderr",
255
+ "output_type": "stream",
256
+ "text": [
257
+ " 6/20 3.57G 0.6922 0.8384 0.9155 144 640: 100%|██████████| 241/241 [00:28<00:00, 8.38it/s]\n",
258
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.61it/s]"
259
+ ]
260
+ },
261
+ {
262
+ "name": "stdout",
263
+ "output_type": "stream",
264
+ "text": [
265
+ " all 481 6875 0.774 0.584 0.635 0.541\n"
266
+ ]
267
+ },
268
+ {
269
+ "name": "stderr",
270
+ "output_type": "stream",
271
+ "text": [
272
+ "\n"
273
+ ]
274
+ },
275
+ {
276
+ "name": "stdout",
277
+ "output_type": "stream",
278
+ "text": [
279
+ "\n",
280
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
281
+ ]
282
+ },
283
+ {
284
+ "name": "stderr",
285
+ "output_type": "stream",
286
+ "text": [
287
+ " 7/20 3.58G 0.6745 0.8128 0.9085 124 640: 100%|██████████| 241/241 [00:28<00:00, 8.34it/s]\n",
288
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.58it/s]"
289
+ ]
290
+ },
291
+ {
292
+ "name": "stdout",
293
+ "output_type": "stream",
294
+ "text": [
295
+ " all 481 6875 0.769 0.601 0.673 0.576\n"
296
+ ]
297
+ },
298
+ {
299
+ "name": "stderr",
300
+ "output_type": "stream",
301
+ "text": [
302
+ "\n"
303
+ ]
304
+ },
305
+ {
306
+ "name": "stdout",
307
+ "output_type": "stream",
308
+ "text": [
309
+ "\n",
310
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
311
+ ]
312
+ },
313
+ {
314
+ "name": "stderr",
315
+ "output_type": "stream",
316
+ "text": [
317
+ " 8/20 3.86G 0.6598 0.78 0.9037 87 640: 100%|██████████| 241/241 [00:28<00:00, 8.34it/s]\n",
318
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.48it/s]"
319
+ ]
320
+ },
321
+ {
322
+ "name": "stdout",
323
+ "output_type": "stream",
324
+ "text": [
325
+ " all 481 6875 0.776 0.622 0.682 0.598\n"
326
+ ]
327
+ },
328
+ {
329
+ "name": "stderr",
330
+ "output_type": "stream",
331
+ "text": [
332
+ "\n"
333
+ ]
334
+ },
335
+ {
336
+ "name": "stdout",
337
+ "output_type": "stream",
338
+ "text": [
339
+ "\n",
340
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
341
+ ]
342
+ },
343
+ {
344
+ "name": "stderr",
345
+ "output_type": "stream",
346
+ "text": [
347
+ " 9/20 3.86G 0.6381 0.7502 0.8973 162 640: 100%|██████████| 241/241 [00:28<00:00, 8.37it/s]\n",
348
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.77it/s]"
349
+ ]
350
+ },
351
+ {
352
+ "name": "stdout",
353
+ "output_type": "stream",
354
+ "text": [
355
+ " all 481 6875 0.692 0.609 0.654 0.573\n"
356
+ ]
357
+ },
358
+ {
359
+ "name": "stderr",
360
+ "output_type": "stream",
361
+ "text": [
362
+ "\n"
363
+ ]
364
+ },
365
+ {
366
+ "name": "stdout",
367
+ "output_type": "stream",
368
+ "text": [
369
+ "\n",
370
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
371
+ ]
372
+ },
373
+ {
374
+ "name": "stderr",
375
+ "output_type": "stream",
376
+ "text": [
377
+ " 10/20 3.86G 0.6308 0.7258 0.8911 114 640: 100%|██████████| 241/241 [00:29<00:00, 8.28it/s]\n",
378
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.66it/s]"
379
+ ]
380
+ },
381
+ {
382
+ "name": "stdout",
383
+ "output_type": "stream",
384
+ "text": [
385
+ " all 481 6875 0.721 0.625 0.664 0.582\n"
386
+ ]
387
+ },
388
+ {
389
+ "name": "stderr",
390
+ "output_type": "stream",
391
+ "text": [
392
+ "\n"
393
+ ]
394
+ },
395
+ {
396
+ "name": "stdout",
397
+ "output_type": "stream",
398
+ "text": [
399
+ "Closing dataloader mosaic\n",
400
+ "\n",
401
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
402
+ ]
403
+ },
404
+ {
405
+ "name": "stderr",
406
+ "output_type": "stream",
407
+ "text": [
408
+ " 11/20 3.86G 0.6223 0.7513 0.8781 44 640: 100%|██████████| 241/241 [00:28<00:00, 8.55it/s]\n",
409
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.53it/s]"
410
+ ]
411
+ },
412
+ {
413
+ "name": "stdout",
414
+ "output_type": "stream",
415
+ "text": [
416
+ " all 481 6875 0.716 0.631 0.667 0.583\n"
417
+ ]
418
+ },
419
+ {
420
+ "name": "stderr",
421
+ "output_type": "stream",
422
+ "text": [
423
+ "\n"
424
+ ]
425
+ },
426
+ {
427
+ "name": "stdout",
428
+ "output_type": "stream",
429
+ "text": [
430
+ "\n",
431
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
432
+ ]
433
+ },
434
+ {
435
+ "name": "stderr",
436
+ "output_type": "stream",
437
+ "text": [
438
+ " 12/20 3.86G 0.6038 0.7067 0.8681 59 640: 100%|██████████| 241/241 [00:27<00:00, 8.71it/s]\n",
439
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.62it/s]"
440
+ ]
441
+ },
442
+ {
443
+ "name": "stdout",
444
+ "output_type": "stream",
445
+ "text": [
446
+ " all 481 6875 0.769 0.633 0.691 0.609\n"
447
+ ]
448
+ },
449
+ {
450
+ "name": "stderr",
451
+ "output_type": "stream",
452
+ "text": [
453
+ "\n"
454
+ ]
455
+ },
456
+ {
457
+ "name": "stdout",
458
+ "output_type": "stream",
459
+ "text": [
460
+ "\n",
461
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
462
+ ]
463
+ },
464
+ {
465
+ "name": "stderr",
466
+ "output_type": "stream",
467
+ "text": [
468
+ " 13/20 3.86G 0.5843 0.675 0.8647 41 640: 100%|██████████| 241/241 [00:27<00:00, 8.71it/s]\n",
469
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.58it/s]"
470
+ ]
471
+ },
472
+ {
473
+ "name": "stdout",
474
+ "output_type": "stream",
475
+ "text": [
476
+ " all 481 6875 0.759 0.627 0.673 0.597\n"
477
+ ]
478
+ },
479
+ {
480
+ "name": "stderr",
481
+ "output_type": "stream",
482
+ "text": [
483
+ "\n"
484
+ ]
485
+ },
486
+ {
487
+ "name": "stdout",
488
+ "output_type": "stream",
489
+ "text": [
490
+ "\n",
491
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
492
+ ]
493
+ },
494
+ {
495
+ "name": "stderr",
496
+ "output_type": "stream",
497
+ "text": [
498
+ " 14/20 3.86G 0.5757 0.6552 0.8599 55 640: 100%|██████████| 241/241 [00:27<00:00, 8.71it/s]\n",
499
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.85it/s]"
500
+ ]
501
+ },
502
+ {
503
+ "name": "stdout",
504
+ "output_type": "stream",
505
+ "text": [
506
+ " all 481 6875 0.809 0.639 0.704 0.63\n"
507
+ ]
508
+ },
509
+ {
510
+ "name": "stderr",
511
+ "output_type": "stream",
512
+ "text": [
513
+ "\n"
514
+ ]
515
+ },
516
+ {
517
+ "name": "stdout",
518
+ "output_type": "stream",
519
+ "text": [
520
+ "\n",
521
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
522
+ ]
523
+ },
524
+ {
525
+ "name": "stderr",
526
+ "output_type": "stream",
527
+ "text": [
528
+ " 15/20 3.86G 0.5684 0.6373 0.857 105 640: 100%|██████████| 241/241 [00:27<00:00, 8.73it/s]\n",
529
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.79it/s]"
530
+ ]
531
+ },
532
+ {
533
+ "name": "stdout",
534
+ "output_type": "stream",
535
+ "text": [
536
+ " all 481 6875 0.764 0.646 0.692 0.619\n"
537
+ ]
538
+ },
539
+ {
540
+ "name": "stderr",
541
+ "output_type": "stream",
542
+ "text": [
543
+ "\n"
544
+ ]
545
+ },
546
+ {
547
+ "name": "stdout",
548
+ "output_type": "stream",
549
+ "text": [
550
+ "\n",
551
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
552
+ ]
553
+ },
554
+ {
555
+ "name": "stderr",
556
+ "output_type": "stream",
557
+ "text": [
558
+ " 16/20 3.86G 0.5521 0.6189 0.8535 53 640: 100%|██████████| 241/241 [00:27<00:00, 8.68it/s]\n",
559
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.79it/s]"
560
+ ]
561
+ },
562
+ {
563
+ "name": "stdout",
564
+ "output_type": "stream",
565
+ "text": [
566
+ " all 481 6875 0.751 0.623 0.68 0.612\n"
567
+ ]
568
+ },
569
+ {
570
+ "name": "stderr",
571
+ "output_type": "stream",
572
+ "text": [
573
+ "\n"
574
+ ]
575
+ },
576
+ {
577
+ "name": "stdout",
578
+ "output_type": "stream",
579
+ "text": [
580
+ "\n",
581
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
582
+ ]
583
+ },
584
+ {
585
+ "name": "stderr",
586
+ "output_type": "stream",
587
+ "text": [
588
+ " 17/20 3.86G 0.544 0.6061 0.8504 45 640: 100%|██████████| 241/241 [00:27<00:00, 8.74it/s]\n",
589
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.99it/s]"
590
+ ]
591
+ },
592
+ {
593
+ "name": "stdout",
594
+ "output_type": "stream",
595
+ "text": [
596
+ " all 481 6875 0.753 0.664 0.692 0.624\n"
597
+ ]
598
+ },
599
+ {
600
+ "name": "stderr",
601
+ "output_type": "stream",
602
+ "text": [
603
+ "\n"
604
+ ]
605
+ },
606
+ {
607
+ "name": "stdout",
608
+ "output_type": "stream",
609
+ "text": [
610
+ "\n",
611
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
612
+ ]
613
+ },
614
+ {
615
+ "name": "stderr",
616
+ "output_type": "stream",
617
+ "text": [
618
+ " 18/20 3.86G 0.548 0.5979 0.8497 56 640: 100%|██████████| 241/241 [00:27<00:00, 8.73it/s]\n",
619
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.85it/s]"
620
+ ]
621
+ },
622
+ {
623
+ "name": "stdout",
624
+ "output_type": "stream",
625
+ "text": [
626
+ " all 481 6875 0.752 0.647 0.689 0.624\n"
627
+ ]
628
+ },
629
+ {
630
+ "name": "stderr",
631
+ "output_type": "stream",
632
+ "text": [
633
+ "\n"
634
+ ]
635
+ },
636
+ {
637
+ "name": "stdout",
638
+ "output_type": "stream",
639
+ "text": [
640
+ "\n",
641
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
642
+ ]
643
+ },
644
+ {
645
+ "name": "stderr",
646
+ "output_type": "stream",
647
+ "text": [
648
+ " 19/20 3.86G 0.5285 0.58 0.8455 73 640: 100%|██████████| 241/241 [00:27<00:00, 8.74it/s]\n",
649
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 11.85it/s]"
650
+ ]
651
+ },
652
+ {
653
+ "name": "stdout",
654
+ "output_type": "stream",
655
+ "text": [
656
+ " all 481 6875 0.735 0.672 0.691 0.625\n"
657
+ ]
658
+ },
659
+ {
660
+ "name": "stderr",
661
+ "output_type": "stream",
662
+ "text": [
663
+ "\n"
664
+ ]
665
+ },
666
+ {
667
+ "name": "stdout",
668
+ "output_type": "stream",
669
+ "text": [
670
+ "\n",
671
+ " Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n"
672
+ ]
673
+ },
674
+ {
675
+ "name": "stderr",
676
+ "output_type": "stream",
677
+ "text": [
678
+ " 20/20 3.86G 0.525 0.5689 0.8472 72 640: 100%|██████████| 241/241 [00:27<00:00, 8.74it/s]\n",
679
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:01<00:00, 10.56it/s]"
680
+ ]
681
+ },
682
+ {
683
+ "name": "stdout",
684
+ "output_type": "stream",
685
+ "text": [
686
+ " all 481 6875 0.786 0.679 0.707 0.641\n",
687
+ "\n",
688
+ "20 epochs completed in 0.166 hours.\n"
689
+ ]
690
+ },
691
+ {
692
+ "name": "stderr",
693
+ "output_type": "stream",
694
+ "text": [
695
+ "\n"
696
+ ]
697
+ },
698
+ {
699
+ "name": "stdout",
700
+ "output_type": "stream",
701
+ "text": [
702
+ "Optimizer stripped from runs/detect/train5/weights/last.pt, 6.2MB\n",
703
+ "Optimizer stripped from runs/detect/train5/weights/best.pt, 6.2MB\n",
704
+ "\n",
705
+ "Validating runs/detect/train5/weights/best.pt...\n",
706
+ "Ultralytics 8.3.171 🚀 Python-3.12.3 torch-2.7.1+cu126 CUDA:0 (NVIDIA GeForce RTX 3060, 11910MiB)\n",
707
+ "Model summary (fused): 72 layers, 3,009,743 parameters, 0 gradients, 8.1 GFLOPs\n"
708
+ ]
709
+ },
710
+ {
711
+ "name": "stderr",
712
+ "output_type": "stream",
713
+ "text": [
714
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 16/16 [00:02<00:00, 7.23it/s]\n"
715
+ ]
716
+ },
717
+ {
718
+ "name": "stdout",
719
+ "output_type": "stream",
720
+ "text": [
721
+ " all 481 6875 0.786 0.678 0.707 0.64\n",
722
+ " BackgroundImage 56 56 0.872 0.73 0.875 0.842\n",
723
+ " Bottom_Navigation 2 2 1 0 0.0326 0.0271\n",
724
+ " Card 6 14 0.469 0.786 0.501 0.444\n",
725
+ " CheckedTextView 23 107 0.837 0.832 0.881 0.7\n",
726
+ " Drawer 30 30 0.938 0.967 0.993 0.987\n",
727
+ " EditText 112 246 0.927 0.879 0.945 0.849\n",
728
+ " Icon 297 1269 0.883 0.864 0.925 0.759\n",
729
+ " Image 370 868 0.781 0.841 0.894 0.833\n",
730
+ " Map 1 1 0 0 0 0\n",
731
+ " Modal 41 41 0.918 0.854 0.937 0.911\n",
732
+ " Multi_Tab 3 3 1 0 0.056 0.0474\n",
733
+ " PageIndicator 151 151 0.971 0.854 0.961 0.715\n",
734
+ " Spinner 1 1 0 0 0 0\n",
735
+ " Switch 10 28 0.957 0.929 0.984 0.915\n",
736
+ " Text 479 3164 0.932 0.946 0.97 0.839\n",
737
+ " TextButton 290 493 0.925 0.974 0.976 0.95\n",
738
+ " Toolbar 26 26 0.747 0.808 0.797 0.783\n",
739
+ " UpperTaskBar 375 375 0.996 0.949 0.992 0.927\n",
740
+ "Speed: 0.1ms preprocess, 1.0ms inference, 0.0ms loss, 2.3ms postprocess per image\n",
741
+ "Results saved to \u001b[1mruns/detect/train5\u001b[0m\n",
742
+ "Ultralytics 8.3.171 🚀 Python-3.12.3 torch-2.7.1+cu126 CUDA:0 (NVIDIA GeForce RTX 3060, 11910MiB)\n",
743
+ "Model summary (fused): 72 layers, 3,009,743 parameters, 0 gradients, 8.1 GFLOPs\n",
744
+ "\u001b[34m\u001b[1mval: \u001b[0mFast image access ✅ (ping: 0.0±0.0 ms, read: 4011.9±2287.7 MB/s, size: 279.8 KB)\n"
745
+ ]
746
+ },
747
+ {
748
+ "name": "stderr",
749
+ "output_type": "stream",
750
+ "text": [
751
+ "\u001b[34m\u001b[1mval: \u001b[0mScanning /home/xd/Documents/ML_AI/ui_detection_yolo/dataset/val/labels.cache... 481 images, 0 backgrounds, 0 corrupt: 100%|██████████| 481/481 [00:00<?, ?it/s]\n",
752
+ " Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 31/31 [00:02<00:00, 11.50it/s]\n"
753
+ ]
754
+ },
755
+ {
756
+ "name": "stdout",
757
+ "output_type": "stream",
758
+ "text": [
759
+ " all 481 6875 0.786 0.678 0.707 0.645\n",
760
+ " BackgroundImage 56 56 0.872 0.73 0.878 0.847\n",
761
+ " Bottom_Navigation 2 2 1 0 0.0326 0.028\n",
762
+ " Card 6 14 0.468 0.786 0.502 0.442\n",
763
+ " CheckedTextView 23 107 0.837 0.832 0.883 0.71\n",
764
+ " Drawer 30 30 0.934 0.967 0.992 0.989\n",
765
+ " EditText 112 246 0.927 0.88 0.942 0.847\n",
766
+ " Icon 297 1269 0.883 0.864 0.926 0.765\n",
767
+ " Image 370 868 0.778 0.842 0.895 0.836\n",
768
+ " Map 1 1 0 0 0 0\n",
769
+ " Modal 41 41 0.919 0.854 0.939 0.914\n",
770
+ " Multi_Tab 3 3 1 0 0.056 0.0474\n",
771
+ " PageIndicator 151 151 0.978 0.854 0.962 0.742\n",
772
+ " Spinner 1 1 0 0 0 0\n",
773
+ " Switch 10 28 0.956 0.929 0.984 0.932\n",
774
+ " Text 479 3164 0.931 0.944 0.969 0.847\n",
775
+ " TextButton 290 493 0.923 0.974 0.976 0.955\n",
776
+ " Toolbar 26 26 0.744 0.808 0.795 0.781\n",
777
+ " UpperTaskBar 375 375 0.996 0.949 0.992 0.927\n",
778
+ "Speed: 0.3ms preprocess, 1.9ms inference, 0.0ms loss, 1.5ms postprocess per image\n",
779
+ "Results saved to \u001b[1mruns/detect/train52\u001b[0m\n"
780
+ ]
781
+ }
782
+ ],
783
+ "source": [
784
+ "from ultralytics import YOLO\n",
785
+ "\n",
786
+ "# Load the YOLOv8 Nano model\n",
787
+ "model = YOLO(\"yolov8n.pt\")\n",
788
+ "\n",
789
+ "# Train the model\n",
790
+ "train_results = model.train(\n",
791
+ " data=\"/home/xd/Documents/ML_AI/ui_detection_yolo/data.yml\", # Dataset configuration\n",
792
+ " epochs=20, # Number of training cycles\n",
793
+ " imgsz=640, # Input image size\n",
794
+ " device=\"cuda\",\n",
795
+ " batch=16 # Adjust based on RAM\n",
796
+ ")\n",
797
+ "\n",
798
+ "# Evaluate performance\n",
799
+ "metrics = model.val()\n",
800
+ "\n"
801
+ ]
802
+ },
803
+ {
804
+ "cell_type": "code",
805
+ "execution_count": 19,
806
+ "id": "f35b12d9",
807
+ "metadata": {},
808
+ "outputs": [
809
+ {
810
+ "name": "stdout",
811
+ "output_type": "stream",
812
+ "text": [
813
+ "\n",
814
+ "image 1/1 /home/xd/Documents/ML_AI/ui_detection_yolo/test3.png: 640x384 11 CheckedTextViews, 2 EditTexts, 3 Icons, 5 Images, 13 Texts, 1 Toolbar, 1 UpperTaskBar, 33.1ms\n",
815
+ "Speed: 16.0ms preprocess, 33.1ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 384)\n"
816
+ ]
817
+ },
818
+ {
819
+ "name": "stdout",
820
+ "output_type": "stream",
821
+ "text": [
822
+ "Opening in existing browser session.\n"
823
+ ]
824
+ }
825
+ ],
826
+ "source": [
827
+ "\n",
828
+ "\n",
829
+ "# Detect elements in a test image\n",
830
+ "results = model(\"test3.png\")\n",
831
+ "results[0].show() # Display annotated predictions"
832
+ ]
833
+ }
834
+ ],
835
+ "metadata": {
836
+ "kernelspec": {
837
+ "display_name": ".venv",
838
+ "language": "python",
839
+ "name": "python3"
840
+ },
841
+ "language_info": {
842
+ "codemirror_mode": {
843
+ "name": "ipython",
844
+ "version": 3
845
+ },
846
+ "file_extension": ".py",
847
+ "mimetype": "text/x-python",
848
+ "name": "python",
849
+ "nbconvert_exporter": "python",
850
+ "pygments_lexer": "ipython3",
851
+ "version": "3.12.3"
852
+ }
853
+ },
854
+ "nbformat": 4,
855
+ "nbformat_minor": 5
856
+ }