Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# YOLOv2 in Keras and Applications

This repo contains the implementation of YOLOv2 in Keras with Tensorflow backend. It supports training YOLOv2 network with various backends such as MobileNet and InceptionV3. Links to demo applications are shown below. Check out https://experiencor.github.io/yolo_demo/demo.html for a Raccoon Detector demo run entirely in brower with DeepLearn.js and MobileNet backend (it somehow breaks in Window). Source code of this demo is located at https://git.io/vF7vG.
This repo contains the implementation of YOLOv2 in Keras with Tensorflow backend. It supports training YOLOv2 network with various backends such as MobileNet and InceptionV3. Links to demo applications are shown below. Check out https://experiencor.github.io/yolo_demo/demo.html for a Raccoon Detector demo run entirely in browser with DeepLearn.js and MobileNet backend (it somehow breaks in Window). Source code of this demo is located at https://git.io/vF7vG.

## Todo list:
- [x] Warmup training
Expand Down Expand Up @@ -42,7 +42,7 @@ Dataset => http://cvrr.ucsd.edu/vivachallenge/index.php/hands/hand-detection/

### 0. Requirement

python 2.7
python 2.7 or python 3.6

keras >= 2.0.8

Expand All @@ -69,7 +69,7 @@ The configuration file is a json file, which looks like this:
```python
{
"model" : {
"architecture": "Full Yolo", # "Tiny Yolo" or "Full Yolo" or "MobileNet" or "SqueezeNet" or "Inception3"
"backend": "Full Yolo", # "Tiny Yolo" or "Full Yolo" or "MobileNet" or "SqueezeNet" or "Inception3"
"input_size": 416,
"anchors": [0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828],
"max_box_per_image": 10,
Expand Down
2 changes: 1 addition & 1 deletion backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def space_to_depth_x2(x):
x = LeakyReLU(alpha=0.1)(x)

self.feature_extractor = Model(input_image, x)
self.feature_extractor.load_weights(FULL_YOLO_BACKEND_PATH)
# self.feature_extractor.load_weights(FULL_YOLO_BACKEND_PATH)

def normalize(self, image):
return image / 255.
Expand Down
14 changes: 7 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
"input_size": 416,
"anchors": [0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828],
"max_box_per_image": 10,
"labels": ["kangaroo"]
"labels": ["raccoon"]
},

"train": {
"train_image_folder": "/home/andy/data/kangaroo/images/",
"train_annot_folder": "/home/andy/data/kangaroo/annots/",
"train_image_folder": "./train_image_folder/",
"train_annot_folder": "./train_annot_folder/",

"train_times": 8,
"pretrained_weights": "full_yolo_kangaroo3.h5",
"pretrained_weights": "",
"batch_size": 16,
"learning_rate": 1e-4,
"nb_epochs": 1,
"nb_epochs": 50,
"warmup_epochs": 3,

"object_scale": 5.0 ,
"no_object_scale": 1.0,
"coord_scale": 1.0,
"class_scale": 1.0,

"saved_weights_name": "full_yolo_kangaroo.h5",
"saved_weights_name": "full_yolo_raccoon.h5",
"debug": true
},

Expand Down
9 changes: 9 additions & 0 deletions preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def parse_annotation(ann_dir, img_dir, labels=[]):

return all_imgs, seen_labels

def parse_annotation_json(ann_dir, img_dir, labels=[]):
all_imgs = []
seen_labels = []

for ann in sorted(os.listdir(ann_dir)):
img = { 'object': [] }

pass

class BatchGenerator(Sequence):
def __init__(self, images,
config,
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tensorflow-gpu==1.3
keras==2.0.8
tensorflow-gpu
keras
imgaug
opencv-python
h5py
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-1.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-1.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>650</width>
<height>417</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>81</xmin>
<ymin>88</ymin>
<xmax>522</xmax>
<ymax>408</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-10.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-10.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>450</width>
<height>495</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>130</xmin>
<ymin>2</ymin>
<xmax>446</xmax>
<ymax>488</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-100.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-100.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-100.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>960</width>
<height>576</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>548</xmin>
<ymin>10</ymin>
<xmax>954</xmax>
<ymax>520</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-101.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-101.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-101.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>640</width>
<height>426</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>86</xmin>
<ymin>53</ymin>
<xmax>400</xmax>
<ymax>356</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-102.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-102.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-102.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>259</width>
<height>194</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1</xmin>
<ymin>1</ymin>
<xmax>118</xmax>
<ymax>152</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-103.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-103.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-103.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>480</width>
<height>640</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>92</xmin>
<ymin>54</ymin>
<xmax>460</xmax>
<ymax>545</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-104.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-104.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-104.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>600</width>
<height>304</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>189</xmin>
<ymin>41</ymin>
<xmax>340</xmax>
<ymax>249</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-105.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-105.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-105.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>720</width>
<height>960</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>250</xmin>
<ymin>49</ymin>
<xmax>714</xmax>
<ymax>869</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-106.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-106.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-106.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>269</width>
<height>187</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>31</xmin>
<ymin>21</ymin>
<xmax>226</xmax>
<ymax>146</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-107.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-107.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-107.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>500</width>
<height>622</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>165</xmin>
<ymin>51</ymin>
<xmax>496</xmax>
<ymax>590</ymax>
</bndbox>
</object>
</annotation>
26 changes: 26 additions & 0 deletions train_annot_folder/raccoon-108.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<annotation verified="yes">
<folder>images</folder>
<filename>raccoon-108.jpg</filename>
<path>/Users/datitran/Desktop/raccoon/images/raccoon-108.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>604</width>
<height>481</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>raccoon</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>99</xmin>
<ymin>53</ymin>
<xmax>402</xmax>
<ymax>464</ymax>
</bndbox>
</object>
</annotation>
Loading