This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!git clone https://github.com/AlexeyAB/darknet | |
# verify CUDA | |
!/usr/local/cuda/bin/nvcc --version | |
# change makefile to have GPU and OPENCV enabled | |
%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 | |
!sed -i 's/CUDNN_HALF=0/CUDNN_HALF=1/' Makefile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!sed -i 's/batch=1/batch=64/' cfg/yolov4.cfg | |
!sed -i 's/subdivisions=1/subdivisions=16/' cfg/yolov4.cfg | |
!sed -i 's/max_batches = 500500/max_batches = 6000/' cfg/yolov4.cfg | |
!sed -i '968 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '1056 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '1144 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '961 s@filters=255@filters=18@' cfg/yolov4.cfg . | |
!sed -i '1049 s@filters=255@filters=18@' cfg/yolov4.cfg | |
!sed -i '1137 s@filters=255@filters=18@' cfg/yolov4.cfg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!echo "Glasses" > data/obj.names | |
!echo -e 'classes= 1\ntrain = data/train.txt\nvalid = data/test.txt\nnames = data/obj.names\nbackup = /mydrive/yolov4_v1' > data/obj.data | |
!mkdir data/obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights | |
!wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.conv.137 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!unrar e /mydrive/Colab/yolov4/Glasses.rar -d data/obj | |
import glob | |
import os | |
import re | |
txt_file_paths = glob.glob(r"data/obj/*.txt") | |
for i, file_path in enumerate(txt_file_paths): | |
# get image size | |
with open(file_path, "r") as f_o: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start the training | |
!./darknet detector train data/obj.data cfg/yolov4_training.cfg yolov4.conv.137 -dont_show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division, print_function | |
# coding=utf-8 | |
import sys | |
import os | |
import glob | |
import re, glob, os,cv2 | |
import numpy as np | |
import pandas as pd | |
import glass_detection | |
from shutil import copyfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert the model. | |
converter = tf.lite.TFLiteConverter.from_keras_model(model) | |
tflite_model = converter.convert() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save the model. | |
with open('model.tflite', 'wb') as f: | |
f.write(tflite_model) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conda create -n Python-keras python=3.6 |