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. You will also find module_specification.json which contains the specification of your module. It has two parts spec and ui.

module_specification.json: The module_specification you get by default has two sections 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 default module takes four inputs, one image file and three integer values named red, green and blue. The code tints the input image based on the given RGB values. The module outputs one file named tinted_image. The names of input and outputs are very important, since these are the keys through which we will access inputs and outputs. To this in detail, open apeer_main.py. As you can see, to get inputs you will use

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'])

tint_image is the python module which contains a method run that takes the input and runs the algorithm and returns the output dictionary

Apeer_main.py: apeer_main.py is the input point for your module when it runs on Apeer.

Clone this wiki locally