- flash.core.serve.decorators.expose(inputs, outputs)¶
Expose a function/method via a web API for serving model inference.
@exposedecorator 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
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.
BaseType]) – accepts a dictionary mapping outputs of the decorated method to keys and data type (similar to inputs). However, unlike
inputsthe 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,
key 1 -> sequence, etc.)