Git Product home page Git Product logo

faces's Introduction

Faces

😔 → 😀

A Python wrapper around FaceApp .

Build Status Python version

Installation

$ pip install git+https://github.com/vasilysinitsin/Faces.git or manually clone this repo.

Basic Usage

With file,

import faces

sad = open('sad.jpg', 'rb')
image = faces.FaceAppImage(file=sad)
happy = image.apply_filter('smile', cropped=True)

with URL

import faces

old_rockfeller = 'https://upload.wikimedia.org/wikipedia/commons/6/6f/John_D._Rockefeller_1885.jpg'
image = faces.FaceAppImage(url=old_rockfeller)
young_rockfeller = image.apply_filter('young')

or with FaceApp code and device id

import faces

code_of_me_uploaded = '20170517181457gflf'
my_device_id = '12345678'
image = faces.FaceAppImage(code=code_of_me_uploaded, device_id=my_device_id)
brad_pitt = image.apply_filter('hot')

Filter list

Can be obtained using filters property.

>>> image = faces.FaceAppImage(...)
>>> image.filters
['no-filter', 'smile', 'smile_2', 'hot', 'old', 'young', 'hollywood', 'fun_glasses', 'hitman',
'mustache_free', 'pan', 'heisenberg', 'female', 'female_2', 'male', 'no-filter', 'impression',
'goatee', 'mustache', 'hipster', 'lion', 'bangs', 'glasses', 'wave', 'makeup']

You can track which of them works on Travis CI latest build info. It is scheduled to be updated daily.

Handling Exceptions

try:
    image = faces.FaceAppImage(...)
except faces.ImageHasNoFaces:
    print('Your face is not recognized. Are you an alien?')
except faces.BadImageType:
    print('This image is not valid. Get some good bytes.')
except faces.BaseFacesException:
    print('Some unknown wrong things happened.')

try:
    result = image.apply_filter('young, rich and powerful')
except faces.BadFilterID:
    print('Too cool filter to exist.')

Advanced features

Dumping and rebuilding class from json

# It is handy when you have uploader-worker application and have to pass data between.

image = faces.FaceAppImage(...)
json_string = image.to_json() # type(json_string) == str

"""
...pass to different machine
"""

rebuilt_image = faces.FaceAppImage.from_json(json_string) # type(rebuilt_image) == faces.FaceAppImage

Tests and API status

This module hardly relies on undocumented FaceApp API. Tests are scheduled to run daily on Travis CI to ensure API works as expected.

Yes, it's that easy. Now create something cool!

faces's People

Contributors

vasilysinitsin avatar re1ard 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.