-
Notifications
You must be signed in to change notification settings - Fork 1
/
robotics.py
78 lines (58 loc) · 2.87 KB
/
robotics.py
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
# -*- coding: utf-8 -*-
"""Robotics.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1uGEuBPaaz2ef2HzQkfmPieRHIkp1WSt1
"""
# Commented out IPython magic to ensure Python compatibility.
# Clone the repository from the source and build it
! git clone https://github.com/AlexeyAB/darknet
# %cd darknet/
! make
# connect to the google drive
from google.colab import drive
drive.mount('/content.gdrive')
from google.colab import drive
drive.mount('/content/drive')
#print the GPU details
!nvidia-smi
import os
os.environ['PATH'] += ':/usr/local/cuda/bin'
!rm -fr darknet
#go to the darknet folder, edit and remake Makefiles of GPU and OPENCV
# %cd darknet
!sed -i 's/GPU=0/GPU=1/g' Makefile
!sed -i 's/OPENCV=0/OPENCV=1/g' Makefile
!make
# get yolov3 weights
!wget https://pjreddie.com/media/files/darknet53.conv.74
# !chmod a+x ./darknet
#install all the apps which are required
!apt install ffmpeg libopencv-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
# make a directory for traffic light datamkdir traffic-lights
! mkdir traffic-lights
! cp /content/drive/MyDrive/traffic-lights/bosch_voc_to_yolo_converter.py traffic-lights/
! cp /content/drive/MyDrive/traffic-lights/make_xml_list.py traffic-lights/
! cp /content/drive/MyDrive/traffic-lights/train_test_split.py traffic-lights/
# Commented out IPython magic to ensure Python compatibility.
# % cd traffic-lights/
! python make_xml_list.py /content/drive/MyDrive/Dataset/rgb/train/traffic_light_xmls/
# Commented out IPython magic to ensure Python compatibility.
# % cd ..
! cp /content/drive/MyDrive/traffic-lights/voc-bosch.names traffic-lights/
# Commented out IPython magic to ensure Python compatibility.
# % cd traffic-lights/
# ! python bosch_voc_to_yolo_converter.py /content/drive/MyDrive/Dataset/rgb/train/traffic_light_labels/ bosch_traffic_light_xmls_list.txt /content/drive/MyDrive/Dataset/rgb/train/traffic_light_images/
! cp /content/drive/MyDrive/traffic-lights/traffic_lights.txt .
! cp /content/drive/MyDrive/traffic-lights/train_test_split.py .
! python train_test_split.py traffic_lights.txt 0.2
# ! mkdir backup
# Commented out IPython magic to ensure Python compatibility.
# %cd traffic-lights/
! cp /content/drive/MyDrive/traffic-lights/voc-bosch.data .
! cp /content/drive/MyDrive/traffic-lights/yolov3-tiny-bosch.cfg .
# %cd ..
# Commented out IPython magic to ensure Python compatibility.
# %cd ..
# %cd /content/darknet/
! ./darknet detector train traffic-lights/voc-bosch.data traffic-lights/yolov3-tiny-bosch.cfg darknet53.conv.74