Code Monkey home page Code Monkey logo

project-oxford-python's Introduction

Project Oxford for Python

Build Status PyPI version

This package contains a set of intelligent APIs understanding images: It can detect and analyze people's faces, their age, gender, and similarity. It can identify people based on a set of images. It can understand what is displayed in a picture and crop it according to where the important features are. It can tell you whether an image contains adult content, what the main colors are, and which of your images belong in a group. If your image features text, it will tell you the language and return the text as a string. It's basically magic. For more details on the Project Oxford API, please visit projectoxford.ai.

This python module implements all APIs available in the Face and Vision APIs of Project Oxford.

Installation

To install the latest release you can use pip.

$ pip install projectoxford

Usage

Note: before you can send data to you will need an API key. There are separate API keys for face and vision.

Initialize a client

from projectoxford import Client
client = Client('<api_key>')

Face detection

result = client.face.detect({'url': 'https://upload.wikimedia.org/wikipedia/commons/1/19/Bill_Gates_June_2015.jpg'})
print(result['faceId'])
print(result['attributes']['age'])

Face identification

personGroup = 'example-person-group'
bill = 'https://upload.wikimedia.org/wikipedia/commons/1/19/Bill_Gates_June_2015.jpg'
billAndMelinda = 'https://upload.wikimedia.org/wikipedia/commons/2/28/Bill_og_Melinda_Gates_2009-06-03_%28bilde_01%29.JPG'

# get a face ID and create and train a person group with a person
faceId = client.face.detect({'url': bill})[0]['faceId']
client.face.personGroup.createOrUpdate(personGroup, 'my person group')
client.face.person.createOrUpdate(personGroup, [faceId], 'bill gates')
client.face.personGroup.trainAndPollForCompletion(personGroup)

# detect faces in a second photo
detectResults = client.face.detect({'url': billAndMelinda})
faceIds = []
for result in detectResults:
    faceIds.append(result['faceId'])

# identify any known faces from the second photo
identifyResults = client.face.identify(personGroup, faceIds)
for result in identifyResults:
    for candidate in result['candidates']:
        confidence = candidate['confidence']
        personData = client.face.person.get(personGroup, candidate['personId'])
        name = personData['name']
        print('identified {0} with {1}% confidence'.format(name, str(float(confidence) * 100)))

# remove the example person group from your subscription
client.face.personGroup.delete(personGroup)

Contributing

Development environment

  • Install python, pip

  • Get a Project Oxford API key

  • Install dev dependencies

    pip install -r requirements.txt
    
  • Set environment variable API key

    set OXFORD_FACE_API_KEY=<insert_your_key_here>
    set OXFORD_VISION_API_KEY=<insert_your_key_here>
    
  • Run tests

    python setup.py test
    
  • Publishing

    • update version number in setup.py
     git tag <version number> -m "update tag version"
     git push --tags origin master
     python setup.py register -r pypi # first time only
     python setup.py sdist upload
    

License

Licensed as MIT - please see LICENSE for details.

project-oxford-python's People

Contributors

az0 avatar irjudson avatar lxiange avatar southwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

project-oxford-python's Issues

Error run pip command

Hello i am trying to install it with pip install projectoxford and i am getting this error:

Downloading/unpacking projectoxford
Downloading projectoxford-0.3.1.zip
Running setup.py (path:/tmp/pip-build-y3pBs5/projectoxford/setup.py) egg_info for package projectoxford
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip-build-y3pBs5/projectoxford/setup.py", line 12, in
with open('README', 'r', encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip-build-y3pBs5/projectoxford/setup.py", line 12, in

with open('README', 'r', encoding='utf-8') as f:

TypeError: 'encoding' is an invalid keyword argument for this function


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-y3pBs5/projectoxford
Storing debug log for failure in /home/panagorn/.pip/pip.log

API version

Can you change the api version from v0 to v1?

No Client.py in projectoxford and doesn't work with previous version

Hello!
I can't make project oxford work fine.
I'm just trying to get emotion status from picture.

OS - Windows
Python - 3.5

Here are my steps:

  1. Install python 3.5
  2. pip install projectoxford

Then I crate new .py file and put this code:

from projectoxford import Client
client = Client('111')
result = client.face.detect({'url': 'https://st.kp.yandex.net/images/actor_iphone/iphone360_37859.jpg'})
print (result['faceId'])
print (result['attributes']['age'])

And I get this error:
from projectoxford import Client
ImportError: cannot import name 'Client'

I checked - there are really no Client.py in C:\Python35\Lib\site-packages\projectoxford and it's even absent at latest version of Project Oxford modules:
https://pypi.python.org/pypi/projectoxford/0.3.1

I've tried to copy Client.py, Emotion.py ...etc from projectoxford-0.2.0 (downloaded it from https://pypi.python.org/pypi/projectoxford/0.2.0) into C:\Python35\Lib\site-packages\projectoxford and now my code returns this error:
client = Client('XXX')
TypeError: 'module' object is not callable (there is my API instead of XXX).

I have been fighting with it all day and I can't find the solution. Could you help me?
I apologize, my English is too bad.

Thank you!

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.