Skip to content

Instantly share code, notes, and snippets.

@ck196
ck196 / Play_WS_Standalone.scala
Last active November 27, 2015 01:40
Play WS standalone
import play.api.libs.ws.ning._
import play.api.libs.ws._
import play.api.libs.concurrent.Execution.Implicits
object Sample {
def main(args: Array[String]) {
implicit val client = NingWSClient()
implicit val context = Implicits.defaultContext
// close with sslClient.close() when finished with client
@ck196
ck196 / caffe_simple_python.py
Created January 6, 2016 09:19
caffe_simple_python.py
import numpy as np
import matplotlib.pyplot as plt
# Make sure that caffe is on the python path:
caffe_root = '../' # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
@ck196
ck196 / flirckr_search.py
Created January 27, 2016 04:29
Flick search api
# Using flickr_api to search and download images
# https://github.com/alexis-mignon/python-flickr-api/wiki/Tutorial
import flickr_api as f
f.set_keys(api_key = 'xxxxxxxxxxxxxxxxxxxxxxx',
api_secret = 'xxxxxxxxxxx')
auth = f.auth.AuthHandler()
w = f.Walker(f.Photo.search, tags="sumo")
# 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()
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)
#!/usr/bin/env python
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""
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)
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)

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
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)