Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigmoid overflow error for very small input values z. and Colorful drawing boxes #354

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.bak
*.h5
__pycache__/*
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,51 @@ This repo contains the implementation of YOLOv2 in Keras with Tensorflow backend
- [ ] Multiscale training
- [ ] mAP Evaluation


## Kabrau modifications:

### Evaluation

Validation and test evaluate, by classes, mAP, FPS, and PR CURVE image
- Important: Clone https://github.com/kabrau/mean_average_precision

`python evaluate.py -c confg.json -w /path/to/best_weights.h5 -i /path/validation_images/ -a /path/validation_pascal_xml -j /path/test_images/ -t /path/test_pascal_xml`

Example

`python evaluate.py -c E:/rodney/configs/keras-yolo2/config.Inception3.json -w E:/rodney/weights/Inception3_V2c.h5 -i E:/rodney/DSDFinal/images/ -a E:/rodney/DSDFinal/split/validation/ -j E:/rodney/DSDFinal/images/ -t E:/rodney/DSDFinal/split/test/`

Result example

```
Valid Evaluate
ascending_stair 0.8334
descending_stair 0.6084
door 0.8277
elevator_door 0.9268
Valid mAP: 0.7991

Total Images: 546
Elapse Time: 11.0589
Avg Image Time: 0.0203
FPS: 49

Test Evaluate
ascending_stair 0.7365
descending_stair 0.6934
door 0.7482
elevator_door 0.9024
Test mAP: 0.7701

Total Images: 535
Elapse Time: 9.8113
Avg Image Time: 0.0183
Desvio Padrão: 0.0059
FPS: 54
```



## Some example applications (click for videos):

### Raccon detection
Expand Down
112 changes: 112 additions & 0 deletions evaluate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#! /usr/bin/env python

import argparse
import os
import numpy as np
from preprocessing import parse_annotation
from frontend_evaluate import YOLO
import json

os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"

argparser = argparse.ArgumentParser(
description='Train and validate YOLO_v2 model on any dataset')

argparser.add_argument(
'-c',
'--conf',
help='path to configuration file')

argparser.add_argument(
'-w',
'--weights',
help='path to pretrained weights')

argparser.add_argument(
'-i',
'--inputVal',
help='val image folder')

argparser.add_argument(
'-a',
'--annotVal',
help='val annotation folder')

argparser.add_argument(
'-j',
'--inputTest',
help='test image folder')

argparser.add_argument(
'-t',
'--annotTest',
help='test annotation folder')

def _main_(args):
config_path = args.conf

with open(config_path) as config_buffer:
config = json.loads(config_buffer.read())

###############################
# Parse the annotations
###############################

valid_imgs, valid_labels = parse_annotation(args.annotVal,
args.inputVal,
config['model']['labels'])

test_imgs, test_labels = parse_annotation(args.annotTest,
args.inputTest,
config['model']['labels'])


if len(config['model']['labels']) > 0:
overlap_labels = set(config['model']['labels']).intersection(set(valid_labels.keys()))

print('Seen labels:\t', valid_labels)
print('Given labels:\t', config['model']['labels'])
print('Overlap labels:\t', overlap_labels)

if len(overlap_labels) < len(config['model']['labels']):
print('Some labels have no annotations! Please revise the list of labels in the config.json file!')
return
else:
print('No labels are provided. Train on all seen labels.')
config['model']['labels'] = valid_labels.keys()

###############################
# Construct the model
###############################

yolo = YOLO(backend = config['model']['backend'],
input_size = config['model']['input_size'],
labels = config['model']['labels'],
max_box_per_image = config['model']['max_box_per_image'],
anchors = config['model']['anchors'])

###############################
# Load the pretrained weights (if any)
###############################

print("Loading pre-trained weights in", args.weights)
yolo.load_weights(args.weights)

###############################
# Start the training process
###############################

yolo.eval(valid_imgs = valid_imgs,
test_imgs = test_imgs,
learning_rate = config['train']['learning_rate'],
batch_size = config['train']['batch_size'],
object_scale = config['train']['object_scale'],
no_object_scale = config['train']['no_object_scale'],
coord_scale = config['train']['coord_scale'],
class_scale = config['train']['class_scale'],
debug = config['train']['debug'])

if __name__ == '__main__':
args = argparser.parse_args()
_main_(args)
2 changes: 1 addition & 1 deletion frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def train(self, train_imgs, # the list of images to train the model
save_best_only=True,
mode='min',
period=1)
tensorboard = TensorBoard(log_dir=os.path.expanduser('~/logs/'),
tensorboard = TensorBoard(log_dir=os.path.expanduser('./logs/'),
histogram_freq=0,
#write_batch_performance=True,
write_graph=True,
Expand Down
Loading