Inputs
It is required to define your model inputs to deploy your machine learning model. You need to specify the inputs. You need to make this definition carefully. Because these input types are used when creating APIs. Currently, there are 2 input types;
Tabular
Image
Types​
1. Tabular​
Basically, it is expected column-based inputs as a sequence if your model input is a data frame. Tabular type includes list of Column object.
from modelify.schema import Tabular, Input
model_input = Tabular([
Column(name="sepal length", input_type="float"),
Column(name="sepal width", input_type="float"),
Column(name="petal width", input_type="float"),
Column(name="petal length", input_type="float")
])
Helper Function For Tabular​
It is very difficult to create this tabular input type for data containing many columns. However, there is a helper function to create this quickly. You can create a Tabular object by giving an example pandas dataframe object.
from modelify.helpers import create_schema
model_input = create_schema(X_train)
2. Image​
Image input type is for generally computer vision models. You must define your size of image.
model_input = Image(width=224, height=224)
Image Channel​
If you are working with grayscale image, you need to set channel to 1. The default of the image channel is 3.
model_input = Image(width=224, height=224, channel=1)
Channel Format​
Image type accepts channels_last or channels_first. It represents the ordering of the dimensions in the inputs. You can change using the channel_format attribute.
channels_last (default) corresponds to inputs with shape (1, height, width, channels)
channels_first corresponds to inputs with shape (1, channels, height, width).
model_input = Image(width=224, height=224, channel=3, channel_format="channels_first")
Sample Data​
You can add a sample input to test your Model Inference locally.
model_input = Image(width=224, height=224)
model_input.add_sample("./test.jpg")