<jupyter_start><jupyter_text>**Training YOLO Model for tracking plane**  Check the gpuP100 > T4 > P4 > K80<jupyter_code>from IPython.display import HTML, clear_output
from subprocess import getoutput
s = getoutput('nvidia-smi')
if 'K80' in s:gpu = 'K80'
elif 'T4' in s:gpu = 'T4'
elif 'P100' in s:gpu = 'P100'
elif 'P4' in s:gpu = 'P4'
display(HTML(f"<h1>{gpu}</h1>"))
from google.colab import drive
drive.mount('/content/gdrive')
!ln -s /content/gdrive/My\ Drive/ /mydrive
%cd /mydrive/yolov3<jupyter_output>/content/gdrive/My Drive/yolov3<jupyter_text>**Cloning the repisotory for YOLO ModelConfiguration**<jupyter_code>!git clone https://github.com/AlexeyAB/darknet<jupyter_output>Cloning into 'darknet'...
remote: Enumerating objects: 15298, done.[K
remote: Total 15298 (delta 0), reused 0 (delta 0), pack-reused 15298[K
Receiving objects: 100% (15298/15298), 13.68 MiB | 7.03 MiB/s, done.
Resolving deltas: 100% (10389/10389), done.
Checking out files: 100% (2044/2044), done.<jupyter_text>**Clone,Configure&Compile Darknet**<jupyter_code>%cd darknet
!sed -i 's/OPENCV=0/OPENCV=1/' Makefile
!sed -i 's/GPU=0/GPU=1/' Makefile
!sed -i 's/CUDNN=0/CUDNN=1/' Makefile
!make<jupyter_output>/content/gdrive/My Drive/yolov3/darknet
chmod +x *.sh
g++ -std=c++11 -std=c++11 -Iinclude/ -I3rdparty/stb/include -DOPENCV `pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv` -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -I/usr/local/cudnn/include -c ./src/image_opencv.cpp -o obj/image_opencv.o
[01m[K./src/image_opencv.cpp:[m[K In function ‘[01m[Kvoid draw_detections_cv_v3(void**, detection*, int, float, char**, image**, int, int)[m[K’:
[01m[K./src/image_opencv.cpp:946:23:[m[K [01;35m[Kwarning: [m[Kvariable ‘[01m[Krgb[m[K’ set but not used [[01;35m[K-Wunused-but-set-variable[m[K]
                 float [01;35m[Krgb[m[K[3];
                       [01;35m[K^~~[m[K
[01m[K./src/image_opencv.cpp:[m[K In function ‘[01m[Kvoid draw_train_loss(char*, void**, int, float, float, int, int, float, int, char*, float, int, int, double)[m[K’:
[01m[K[...]<jupyter_text>**YOLOv3-tiny configuration**<jupyter_code>#!cp cfg/yolov3-tiny.cfg cfg/yolov3-tiny_training.cfg
'''!sed -i 's/batch=64/batch=64/' cfg/yolov3-tiny_training.cfg
!sed -i 's/subdivisions=16/subdivisions=16/' cfg/yolov3-tiny_training.cfg
!sed -i 's/max_batches = 500200/max_batches = 2000/' cfg/yolov3-tiny_training.cfg
!sed -i '135 s@classes=80@classes=1@' cfg/yolov3-tiny_training.cfg
!sed -i '177 s@classes=80@classes=1@' cfg/yolov3-tiny_training.cfg
!sed -i '127 s@filters=255@filters=18@' cfg/yolov3-tiny_training.cfg
!sed -i '171 s@filters=255@filters=18@' cfg/yolov3-tiny_training.cfg
!make'''<jupyter_output><empty_output><jupyter_text>**YOLOv3 configuration**<jupyter_code>!cp cfg/yolov3.cfg cfg/yolov3_training.cfg

!sed -i 's/batch=64/batch=64/' cfg/yolov3_training.cfg
!sed -i 's/subdivisions=16/subdivisions=16/' cfg/yolov3_training.cfg
!sed -i 's/max_batches = 500200/max_batches = 2000/' cfg/yolov3_training.cfg
!sed -i '610 s@classes=80@classes=1@' cfg/yolov3_training.cfg
!sed -i '696 s@classes=80@classes=1@' cfg/yolov3_training.cfg
!sed -i '783 s@classes=80@classes=1@' cfg/yolov3_training.cfg
!sed -i '603 s@filters=255@filters=18@' cfg/yolov3_training.cfg
!sed -i '689 s@filters=255@filters=18@' cfg/yolov3_training.cfg
!sed -i '776 s@filters=255@filters=18@' cfg/yolov3_training.cfg<jupyter_output>chmod +x *.sh<jupyter_text>**Creating obj.names file (classes.txt)**<jupyter_code>!echo -e 'Plane' > data/obj.names<jupyter_output><empty_output><jupyter_text>**Creating obj.data files**<jupyter_code>!echo -e 'classes=1\ntrain = data/train.txt\nvalid = data/test.txt\nnames = data/obj.names\nbackup = /mydrive/yolov3' >data/obj.data<jupyter_output><empty_output><jupyter_text>**Create folder for images**<jupyter_code>!mkdir data/obj
!mkdir data/obj1<jupyter_output><empty_output><jupyter_text>**Unzipping all the images to the folder**<jupyter_code>!unzip /mydrive/yolov3/train.zip -d data/obj
!unzip /mydrive/yolov3/test.zip -d data/obj1<jupyter_output>Archive:  /mydrive/yolov3/test.zip
  inflating: data/obj1/img497.png    
  inflating: data/obj1/img497.txt    
  inflating: data/obj1/img498.png    
  inflating: data/obj1/img498.txt    
  inflating: data/obj1/img499.png    
  inflating: data/obj1/img499.txt    
  inflating: data/obj1/img500.png    
  inflating: data/obj1/img500.txt    
  inflating: data/obj1/img401.png    
  inflating: data/obj1/img401.txt    
  inflating: data/obj1/img402.png    
  inflating: data/obj1/img402.txt    
  inflating: data/obj1/img403.png    
  inflating: data/obj1/img403.txt    
  inflating: data/obj1/img404.png    
  inflating: data/obj1/img404.txt    
  inflating: data/obj1/img405.png    
  inflating: data/obj1/img405.txt    
  inflating: data/obj1/img406.png    
  inflating: data/obj1/img406.txt    
  inflating: data/obj1/img407.png    
  inflating: data/obj1/img407.txt    
  inflating: data/obj1/img408.png    
  inflating: data/obj1/img408.txt    
  inflating: data/obj1/img409.png    
  inflating: da[...]<jupyter_text>**Configuring the images for training**<jupyter_code>import glob
images_list = glob.glob("data/obj/*.png")
with open("data/train.txt","w") as f:
  f.write("\n".join(images_list))<jupyter_output><empty_output><jupyter_text>**Configuring the images for validation**<jupyter_code>import glob
images_list = glob.glob("data/obj1/*.png")
with open("data/test.txt","w") as f:
  f.write("\n".join(images_list))<jupyter_output><empty_output><jupyter_text>**Configuring Pretrained model weights**<jupyter_code>!wget https://pjreddie.com/media/files/darknet53.conv.74<jupyter_output>--2021-08-10 15:48:06--  https://pjreddie.com/media/files/darknet53.conv.74
Resolving pjreddie.com (pjreddie.com)... 192.168.3.11
Connecting to pjreddie.com (pjreddie.com)|192.168.3.11|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 162482580 (155M) [application/octet-stream]
Saving to: ‘darknet53.conv.74’

darknet53.conv.74   100%[===================>] 154.96M  53.2MB/s    in 2.9s    

2021-08-10 15:48:09 (53.2 MB/s) - ‘darknet53.conv.74’ saved [162482580/162482580]<jupyter_text>**Training the YOLO Model**<jupyter_code>#!./darknet detector train data/obj.data cfg/yolov3_training.cfg darknet53.conv.74 -dont_show
# Uncomment below and comment above to re-start your training from last saved weights
!./darknet detector train data/obj.data cfg/yolov3_training.cfg /mydrive/yolov3/yolov3_training_last.weights  -dont_show<jupyter_output>CUDA-version: 11000 (11020), cuDNN: 7.6.5, GPU count: 1  
 OpenCV version: 3.2.0
yolov3_training
 0 : compute_capability = 750, cudnn_half = 0, GPU: Tesla T4 
net.optimized_memory = 0 
mini_batch = 4, batch = 64, time_steps = 1, train = 1 
   layer   filters  size/strd(dil)      input                output
   0 Create CUDA-stream - 0 
 Create cudnn-handle 0 
conv     32       3 x 3/ 1    416 x 416 x   3 ->  416 x 416 x  32 0.299 BF
   1 conv     64       3 x 3/ 2    416 x 416 x  32 ->  208 x 208 x  64 1.595 BF
   2 conv     32       1 x 1/ 1    208 x 208 x  64 ->  208 x 208 x  32 0.177 BF
   3 conv     64       3 x 3/ 1    208 x 208 x  32 ->  208 x 208 x  64 1.595 BF
   4 Shortcut Layer: 1,  wt = 0, wn = 0, outputs: 208 x 208 x  64 0.003 BF
   5 conv    128       3 x 3/ 2    208 x 208 x  64 ->  104 x 104 x 128 1.595 BF
   6 conv     64       1 x 1/ 1    104 x 104 x 128 ->  104 x 104 x  64 0.177 BF
   7 conv    128       3 x 3/ 1    104 x 104 x  64 ->  104 x 104 x 128 1.595 BF
   8 Sho[...]
{'fraction_non_alphanumeric': 0.1543694400837258, 'fraction_numerical': 0.09615384615384616, 'mean_word_length': 3.951424870466321, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 62, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '567865', 'license': 'Apache-2.0', 'n_tokens_mistral': 3631, 'n_tokens_neox': 3122, 'n_words': 653, 'path': 'YOLO_Plane_Tracking.ipynb', 'repo_name': 'The-SocialLion/CGI-Planes-in-Satellite-Imagery-using-Custom-YOLO-v3-model', 'size': '7646'}