Skip to content
Nitish Tripathi edited this page Dec 3, 2018 · 13 revisions

Welcome to the apeer-python-sdk wiki!

Lets go through the steps you are required to get your python code on APEER.

Step 1 - Setting up:

Create a new python module on apeer.com. Now clone the git repository of your newly created module. You will find the git url in the section Module Code in the the detail page of your newly created module

Step 2 - Get the Inputs:

You will find two python files appear_main.py and tint_image.py. tint_image.py contains the users algorithm and apeer_main.py is the entry point for module. This file gets the input and writes the output. You will also find module_specification.json which contains the specification of your module. It has two parts spec and ui. The spec part is again divided in two parts inputs and outputs

"spec": {
    "inputs": {
        "input_image": {
            "type:file": {}
        },
        "red": {
            "type:number": {
                "lower_inclusive": 0.0,
                "upper_inclusive": 1.0
            }
        },
        "green": {
            "type:number": {
                "lower_inclusive": 0.0,
                "upper_inclusive": 1.0
            }
        },
        "blue": {
            "type:number": {
                "lower_inclusive": 0.0,
                "upper_inclusive": 1.0
            }
        }
    },
    "outputs": {
        "tinted_image": {
            "type:file": {}
        }
    }
}

The module takes four inputs, one image file and three integer values named red, green and blue. The module outputs one file named tinted_image. The names of input and outputs specified in module_specification file are very important, since these are the keys through which we will access inputs and outputs inside our code. To see this in action, open apeer_main.py. You will find

inputs = adk.get_inputs()

get_inputs() method returns a dictionary containing a the key and value pair for your module inputs. For example, inputs can be {"input_image": "\input\image.jpg", "red": 0.3, "blue": 0.4, "green": 1}. The inputs are passed your code using

outputs = tint_image.run(inputs['input_image'], inputs['red'], inputs['green'], inputs['blue'])

##Step 3 - Writing Outputs:

Clone this wiki locally