Skip to content

Instantly share code, notes, and snippets.

from __future__ import division, print_function, absolute_import
import pickle
import numpy as np
from PIL import Image
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
name: "toyota_SSD_500x500_train"
layer {
name: "data"
type: "AnnotatedData"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
name: "VGG_ILSVRC_16_layers"
layer {
name: 'input-data'
type: 'Python'
top: 'data'
top: 'im_info'
top: 'gt_boxes'
python_param {
module: 'roi_data_layer.layer'
layer: 'RoIDataLayer'
image = cv2.imread('imgtest/boss.jpg')
cpimg = image.copy()
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = skimage.img_as_float(image).astype(np.float32)

Train Py-Faster-RCNN on Another Dataset

This tutorial is a fine-tuned clone of zeyuanxy's one for the py-faster-rcnn code.

We will illustrate how to train Py-Faster-RCNN on another dataset in the following steps, and we will take INRIA Person as the example dataset.

Clone py-faster-rcnn repository

The current tutorial need you to have clone and tested the regular py-faster-rcnn repository from rbgirshick.

$ git clone https://github.com/rbgirshick/py-faster-rcnn
img = read_image(file_name)
x_batch = np.ndarray((1, 3, model.insize, model.insize), dtype=np.float32)
x_batch[0] = img
y_batch = np.ndarray((1,), dtype=np.int32)
y_batch[0] = label
x = chainer.Variable(xp.asarray(x_batch), volatile=True)
t = chainer.Variable(xp.asarray(y_batch), volatile=True)
def detect_and_save(self, input_path):
img = cv2.imread(input_path)
copy_img = img.copy()
bboxes = self.detect(img)
for bbox_cls in bboxes:
for bbox, class_name in bbox_cls:
cv2.rectangle(frameClone, (bbox[0], bbox[1]), (bbox[2], bbox[3]), (0, 255, 0), 2)
cv2.putText(copy_img,class_name,(bbox[0],bbox[1] - 20), cv2.FONT_HERSHEY_PLAIN, 1.0, (0,0,255), 1)
save_path = "data/" +str(hashlib.md5(img).hexdigest()) + ".jpg"
cv2.imwrite(save_path,copy_img)
#!/usr/bin/env python
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""
from skimage import io
from skimage import transform as tf
import random
import numpy as np
import md5
import glob
def rotate(image):
angle = random.randint(1,360)
# Dependencies: https://github.com/alexis-mignon/python-flickr-api
import flickr_api as f
from sets import Set
f.set_keys(api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
api_secret = 'xxxxxxxxxxxxxxx')
auth = f.auth.AuthHandler()