Coder Social home page Coder Social logo

keras-rcnn's Introduction

Keras-RCNN

https://travis-ci.org/broadinstitute/keras-rcnn.svg?branch=master

keras-rcnn is the Keras package for region-based convolutional neural networks.

Requirements

Python 3

keras-resnet==0.2.0

numpy==1.16.2

tensorflow==1.13.1

Keras==2.2.4

scikit-image==0.15.0

Getting Started

Let’s read and inspect some data:

training_dictionary, test_dictionary = keras_rcnn.datasets.shape.load_data()

categories = {"circle": 1, "rectangle": 2, "triangle": 3}

generator = keras_rcnn.preprocessing.ObjectDetectionGenerator()

generator = generator.flow_from_dictionary(
    dictionary=training_dictionary,
    categories=categories,
    target_size=(224, 224)
)

validation_data = keras_rcnn.preprocessing.ObjectDetectionGenerator()

validation_data = validation_data.flow_from_dictionary(
    dictionary=test_dictionary,
    categories=categories,
    target_size=(224, 224)
)

target, _ = generator.next()

target_bounding_boxes, target_categories, target_images, target_masks, target_metadata = target

target_bounding_boxes = numpy.squeeze(target_bounding_boxes)

target_images = numpy.squeeze(target_images)

target_categories = numpy.argmax(target_categories, -1)

target_categories = numpy.squeeze(target_categories)

keras_rcnn.utils.show_bounding_boxes(target_images, target_bounding_boxes, target_categories)

Let’s create an RCNN instance:

model = keras_rcnn.models.RCNN((224, 224, 3), ["circle", "rectangle", "triangle"])

and pass our preferred optimizer to the compile method:

optimizer = keras.optimizers.Adam(0.0001)

model.compile(optimizer)

Finally, let’s use the fit_generator method to train our network:

model.fit_generator(
    epochs=10,
    generator=generator,
    validation_data=validation_data
)

External Data

The data is made up of a list of dictionaries corresponding to images.

  • For each image, add a dictionary with keys 'image', 'objects'
    • 'image' is a dictionary, which contains keys 'checksum', 'pathname', and 'shape'
      • 'checksum' is the md5 checksum of the image
      • 'pathname' is the pathname of the image, put in full pathname
      • 'shape' is a dictionary with keys 'r', 'c', and 'channels'
        • 'c': number of columns
        • 'r': number of rows
        • 'channels': number of channels
    • 'objects' is a list of dictionaries, where each dictionary has keys 'bounding_box', 'category'
      • 'bounding_box' is a dictionary with keys 'minimum' and 'maximum'
        • 'minimum': dictionary with keys 'r' and 'c'
          • 'r': smallest bounding box row
          • 'c': smallest bounding box column
        • 'maximum': dictionary with keys 'r' and 'c'
          • 'r': largest bounding box row
          • 'c': largest bounding box column
      • 'category' is a string denoting the class name

Suppose this data is save in a file called training.json. To load data,

import json

with open('training.json') as f:
    d = json.load(f)

Slack

We’ve been meeting in the #keras-rcnn channel on the keras.io Slack server.

You can join the server by inviting yourself from the following website:

https://keras-slack-autojoin.herokuapp.com/

keras-rcnn's People

Contributors

0x00b1 avatar 24hours avatar akshaybapat04 avatar brandenkmurray avatar chrisakroyd avatar drwaltman avatar guilhermefscampos avatar hannarud avatar hgaiser avatar imparkss avatar jhung0 avatar jihongju avatar mbroisinbi avatar milani avatar yanfengliu avatar yhenon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.