Giter VIP home page Giter VIP logo

imagemonkey-libs's Introduction

Python

This library is a small wrapper around the ImageMonkey API.

WARNING The library is still in an alpha stage, which means that the API may change as the development continues.

Requirements

  • Python 3.x is required

Examples

  • download images

download all images that are tagged with the label dog and store them in C:\dogs. We are only interested in images where at least 80% of the people think, that the image is correctly labeled. (min_probability = 0.8)

import logging
from pyimagemonkey import API


if __name__ == "__main__":
	logging.basicConfig()

	api = API(api_version=1)
	res = api.export(["dog"], min_probability = 0.8)

	ctr = 1
	for elem in res:
		print "[%d/%d] Downloading image %s" %(ctr, len(res), elem.image.uuid)
		api.download_image(elem.image.uuid, "C:\\dogs")
		ctr += 1
  • Model (re-)training with Tensorflow

Downloads all images from ImageMonkey that are tagged with the label dog or cat and feeds them directly into Tensorflow to train a new layer on top of a pre-trained image model. The downloaded images are stored in an images folder within the training directory (C:\training). In case the clear_before_start parameter is True the whole images directory gets cleared and the images get re-fetched from ImageMonkey every time the script is run.

Internally the TensorflowTrainer class uses the tensorflow retrain.py script. Usually you do not need to download this script manually, as the ImageMonkey library will take care about that. The file will be automatically downloaded and put into the models folder within the specified training directory. In case you want to download the file manually, set auto_download_tensorflow_train_script to False and copy the file into the appropriate folder.

import logging

from pyimagemonkey import API
from pyimagemonkey import TensorflowTrainer

if __name__ == "__main__":
	logging.basicConfig()

	tensorflow_trainer = TensorflowTrainer("C:\\training", clear_before_start=True, auto_download_tensorflow_train_script=True)
	tensorflow_trainer.train(["dog", "cat"], min_probability = 0.8)

imagemonkey-libs's People

Watchers

James Cloos 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.