2 As a means of testing the API and demonstrating functionality, two
3 additional components are included in this repository:
4 a simple [swagger-based webserver](../../testing) (documented here) and
5 a [demo web page](../../web_demo) (documented in the [next tutorial](lesson3.md).
8 Using a simple [flask-based connexion server](https://github.com/zalando/connexion),
9 an API scaffold has been built to host a serialized/dumped model.
11 To utilized [this example app](../../testing), an instance should first be built and downloaded
12 from Acumos (or dumped to disk) and then
13 launched locally. Afterwards, the sample application found in
14 [web_demo](web_demo) (see [the next tutorial](lesson3.md))
15 uses a `localhost` service to transform
16 and visualize the results of model operation.
20 usage: app.py [-h] [-p PORT] [-d MODELDIR_DETECT] [-a MODELDIR_ANALYZE]
23 -h, --help show this help message and exit
24 -p PORT, --port PORT port to launch the simple web server
25 -d MODELDIR_DETECT, --modeldir_detect MODELDIR_DETECT
26 model directory for detection
27 -a MODELDIR_ANALYZE, --modeldir_analyze MODELDIR_ANALYZE
28 model directory for detection
32 Example usage may be running with a detect model that was dumped to the directory `model_detect`
33 in the main repo source directory and a pixelate model in the
34 directory `model_pix` (under the same repo source directory).
37 python app.py --modeldir_detect ../model_detect --modeldir_analyze ../model_pix/
42 This repo provides multiple models that can be created.
44 * detect output - The first set, called
45 `detect` will analyze an image, detect face regions, and echo both the
46 regions and the face back to the user. The region marked with `-1`
47 and a valid `mime_type` parameter will
48 always be the region with the original image.
56 "base64_data": "/9j/4AAQSkZJRgABA....",
60 "mime_type": "image/jpeg"
87 * analyzed output - The second type of output produces processed
88 images as an output. These images are base64 encoded with a decoding
93 "base64_data": "/9j/4AAQSkZJRgABAQAAAQABAAD....",
94 "mime_type": "image/jpeg"
102 * For a graphical experience, view the swagger-generated UI at [http://localhost:8884/ui].
103 * Additionally, a simple command-line utility could be used to post an image
104 and mime type to the main interface. Additional examples for posting base64 encoded
105 images from javascript can be [found on StackOverflow](https://stackoverflow.com/a/20285053).
107 curl -F base64_data=@../web_demo/images/face_renion.jpg -F mime_type="image/jpeg" "http://localhost:8884/transform"
111 Sample images are provided in the `testing` directory and were originally sourced
114 * [multi-face_pexels.jpg](https://www.pexels.com/photo/family-generation-father-mother-8509/)
115 * [single-face_pexels.jpg](https://www.pexels.com/photo/adult-beard-boy-casual-220453/)