Deployment and virtualization, Dockerization project

Joseph Chazalon, Clément Demoulins {firstname.lastname@lrde.epita.fr}

February 2020

Assignment

For this project you have to encapsulate an image processing tool in a Docker image and expose it through a REST API.

The tool in question is a Python script which detect the outline of a document page scanned using a smartphone (ie we took a picture of it). The full version of this tool (not provided here) enables to automatically correct the perspective distortion and crop the resulting image so the resulting image looks like a document acquired using a traditional flatbed scanner.

The tool (dewarp.py) and a sample REST client (client.py) are available in the resources.tar.gz file. We also provide you with a sample input image.

Synopsis of the tool:

> python dewarp.py --help
usage: dewarp.py [-h] [-d] input_image output_file

Detect and dewarp (correct perspective transform) a document page area in a mobile captured image.

positional arguments:
  input_image  Input image containing a document page.
  output_file  Path to output JSON file.

optional arguments:
  -h, --help   show this help message and exit
  -d, --debug  Activate debug output. (default: False)

Sample use:

python dewarp.py input_samples/sample01.png /tmp/output.json

Example of result:

{'bl': {'y': 808, 'x': 892}, 
 'tl': {'y': 324, 'x': 740}, 
 'tr': {'y': 280, 'x': 1084}, 
 'br': {'y': 724, 'x': 1284}
}

Warning: if no object is found, no output file is created.*

Constraints, API and hints

Tool dependencies:

Your project will be graded automatically. It MUST exactly implement the following API:

POST /dewarp FILES image

Sample session using the client:

> python client.py input_samples/sample01.png 
{u'bl': {u'y': 808, u'x': 892}, u'tl': {u'y': 324, u'x': 740}, u'tr': {u'y': 280, u'x': 1084}, u'br': {u'y': 724, u'x': 1284}}

The test client is implemented like this:

import requests
import sys
print(requests.post("http://localhost:5000/dewarp",
      files={"image": open(sys.argv[1], "rb")})).json()

You webservice MUST listing on port 5000.

To develope pour REST API, we do not impose any constraint BY we recommend to use the Python framework Flask.

Grading grid

This is subject to change

Description Points
Build OK 4
Run OK with well-formed input 4
.dockerignore file 1
Working docker-compose (build) 1
Working docker-compose (run) 1
Good dependency management (requirements.txt or other) 0.5
Good build cache management, minimization of the number of layers (using req.txt among others) 1
Caches cleaning (build cache, packet manager, etc.) or no problem on this side 0.5
final image size < 500 Mo 2
final image size < 400 Mo 1
final image size < 300 Mo 1
super slim image 1
Good handling of multiple, concurrent calls, without input and output collision 1
Use TMPFS for work data 0.5
Container resource capping (CPU, MEM) 0.5
TOTAL 20

Submission

You MUST submit your project using Moodle.

You submission MUST be a compressed archive (.tar.gz) containing:

Good luck!