<jupyter_start><jupyter_text>Creating a YOLO modelWe first install the YOLO library<jupyter_code>!git clone https://github.com/joheras/darknet-colab
cd darknet-colab/
!make
!pip install matplotlib
!pip install clodsa
!pip install imutils
!pip install shutil<jupyter_output><empty_output><jupyter_text>Now, we download the necessary files. The following files are employed for fine-tuning the network and configuring the dataset.<jupyter_code>!wget https://www.dropbox.com/s/0js92hbmkozgn46/funciones.py?dl=1 -O funciones.py
!wget https://www.dropbox.com/s/k8tj95uc25x2u7d/pascal2yolo_1class.py?dl=1 -O pascal2yolo_1class.py
!wget https://pjreddie.com/media/files/darknet53.conv.74 -O darknet53.conv.74
!wget https://www.dropbox.com/s/5pkkrx82q9dd7ml/detect.py?dl=1 -O detect.py
!wget https://www.dropbox.com/s/s5ogv96lxqxhr4v/generateXML.py?dl=1 -O generateXML.py
from funciones import *
from pascal2yolo_1class import *
from detect import *<jupyter_output><empty_output><jupyter_text>We download the dataset. If you are working with Google Colab, you have several options to download the dataset in this notebook, see the available options in the [LabelDetection documentation](https://github.com/ancasag/LabelDetection).<jupyter_code>!cp /content/drive/My\ Drive/datasets/dataset.zip dataset.zip
!unzip dataset.zip<jupyter_output><empty_output><jupyter_text>We start the training process.<jupyter_code>!./darknet detector train dataset/classes.data dataset/train.cfg darknet53.conv.74 -dont_show<jupyter_output><empty_output><jupyter_text>Finally, we evaluate the model to know its performance in an independent test set.<jupyter_code>!./darknet detector map dataset/classes.data dataset/test.cfg backup/train_final.weights -thresh 0.25<jupyter_output><empty_output><jupyter_text>At the end you will have your model in the file pesos. Those weights can be included in the application to be employed with new images.  Data distillationAfter training a model with the annotated images, it is possible to apply a data distillation procedure to create a model using the unlabelled images. You can only apply this techique if there were unlabelled images in your dataset.  We first install the library for ensemble methods.<jupyter_code>!git clone https://github.com/ancasag/ensembleObjectDetection.git
cd ensembleObjectDetection/TestTimeAugmentation
!pip install mrcnn
!pip install keras-retinanet
!pip install gluoncv
!pip install mxnet
import testTimeAugmentation
import function
import os
import shutil
import argparse
import ensembleOptions
from mainTTA import tta
from imutils import paths
pathImg = '/content/darknet-colab/dataset/unlabelled/'
yolo = testTimeAugmentation.DarknetYoloPred('/content/darknet-colab/backup/train_final.weights', '/content/darknet-colab/dataset/classes.names','/content/darknet-colab/dataset/train.cfg')
myTechniques = [ "histo","hflip","none"]
option = "affirmative"
tta(yolo,myTechniques,pathImg,option)<jupyter_output><empty_output><jupyter_text>We convert the annotations of the new predictions to txt<jupyter_code>cd /content/darknet-colab/
principal('/content/darknet-colab/dataset/unlabelled')<jupyter_output><empty_output><jupyter_text>We move the jpg and txt to the train carpet<jupyter_code>moverTxt('/content/darknet-colab/dataset/unlabelled/', '/content/darknet-colab/dataset/train/labels/')
moverImg('/content/darknet-colab/dataset/unlabelled/', '/content/darknet-colab/dataset/train/JPEGImages/')
!./darknet detector train dataset/classes.data dataset/train.cfg darknet53.conv.74 -dont_show
!./darknet detector map dataset/classes.data dataset/test.cfg backup/train_final.weights -thresh 0.25<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09760087241003272, 'fraction_numerical': 0.014449291166848418, 'mean_word_length': 6.4271255060728745, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '258089', 'license': 'MIT', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1185, 'n_words': 294, 'path': 'notebooks/YOLOExampleDD2.ipynb', 'repo_name': 'ancasag/labelDetection_2', 'size': '3668'}