Skip to content

Commit 7299d41

Browse files
committed
python_face++
1 parent 9de0eb9 commit 7299d41

File tree

23 files changed

+729
-0
lines changed

23 files changed

+729
-0
lines changed

python_face++/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
*.swp

python_face++/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# FacePlusPlus Python SDK
2+
3+
This is the Face++ python SDK suite. Note that python2.7 is required.
4+
5+
## 1. cmdtool.py
6+
This is an interactive command line tool which could be used to experiment
7+
with Face++ APIs. It is recommended to have ipython installed so that you can
8+
have tab-completion and some other nice features.
9+
10+
First please put your API key/secret in apikey.cfg. Then you can start the program
11+
and you will drop into a python shell, where you can write something like:
12+
13+
api.detection.detect(img = File(r'<path to the image file>'))
14+
15+
Note that `api` here is a global variable.
16+
17+
## 2. hello.py
18+
This is a comprehensive demo for Face++ APIs. See the comments in the source
19+
code for details.
20+
21+
## 3. facepp.py
22+
23+
This is the underlying API implementation.

python_face++/apikey.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SERVER = 'http://api.cn.faceplusplus.com/'
2+
# uncomment the following line to switch to US server
3+
# SERVER = 'http://api.us.faceplusplus.com/'
4+
5+
API_KEY = '<your API key here>'
6+
API_SECRET = '<your API secret here>'

python_face++/cmdtool.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python2
2+
# -*- coding: utf-8 -*-
3+
# $File: cmdtool.py
4+
# $Date: Sat Apr 06 15:42:43 2013 +0800
5+
6+
#
7+
# This program is free software. It comes without any warranty, to
8+
# the extent permitted by applicable law. You can redistribute it
9+
# and/or modify it under the terms of the Do What The Fuck You Want
10+
# To Public License, Version 2, as published by Sam Hocevar. See
11+
# http://sam.zoy.org/wtfpl/COPYING (copied as below) for more details.
12+
#
13+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
14+
# Version 2, December 2004
15+
#
16+
# Copyright (C) 2004 Sam Hocevar <[email protected]>
17+
#
18+
# Everyone is permitted to copy and distribute verbatim or modified
19+
# copies of this license document, and changing it is allowed as long
20+
# as the name is changed.
21+
#
22+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
23+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
24+
#
25+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
26+
27+
def init():
28+
import sys
29+
import os
30+
import os.path
31+
if sys.version_info.major != 2:
32+
sys.exit('Python 2 is required to run this program')
33+
34+
fdir = None
35+
if hasattr(sys, "frozen") and \
36+
sys.frozen in ("windows_exe", "console_exe"):
37+
fdir = os.path.dirname(os.path.abspath(sys.executable))
38+
sys.path.append(fdir)
39+
fdir = os.path.join(fdir, '..')
40+
else:
41+
fdir = os.path.dirname(__file__)
42+
43+
with open(os.path.join(fdir, 'apikey.cfg')) as f:
44+
exec(f.read())
45+
46+
srv = locals().get('SERVER')
47+
from facepp import API
48+
return API(API_KEY, API_SECRET, srv = srv)
49+
50+
api = init()
51+
52+
from facepp import API, File
53+
54+
del init
55+
56+
def _run():
57+
global _run
58+
_run = lambda: None
59+
60+
msg = """
61+
===================================================
62+
Welcome to Face++ Interactive Shell!
63+
Here, you can explore and play with Face++ APIs :)
64+
---------------------------------------------------
65+
Getting Started:
66+
0. Register a user and API key on http://www.faceplusplus.com
67+
1. Write your API key/secret in apikey.cfg
68+
2. Start this interactive shell and try various APIs
69+
For example, to find all faces in a local image file, just type:
70+
api.detection.detect(img = File(r'<path to the image file>'))
71+
72+
Enjoy!
73+
"""
74+
75+
try:
76+
from IPython import embed
77+
embed(banner2 = msg)
78+
except ImportError:
79+
import code
80+
code.interact(msg, local = globals())
81+
82+
83+
if __name__ == '__main__':
84+
_run()

python_face++/dist/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
facepp_cmdtool.zip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../apikey.cfg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../cmdtool.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../facepp.py
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
if type python2 > /dev/null
3+
then
4+
python2 cmdtool.py
5+
else
6+
python cmdtool.py
7+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../win32-dist/facepp_cmdtool_win32

0 commit comments

Comments
 (0)