Shortcuts

flash.core.serve.decorators.expose

flash.core.serve.decorators.expose(inputs, outputs)[source]

Expose a function/method via a web API for serving model inference.

The @expose decorator has two arguments, inputs and outputs, which describe how the inputs to predict are decoded from the request and how the outputs of predict are encoded to a response.

Must decorate one (and only one) method when used within a subclass of ModelComponent.

Parameters
  • inputs (Dict[str, BaseType]) – accepts a dictionary mapping keys to decorated method parameter names (must be one to one mapping) with values corresponding to an instantiated specification of a Flash Serve Data Type (ie. Number(), Image(), Text(), etc…)

  • outputs (Dict[str, BaseType]) – accepts a dictionary mapping outputs of the decorated method to keys and data type (similar to inputs). However, unlike inputs the output keys are less strict in their names. IF the method returns a dictionary, the keys must match one-to-one. However, if the method returns a sorted sequence (list / tuple) the keys can be arbitrary, so long as no reserved names are used (primarily python keywords). For result sequences, the order in which keys are defined maps to the appropriate element index in the result (ie. key 0 -> sequence[0], key 1 -> sequence[1], etc.)

Read the Docs v: stable
Versions
latest
stable
0.8.1
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0post1
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.