File size: 72,662 Bytes
d9b9366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "-tGvKM82qJsO"
   },
   "source": [
    "# Object Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GPU available: NVIDIA H100 PCIe\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "if torch.cuda.is_available():\n",
    "    print(f\"GPU available: {torch.cuda.get_device_name(0)}\")\n",
    "else:\n",
    "    print(\"GPU not available.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "I1WFGtgTqItg",
    "outputId": "ef51af7f-2a14-4a21-e6ef-cef04da2d4c7"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extraction completed.\n"
     ]
    }
   ],
   "source": [
    "from zipfile import ZipFile\n",
    "\n",
    "# Path to your ZIP file\n",
    "zip_file_path = '/user/bhanucha/final_data.zip'\n",
    "# Destination directory where you want to extract the files\n",
    "extraction_directory = '/user/bhanucha/input'\n",
    "\n",
    "# Extract the ZIP file\n",
    "with ZipFile(zip_file_path, 'r') as zip_ref:\n",
    "    zip_ref.extractall(extraction_directory)\n",
    "\n",
    "print(\"Extraction completed.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "id": "65r28yu_uZUc"
   },
   "outputs": [],
   "source": [
    "import xml.etree.ElementTree as ET\n",
    "import os\n",
    "from PIL import Image\n",
    "\n",
    "# Load class names and create a mapping to IDs\n",
    "def load_class_names(class_file_path):\n",
    "    with open(class_file_path, 'r') as file:\n",
    "        class_names = file.read().strip().split('\\n')\n",
    "    return {name: i for i, name in enumerate(class_names)}\n",
    "\n",
    "def convert_voc_to_yolo(voc_xml_file, class_mapping, img_width, img_height):\n",
    "    tree = ET.parse(voc_xml_file)\n",
    "    root = tree.getroot()\n",
    "    yolo_format = []\n",
    "\n",
    "    for member in root.findall('object'):\n",
    "        classname = member.find('name').text\n",
    "        class_id = class_mapping[classname]\n",
    "\n",
    "        bndbox = member.find('bndbox')\n",
    "        xmin = int(bndbox.find('xmin').text)\n",
    "        ymin = int(bndbox.find('ymin').text)\n",
    "        xmax = int(bndbox.find('xmax').text)\n",
    "        ymax = int(bndbox.find('ymax').text)\n",
    "\n",
    "        x_center = ((xmin + xmax) / 2) / img_width\n",
    "        y_center = ((ymin + ymax) / 2) / img_height\n",
    "        width = (xmax - xmin) / img_width\n",
    "        height = (ymax - ymin) / img_height\n",
    "\n",
    "        yolo_format.append(f\"{class_id} {x_center} {y_center} {width} {height}\")\n",
    "\n",
    "    return yolo_format\n",
    "\n",
    "def process_dataset(dataset_directory, class_file_path):\n",
    "    class_mapping = load_class_names(class_file_path)\n",
    "\n",
    "    for class_dir in os.listdir(dataset_directory):\n",
    "        class_path = os.path.join(dataset_directory, class_dir)\n",
    "        if os.path.isdir(class_path):\n",
    "            for file in os.listdir(class_path):\n",
    "                if file.endswith('.xml'):\n",
    "                    img_file = os.path.splitext(file)[0] + '.jpg'\n",
    "                    img_path = os.path.join(class_path, img_file)\n",
    "                    xml_path = os.path.join(class_path, file)\n",
    "\n",
    "                    # Use PIL to get image dimensions\n",
    "                    with Image.open(img_path) as img:\n",
    "                        img_width, img_height = img.size\n",
    "\n",
    "                    yolo_annotations = convert_voc_to_yolo(xml_path, class_mapping, img_width, img_height)\n",
    "                    yolo_annotation_text = \"\\n\".join(yolo_annotations)\n",
    "\n",
    "                    # Save YOLO annotations to a .txt file\n",
    "                    txt_filename = os.path.splitext(xml_path)[0] + '.txt'\n",
    "                    with open(txt_filename, 'w') as f:\n",
    "                        f.write(yolo_annotation_text)\n",
    "\n",
    "# Assuming your class file path and dataset directory are as follows:\n",
    "class_file_path = '/user/bhanucha/Final_classes.txt'\n",
    "dataset_directory = '/user/bhanucha/input/initial_data_annotated'\n",
    "process_dataset(dataset_directory, class_file_path)\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Defaulting to user installation because normal site-packages is not writeable\n",
      "Collecting scikit-learn\n",
      "  Downloading scikit_learn-1.4.1.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 12.2 MB 3.7 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: scipy>=1.6.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/scipy-bundle/2021.10/lib/python3.9/site-packages (from scikit-learn) (1.7.1)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from scikit-learn) (2.2.0)\n",
      "Requirement already satisfied: numpy<2.0,>=1.19.5 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/scipy-bundle/2021.10/lib/python3.9/site-packages (from scikit-learn) (1.21.3)\n",
      "Collecting joblib>=1.2.0\n",
      "  Downloading joblib-1.3.2-py3-none-any.whl (302 kB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 302 kB 170.2 MB/s eta 0:00:01\n",
      "\u001b[?25hInstalling collected packages: joblib, scikit-learn\n",
      "Successfully installed joblib-1.3.2 scikit-learn-1.4.1.post1\n",
      "\u001b[33mWARNING: You are using pip version 21.2.2; however, version 24.0 is available.\n",
      "You should consider upgrading via the '/cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/bin/python -m pip install --upgrade pip' command.\u001b[0m\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install scikit-learn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "6wQoeoSzsUZ4",
    "outputId": "91698654-1b61-4e91-a7f4-4f706d28faad"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Training images: 3988\n",
      "Validation images: 499\n",
      "Test images: 499\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import random\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# Define your dataset directory and output files\n",
    "dataset_dir = '/user/bhanucha/input/initial_data_annotated'\n",
    "output_train = '/user/bhanucha/train.txt'\n",
    "output_val = '/user/bhanucha/valid.txt'\n",
    "output_test = '/user/bhanucha/test.txt'\n",
    "\n",
    "# Specify the split ratios\n",
    "train_ratio = 0.8\n",
    "val_ratio = 0.1\n",
    "test_ratio = 0.1  # Ensures train + val + test = 1.0\n",
    "\n",
    "# Collect all image file paths\n",
    "image_paths = []\n",
    "for root, dirs, files in os.walk(dataset_dir):\n",
    "    for file in files:\n",
    "        if file.endswith('.jpg'):\n",
    "            image_paths.append(os.path.join(root, file))\n",
    "\n",
    "# Split the data\n",
    "train_val_paths, test_paths = train_test_split(image_paths, test_size=test_ratio, random_state=42)\n",
    "train_paths, val_paths = train_test_split(train_val_paths, test_size=val_ratio/(train_ratio+val_ratio), random_state=42)\n",
    "\n",
    "# Function to write paths to a file\n",
    "def write_paths(file_paths, output_file):\n",
    "    with open(output_file, 'w') as f:\n",
    "        for path in file_paths:\n",
    "            f.write(path + '\\n')\n",
    "\n",
    "# Write the splits to their respective files\n",
    "write_paths(train_paths, output_train)\n",
    "write_paths(val_paths, output_val)\n",
    "write_paths(test_paths, output_test)\n",
    "\n",
    "print(f\"Training images: {len(train_paths)}\")\n",
    "print(f\"Validation images: {len(val_paths)}\")\n",
    "print(f\"Test images: {len(test_paths)}\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "sCJT9Xxx4cnH",
    "outputId": "77ae092a-83ca-442c-bc36-0d531a5be850"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'yolov7'...\n",
      "remote: Enumerating objects: 1197, done.\u001b[K\n",
      "remote: Total 1197 (delta 0), reused 0 (delta 0), pack-reused 1197\u001b[K\n",
      "Receiving objects: 100% (1197/1197), 74.23 MiB | 69.03 MiB/s, done.\n",
      "Resolving deltas: 100% (519/519), done.\n",
      "/user/bhanucha/yolov7\n"
     ]
    }
   ],
   "source": [
    "!git clone https://github.com/WongKinYiu/yolov7.git\n",
    "%cd yolov7\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "Pp_80KK95PFq",
    "outputId": "1d7b7a25-77ef-4233-dad0-b2285f32cb68"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Defaulting to user installation because normal site-packages is not writeable\n",
      "Collecting matplotlib>=3.2.2\n",
      "  Downloading matplotlib-3.8.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.6 MB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 11.6 MB 3.5 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: numpy<1.24.0,>=1.18.5 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/scipy-bundle/2021.10/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (1.21.3)\n",
      "Collecting opencv-python>=4.1.1\n",
      "  Downloading opencv_python-4.9.0.80-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (62.2 MB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 62.2 MB 169.7 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: Pillow>=7.1.2 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/pillow/9.2.0/lib/python3.9/site-packages (from -r requirements.txt (line 7)) (9.2.0)\n",
      "Requirement already satisfied: PyYAML>=5.3.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/pyyaml/5.4.1/lib/python3.9/site-packages (from -r requirements.txt (line 8)) (5.4.1)\n",
      "Requirement already satisfied: requests>=2.23.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from -r requirements.txt (line 9)) (2.26.0)\n",
      "Requirement already satisfied: scipy>=1.4.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/scipy-bundle/2021.10/lib/python3.9/site-packages (from -r requirements.txt (line 10)) (1.7.1)\n",
      "Requirement already satisfied: torch!=1.12.0,>=1.7.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/pytorch/1.13.1-CUDA-11.8.0/lib/python3.9/site-packages (from -r requirements.txt (line 11)) (1.13.1)\n",
      "Requirement already satisfied: torchvision!=0.13.0,>=0.8.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/torchvision/0.14.1-CUDA-11.8.0/lib/python3.9/site-packages (from -r requirements.txt (line 12)) (0.14.1)\n",
      "Collecting tqdm>=4.41.0\n",
      "  Downloading tqdm-4.66.2-py3-none-any.whl (78 kB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 78 kB 3.5 MB/s s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: protobuf<4.21.3 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/protobuf-python/3.17.3/lib/python3.9/site-packages (from -r requirements.txt (line 14)) (3.17.3)\n",
      "Requirement already satisfied: tensorboard>=2.4.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from -r requirements.txt (line 17)) (2.11.1)\n",
      "Requirement already satisfied: pandas>=1.1.4 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/scipy-bundle/2021.10/lib/python3.9/site-packages (from -r requirements.txt (line 21)) (1.3.4)\n",
      "Collecting seaborn>=0.11.0\n",
      "  Downloading seaborn-0.13.2-py3-none-any.whl (294 kB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 294 kB 165.8 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: ipython in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from -r requirements.txt (line 34)) (7.26.0)\n",
      "Requirement already satisfied: psutil in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from -r requirements.txt (line 35)) (5.8.0)\n",
      "Collecting thop\n",
      "  Downloading thop-0.1.1.post2209072238-py3-none-any.whl (15 kB)\n",
      "Collecting cycler>=0.10\n",
      "  Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB)\n",
      "Collecting fonttools>=4.22.0\n",
      "  Downloading fonttools-4.50.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 4.6 MB 158.1 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: pyparsing>=2.3.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (2.4.7)\n",
      "Collecting contourpy>=1.0.1\n",
      "  Downloading contourpy-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (304 kB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 304 kB 166.2 MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting kiwisolver>=1.3.1\n",
      "  Downloading kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.6 MB)\n",
      "\u001b[K     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 1.6 MB 26.1 MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: packaging>=20.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (20.9)\n",
      "Requirement already satisfied: importlib-resources>=3.2.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (5.2.2)\n",
      "Requirement already satisfied: python-dateutil>=2.7 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (2.8.2)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (3.2)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (1.26.6)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (2021.5.30)\n",
      "Requirement already satisfied: charset-normalizer~=2.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (2.0.4)\n",
      "Requirement already satisfied: typing_extensions in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/typing-extensions/4.3.0/lib/python3.9/site-packages (from torch!=1.12.0,>=1.7.0->-r requirements.txt (line 11)) (4.3.0)\n",
      "Requirement already satisfied: six>=1.9 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from protobuf<4.21.3->-r requirements.txt (line 14)) (1.16.0)\n",
      "Requirement already satisfied: wheel>=0.26 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (0.36.2)\n",
      "Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (0.6.1)\n",
      "Requirement already satisfied: werkzeug>=1.0.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (2.2.2)\n",
      "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (0.4.6)\n",
      "Requirement already satisfied: absl-py>=0.4 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (1.4.0)\n",
      "Requirement already satisfied: setuptools>=41.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (57.4.0)\n",
      "Requirement already satisfied: markdown>=2.6.8 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (3.4.1)\n",
      "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (1.8.1)\n",
      "Requirement already satisfied: google-auth<3,>=1.6.3 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (2.16.0)\n",
      "Requirement already satisfied: grpcio>=1.24.3 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 17)) (1.51.1)\n",
      "Requirement already satisfied: pytz>=2017.3 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from pandas>=1.1.4->-r requirements.txt (line 21)) (2021.1)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: backcall in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (0.2.0)\n",
      "Requirement already satisfied: decorator in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (5.0.9)\n",
      "Requirement already satisfied: matplotlib-inline in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (0.1.2)\n",
      "Requirement already satisfied: jedi>=0.16 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (0.18.0)\n",
      "Requirement already satisfied: pygments in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (2.9.0)\n",
      "Requirement already satisfied: pexpect>4.3 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (4.8.0)\n",
      "Requirement already satisfied: pickleshare in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (0.7.5)\n",
      "Requirement already satisfied: traitlets>=4.2 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (5.0.5)\n",
      "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from ipython->-r requirements.txt (line 34)) (3.0.19)\n",
      "Requirement already satisfied: pyasn1-modules>=0.2.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 17)) (0.2.8)\n",
      "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 17)) (5.2.1)\n",
      "Requirement already satisfied: rsa<5,>=3.1.4 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 17)) (4.9)\n",
      "Requirement already satisfied: requests-oauthlib>=0.7.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.4.1->-r requirements.txt (line 17)) (1.3.1)\n",
      "Requirement already satisfied: zipp>=3.1.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib>=3.2.2->-r requirements.txt (line 4)) (3.5.0)\n",
      "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from jedi>=0.16->ipython->-r requirements.txt (line 34)) (0.8.2)\n",
      "Requirement already satisfied: importlib-metadata>=4.4 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from markdown>=2.6.8->tensorboard>=2.4.1->-r requirements.txt (line 17)) (4.6.3)\n",
      "Requirement already satisfied: ptyprocess>=0.5 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from pexpect>4.3->ipython->-r requirements.txt (line 34)) (0.7.0)\n",
      "Requirement already satisfied: wcwidth in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython->-r requirements.txt (line 34)) (0.2.5)\n",
      "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/lib/python3.9/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 17)) (0.4.8)\n",
      "Requirement already satisfied: oauthlib>=3.0.0 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.4.1->-r requirements.txt (line 17)) (3.2.2)\n",
      "Requirement already satisfied: ipython-genutils in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/ipython/7.26.0/lib/python3.9/site-packages (from traitlets>=4.2->ipython->-r requirements.txt (line 34)) (0.2.0)\n",
      "Requirement already satisfied: MarkupSafe>=2.1.1 in /cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/tensorflow/2.11.0-CUDA-11.8.0/lib/python3.9/site-packages (from werkzeug>=1.0.1->tensorboard>=2.4.1->-r requirements.txt (line 17)) (2.1.1)\n",
      "Installing collected packages: kiwisolver, fonttools, cycler, contourpy, matplotlib, tqdm, thop, seaborn, opencv-python\n",
      "Successfully installed contourpy-1.2.1 cycler-0.12.1 fonttools-4.50.0 kiwisolver-1.4.5 matplotlib-3.8.4 opencv-python-4.9.0.80 seaborn-0.13.2 thop-0.1.1.post2209072238 tqdm-4.66.2\n",
      "\u001b[33mWARNING: You are using pip version 21.2.2; however, version 24.0 is available.\n",
      "You should consider upgrading via the '/cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/Compiler/gcccore/11.2.0/python/3.9.6/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install -r requirements.txt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "id": "ZvAB0t1a53xr"
   },
   "outputs": [],
   "source": [
    "yaml_content = \"\"\"\n",
    "train: /user/bhanucha/train.txt\n",
    "val: /user/bhanucha/valid.txt\n",
    "test: /user/bhanucha/test.txt\n",
    "\n",
    "nc: 100\n",
    "names: [\n",
    "  'all_purpose_flour', 'almonds', 'apple', 'apricot', 'asparagus', 'avocado', 'bacon', 'banana', 'barley', 'basil',\n",
    "  'basmati_rice', 'beans', 'beef', 'beets', 'bell_pepper', 'berries', 'biscuits', 'blackberries', 'black_pepper',\n",
    "  'blueberries', 'bread', 'bread_crumbs', 'bread_flour', 'broccoli', 'brownie_mix', 'brown_rice', 'butter', 'cabbage',\n",
    "  'cake', 'cardamom', 'carrot', 'cashews', 'cauliflower', 'celery', 'cereal', 'cheese', 'cherries', 'chicken',\n",
    "  'chickpeas', 'chocolate', 'chocolate_chips', 'chocolate_syrup', 'cilantro', 'cinnamon', 'clove', 'cocoa_powder',\n",
    "  'coconut', 'cookies', 'corn', 'cucumber', 'dates', 'eggplant', 'eggs', 'fish', 'garlic', 'ginger', 'grapes', 'honey',\n",
    "  'jalapeno', 'kidney_beans', 'lemon', 'mango', 'marshmallows', 'milk', 'mint', 'muffins', 'mushroom', 'noodles',\n",
    "  'nuts', 'oats', 'okra', 'olive', 'onion', 'orange', 'oreo_cookies', 'pasta', 'pear', 'pepper', 'pineapple',\n",
    "  'pistachios', 'pork', 'potato', 'pumpkin', 'radishes', 'raisins', 'red_chilies', 'rice', 'rosemary', 'salmon', 'salt',\n",
    "  'shrimp', 'spinach', 'strawberries', 'sugar', 'sweet_potato', 'tomato', 'vanilla_ice_cream', 'walnuts', 'watermelon',\n",
    "  'yogurt'\n",
    "]\n",
    "\"\"\"\n",
    "\n",
    "with open('/user/bhanucha/ingredients.yaml', 'w') as file:\n",
    "    file.write(yaml_content.strip())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "uzzsNi5Y6fdU",
    "outputId": "d2702961-cc1a-42dc-ee26-e3bfdc361240"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/user/bhanucha/yolov7\n"
     ]
    }
   ],
   "source": [
    "%cd /user/bhanucha/yolov7\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "sQbHP-J86FhY",
    "outputId": "3832631b-f51e-4b7c-9ac1-0b70e7606d0a"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "YOLOR ๐Ÿš€ v0.1-128-ga207844 torch 1.13.1 CUDA:0 (NVIDIA H100 PCIe, 81230.375MB)\n",
      "\n",
      "Namespace(weights='yolov7.pt', cfg='cfg/training/yolov7.yaml', data='/user/bhanucha/ingredients.yaml', hyp='data/hyp.scratch.p5.yaml', epochs=50, batch_size=64, img_size=[640, 640], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='0', multi_scale=False, single_cls=False, adam=False, sync_bn=False, local_rank=-1, workers=4, project='runs/train', entity=None, name='exp', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs/train/exp2', total_batch_size=64)\n",
      "\u001b[34m\u001b[1mtensorboard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n",
      "2024-04-04 11:10:34.277310: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX512_VNNI AVX512_BF16 AVX_VNNI AMX_TILE AMX_INT8 AMX_BF16\n",
      "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
      "2024-04-04 11:10:40.042222: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
      "\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.2, scale=0.9, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.15, copy_paste=0.0, paste_in=0.15, loss_ota=1\n",
      "\u001b[34m\u001b[1mwandb: \u001b[0mInstall Weights & Biases for YOLOR logging with 'pip install wandb' (recommended)\n",
      "Overriding model.yaml nc=80 with nc=100\n",
      "\n",
      "                 from  n    params  module                                  arguments                     \n",
      "  0                -1  1       928  models.common.Conv                      [3, 32, 3, 1]                 \n",
      "  1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]                \n",
      "  2                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      "  3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               \n",
      "  4                -1  1      8320  models.common.Conv                      [128, 64, 1, 1]               \n",
      "  5                -2  1      8320  models.common.Conv                      [128, 64, 1, 1]               \n",
      "  6                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      "  7                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      "  8                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      "  9                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      " 10  [-1, -3, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 11                -1  1     66048  models.common.Conv                      [256, 256, 1, 1]              \n",
      " 12                -1  1         0  models.common.MP                        []                            \n",
      " 13                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 14                -3  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 15                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              \n",
      " 16          [-1, -3]  1         0  models.common.Concat                    [1]                           \n",
      " 17                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 18                -2  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 19                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 20                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 21                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 22                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 23  [-1, -3, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 24                -1  1    263168  models.common.Conv                      [512, 512, 1, 1]              \n",
      " 25                -1  1         0  models.common.MP                        []                            \n",
      " 26                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 27                -3  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 28                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]              \n",
      " 29          [-1, -3]  1         0  models.common.Concat                    [1]                           \n",
      " 30                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 31                -2  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 32                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 33                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 34                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 35                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 36  [-1, -3, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 37                -1  1   1050624  models.common.Conv                      [1024, 1024, 1, 1]            \n",
      " 38                -1  1         0  models.common.MP                        []                            \n",
      " 39                -1  1    525312  models.common.Conv                      [1024, 512, 1, 1]             \n",
      " 40                -3  1    525312  models.common.Conv                      [1024, 512, 1, 1]             \n",
      " 41                -1  1   2360320  models.common.Conv                      [512, 512, 3, 2]              \n",
      " 42          [-1, -3]  1         0  models.common.Concat                    [1]                           \n",
      " 43                -1  1    262656  models.common.Conv                      [1024, 256, 1, 1]             \n",
      " 44                -2  1    262656  models.common.Conv                      [1024, 256, 1, 1]             \n",
      " 45                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 46                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 47                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 48                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 49  [-1, -3, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 50                -1  1   1050624  models.common.Conv                      [1024, 1024, 1, 1]            \n",
      " 51                -1  1   7609344  models.common.SPPCSPC                   [1024, 512, 1]                \n",
      " 52                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 53                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \n",
      " 54                37  1    262656  models.common.Conv                      [1024, 256, 1, 1]             \n",
      " 55          [-1, -2]  1         0  models.common.Concat                    [1]                           \n",
      " 56                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 57                -2  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 58                -1  1    295168  models.common.Conv                      [256, 128, 3, 1]              \n",
      " 59                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 60                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 61                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 62[-1, -2, -3, -4, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 63                -1  1    262656  models.common.Conv                      [1024, 256, 1, 1]             \n",
      " 64                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 65                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \n",
      " 66                24  1     65792  models.common.Conv                      [512, 128, 1, 1]              \n",
      " 67          [-1, -2]  1         0  models.common.Concat                    [1]                           \n",
      " 68                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 69                -2  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 70                -1  1     73856  models.common.Conv                      [128, 64, 3, 1]               \n",
      " 71                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      " 72                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      " 73                -1  1     36992  models.common.Conv                      [64, 64, 3, 1]                \n",
      " 74[-1, -2, -3, -4, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 75                -1  1     65792  models.common.Conv                      [512, 128, 1, 1]              \n",
      " 76                -1  1         0  models.common.MP                        []                            \n",
      " 77                -1  1     16640  models.common.Conv                      [128, 128, 1, 1]              \n",
      " 78                -3  1     16640  models.common.Conv                      [128, 128, 1, 1]              \n",
      " 79                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              \n",
      " 80      [-1, -3, 63]  1         0  models.common.Concat                    [1]                           \n",
      " 81                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 82                -2  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 83                -1  1    295168  models.common.Conv                      [256, 128, 3, 1]              \n",
      " 84                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 85                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 86                -1  1    147712  models.common.Conv                      [128, 128, 3, 1]              \n",
      " 87[-1, -2, -3, -4, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      " 88                -1  1    262656  models.common.Conv                      [1024, 256, 1, 1]             \n",
      " 89                -1  1         0  models.common.MP                        []                            \n",
      " 90                -1  1     66048  models.common.Conv                      [256, 256, 1, 1]              \n",
      " 91                -3  1     66048  models.common.Conv                      [256, 256, 1, 1]              \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 92                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]              \n",
      " 93      [-1, -3, 51]  1         0  models.common.Concat                    [1]                           \n",
      " 94                -1  1    525312  models.common.Conv                      [1024, 512, 1, 1]             \n",
      " 95                -2  1    525312  models.common.Conv                      [1024, 512, 1, 1]             \n",
      " 96                -1  1   1180160  models.common.Conv                      [512, 256, 3, 1]              \n",
      " 97                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 98                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      " 99                -1  1    590336  models.common.Conv                      [256, 256, 3, 1]              \n",
      "100[-1, -2, -3, -4, -5, -6]  1         0  models.common.Concat                    [1]                           \n",
      "101                -1  1   1049600  models.common.Conv                      [2048, 512, 1, 1]             \n",
      "102                75  1    328704  models.common.RepConv                   [128, 256, 3, 1]              \n",
      "103                88  1   1312768  models.common.RepConv                   [256, 512, 3, 1]              \n",
      "104               101  1   5246976  models.common.RepConv                   [512, 1024, 3, 1]             \n",
      "105   [102, 103, 104]  1    568162  models.yolo.IDetect                     [100, [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]], [256, 512, 1024]]\n",
      "/cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/pytorch/1.13.1-CUDA-11.8.0/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /var/tmp/aebruno2/easybuild/build/PyTorch/1.13.1/foss-2021b-CUDA-11.8.0/pytorch-v1.13.1/aten/src/ATen/native/TensorShape.cpp:3190.)\n",
      "  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]\n",
      "Model Summary: 415 layers, 37730562 parameters, 37730562 gradients, 106.8 GFLOPS\n",
      "\n",
      "Transferred 552/566 items from yolov7.pt\n",
      "Scaled weight_decay = 0.0005\n",
      "Optimizer groups: 95 .bias, 95 conv.weight, 98 other\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mScanning '/user/bhanucha/train.cache' images and labels... 3988 found, 0 \u001b[0m\n",
      "\u001b[34m\u001b[1mval: \u001b[0mScanning '/user/bhanucha/valid.cache' images and labels... 499 found, 0 mis\u001b[0m\n",
      "\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mAnalyzing anchors... anchors/target = 3.83, Best Possible Recall (BPR) = 1.0000\n",
      "Image sizes 640 train, 640 test\n",
      "Using 4 dataloader workers\n",
      "Logging results to runs/train/exp2\n",
      "Starting training for 50 epochs...\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      0/49     43.7G   0.05927   0.01208    0.0645    0.1359        42       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367     0.00089      0.0115     0.00104    0.000718\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      1/49     43.7G   0.03925   0.01081   0.06218    0.1122        48       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367     0.00495        0.28      0.0139      0.0107\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      2/49     43.7G   0.03601   0.01014   0.06201    0.1082        47       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367      0.0126       0.156      0.0165      0.0133\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      3/49     43.7G   0.03411  0.009824   0.06196    0.1059        50       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367     0.00946       0.147      0.0199      0.0155\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      4/49     43.7G   0.03276  0.009452   0.06175     0.104        45       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367      0.0803      0.0671      0.0234      0.0164\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      5/49     43.7G   0.03274  0.009439   0.06162    0.1038        60       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367        0.26      0.0682       0.022      0.0164\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      6/49     43.7G   0.03168   0.00919   0.06142    0.1023        55       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.048       0.166      0.0258      0.0189\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      7/49     43.7G   0.02938    0.0095   0.06109   0.09998        43       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.124       0.126      0.0272      0.0224\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      8/49     43.7G   0.02771  0.009402   0.06073   0.09784        50       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367      0.0845       0.152      0.0393      0.0318\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "      9/49     43.7G   0.02783  0.009483   0.05996   0.09727        40       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.632      0.0821      0.0637      0.0536\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     10/49     43.7G   0.02585  0.009862   0.05914   0.09485        39       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.248       0.189      0.0822      0.0652\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     11/49     43.7G   0.02348   0.01029   0.05817   0.09195        64       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.711      0.0972      0.0957      0.0743\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     12/49     43.7G   0.02314  0.009896    0.0566   0.08963        54       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.523       0.145       0.115      0.0907\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     13/49     43.7G   0.02371  0.009747    0.0548   0.08825        37       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.586       0.168       0.164       0.137\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     14/49     43.7G   0.02441  0.009791   0.05267   0.08687        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.448       0.224       0.165       0.128\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     15/49     43.7G   0.02581  0.009632   0.05134   0.08679        37       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.766       0.152       0.176       0.137\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     16/49     43.7G   0.02668  0.009865    0.0499   0.08644        55       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367         0.6       0.183       0.175       0.143\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     17/49     43.7G   0.02685   0.00988   0.04829   0.08502        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.196       0.266       0.138       0.107\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     18/49     43.7G   0.02572   0.00947   0.04623   0.08143        57       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.348       0.299       0.226       0.181\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     19/49     43.7G   0.02658  0.009464   0.04458   0.08062        50       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.262       0.315        0.21       0.172\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     20/49     43.7G   0.02621  0.009319   0.04289   0.07842        46       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.326       0.375        0.26       0.215\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     21/49     43.7G   0.02617  0.009057   0.04091   0.07614        35       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.522        0.25       0.238       0.187\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     22/49     43.7G   0.02586  0.009198   0.04025    0.0753        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.287       0.394       0.303       0.245\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     23/49     43.7G   0.02574  0.009049   0.03859   0.07337        38       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.432       0.281       0.279       0.235\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     24/49     43.7G   0.02544  0.009021   0.03843   0.07289        50       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367        0.32       0.353       0.303       0.244\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     25/49     43.7G   0.02466  0.008962   0.03588    0.0695        59       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.476       0.344        0.35       0.292\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     26/49     43.7G   0.02458  0.008519   0.03484   0.06794        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.287       0.384       0.333       0.284\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     27/49     43.7G   0.02477  0.008755   0.03423   0.06776        52       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.373       0.397       0.366       0.314\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     28/49     43.7G   0.02328  0.008634   0.03253   0.06445        32       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.391        0.38       0.391       0.328\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     29/49     43.7G   0.02363  0.008404    0.0319   0.06393        50       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.337       0.405       0.385       0.331\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     30/49     43.7G    0.0229  0.008227   0.03064   0.06177        35       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.475       0.397       0.434       0.376\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     31/49     43.7G   0.02261  0.008141   0.03003   0.06079        53       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.453       0.447       0.423       0.372\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     32/49     43.7G   0.02301  0.008456     0.029   0.06047        48       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.349       0.495       0.413       0.365\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     33/49     43.7G   0.02191  0.008162   0.02761   0.05768        60       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.385       0.491       0.444       0.387\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     34/49     43.7G   0.02187   0.00808   0.02683   0.05678        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.435       0.479       0.465       0.419\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     35/49     43.7G   0.02128  0.007955   0.02552   0.05475        44       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367        0.38       0.506       0.459       0.405\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     36/49     43.7G    0.0211  0.007721   0.02477   0.05359        49       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.361         0.5       0.477        0.43\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     37/49     43.7G   0.02061   0.00783   0.02403   0.05247        61       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.473        0.44       0.477       0.432\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     38/49     43.7G   0.01983  0.007664   0.02365   0.05115        57       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.542       0.457       0.501       0.453\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     39/49     43.7G   0.02014   0.00756   0.02243   0.05013        42       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.443       0.482       0.482       0.439\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     40/49     43.7G   0.01994  0.007407   0.02229   0.04964        50       640\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.478       0.497       0.513       0.464\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     41/49     43.7G   0.01893  0.007398   0.02043   0.04676        40       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.469       0.543       0.521       0.476\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     42/49     43.7G   0.01868  0.007207   0.01998   0.04588        39       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.626        0.46       0.541       0.493\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     43/49     43.7G   0.01885  0.007177   0.01992   0.04595        48       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.462       0.544       0.542       0.494\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     44/49     43.7G    0.0187  0.007042   0.01925   0.04499        55       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.463       0.518       0.513       0.468\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     45/49     43.7G   0.01834  0.007062   0.01923   0.04463        33       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.446       0.509       0.537       0.486\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     46/49     43.7G   0.01818  0.007035   0.01782   0.04304        66       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367        0.42       0.578       0.536       0.487\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     47/49     43.7G   0.01791  0.006884   0.01763   0.04243        48       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.518       0.535       0.553       0.506\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     48/49     43.7G   0.01732  0.006811   0.01735   0.04148        33       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.491       0.524       0.523       0.482\n",
      "\n",
      "     Epoch   gpu_mem       box       obj       cls     total    labels  img_size\n",
      "     49/49     43.7G   0.01747  0.006579   0.01609   0.04014        41       640\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         367       0.526        0.49       0.547       0.503\n",
      "50 epochs completed in 1.685 hours.\n",
      "\n",
      "Optimizer stripped from runs/train/exp2/weights/last.pt, 75.8MB\n",
      "Optimizer stripped from runs/train/exp2/weights/best.pt, 75.8MB\n"
     ]
    }
   ],
   "source": [
    "!python train.py --batch-size 64 --img 640 640 --data /user/bhanucha/ingredients.yaml --cfg cfg/training/yolov7.yaml --weights 'yolov7.pt' --device 0 --epochs 50 --workers 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "_SMQOX8w9rpd",
    "outputId": "4cdd6774-189a-417d-8c12-15b6d00b2b0e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Namespace(weights=['/user/bhanucha/yolov7/runs/train/exp2/weights/best.pt'], data='/user/bhanucha/ingredients.yaml', batch_size=64, img_size=640, conf_thres=0.001, iou_thres=0.5, task='test', device='', single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project='runs/test', name='exp', exist_ok=False, no_trace=False, v5_metric=False)\n",
      "YOLOR ๐Ÿš€ v0.1-128-ga207844 torch 1.13.1 CUDA:0 (NVIDIA H100 PCIe, 81230.375MB)\n",
      "\n",
      "Fusing layers... \n",
      "RepConv.fuse_repvgg_block\n",
      "RepConv.fuse_repvgg_block\n",
      "RepConv.fuse_repvgg_block\n",
      "IDetect.fuse\n",
      "/cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/pytorch/1.13.1-CUDA-11.8.0/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /var/tmp/aebruno2/easybuild/build/PyTorch/1.13.1/foss-2021b-CUDA-11.8.0/pytorch-v1.13.1/aten/src/ATen/native/TensorShape.cpp:3190.)\n",
      "  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]\n",
      "Model Summary: 314 layers, 37015778 parameters, 6194944 gradients, 104.9 GFLOPS\n",
      " Convert model to Traced-model... \n",
      " traced_script_module saved! \n",
      " model is traced! \n",
      "\n",
      "\u001b[34m\u001b[1mtest: \u001b[0mScanning '/user/bhanucha/test.cache' images and labels... 499 found, 0 mis\u001b[0m\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         346       0.501       0.546       0.532       0.483\n",
      "Speed: 1.6/0.4/1.9 ms inference/NMS/total per 640x640 image at batch-size 64\n",
      "Results saved to runs/test/exp4\n"
     ]
    }
   ],
   "source": [
    "!python test.py --weights /user/bhanucha/yolov7/runs/train/exp2/weights/best.pt --data /user/bhanucha/ingredients.yaml --img 640 --iou-thres 0.5 --batch-size 64 --task test\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Namespace(weights=['/user/bhanucha/yolov7/runs/train/exp2/weights/best.pt'], data='/user/bhanucha/ingredients.yaml', batch_size=32, img_size=640, conf_thres=0.001, iou_thres=0.25, task='test', device='', single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project='runs/test', name='exp', exist_ok=False, no_trace=False, v5_metric=False)\n",
      "YOLOR ๐Ÿš€ v0.1-128-ga207844 torch 1.13.1 CUDA:0 (NVIDIA H100 PCIe, 81230.375MB)\n",
      "\n",
      "Fusing layers... \n",
      "RepConv.fuse_repvgg_block\n",
      "RepConv.fuse_repvgg_block\n",
      "RepConv.fuse_repvgg_block\n",
      "IDetect.fuse\n",
      "/cvmfs/soft.ccr.buffalo.edu/versions/2023.01/easybuild/software/avx512/MPI/gcc/11.2.0/openmpi/4.1.1/pytorch/1.13.1-CUDA-11.8.0/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /var/tmp/aebruno2/easybuild/build/PyTorch/1.13.1/foss-2021b-CUDA-11.8.0/pytorch-v1.13.1/aten/src/ATen/native/TensorShape.cpp:3190.)\n",
      "  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]\n",
      "Model Summary: 314 layers, 37015778 parameters, 6194944 gradients, 104.9 GFLOPS\n",
      " Convert model to Traced-model... \n",
      " traced_script_module saved! \n",
      " model is traced! \n",
      "\n",
      "\u001b[34m\u001b[1mtest: \u001b[0mScanning '/user/bhanucha/test.cache' images and labels... 499 found, 0 mis\u001b[0m\n",
      "               Class      Images      Labels           P           R      mAP@.5\n",
      "                 all         499         346        0.54       0.515        0.53       0.481\n",
      "Speed: 2.5/0.4/2.9 ms inference/NMS/total per 640x640 image at batch-size 32\n",
      "Results saved to runs/test/exp3\n"
     ]
    }
   ],
   "source": [
    "!python test.py --weights /user/bhanucha/yolov7/runs/train/exp2/weights/best.pt --data /user/bhanucha/ingredients.yaml --img 640 --iou-thres 0.25 --task test\n"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "gpuType": "T4",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}