digit-recognition¶
Description¶
Note
More information about the service specification can be found in the Core concepts > Service documentation.
This service uses a keras model to guess a digit in an image.
The service is built in two steps:
- Model creation - The creation of the model from the data
- Model serving - The serving of the built model
Model creation¶
The goal of this step is to prepare the data and train a new model. All further commands are ran in the model-creation
directory.
Info
All following commands are done in the model-creation
directory.
Set up the environment¶
Set up the environment with the following commands.
Run the experiment¶
The model can be tweaked using the params.yaml
file. The numbers
parameter allows to indicate the digits the model must be able to detect.
Run a new training using the following commands.
Note
If you encounter a libdevice not found at ./libdevice.10.bc
error message while utilizing an Nvidia GPU with CUDA, you should export the CUDA library path by executing the command:
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/cuda
Adjust the path accordingly. This step is necessary to enable successful GPU-based training for the model.
The DVC pipeline is described in the dvc.yaml
file.
Each stage describes the dependencies and the outputs of the stage. Every time a dependency of the experiment is updated, running dvc repro
will run the stages of the pipeline that are affected and keep the results in cache to speed up future runs.
More information on their website: Get Started: Data Pipelines - dvc.org.
Push new data/results to MinIO¶
In order to push new results to MinIO, use the following commands (similar to Git). Note: DVC automatically adds files that are specified in the pipelines. In other words, there are no needs to explicitly add those files with dvc add
. Don't forget to then add the DVC metadata files to Git as well.
Model serving¶
The goal of this step is to serve the model made in the previous step. All further commands are ran in the model-serving
directory.
The API documentation is automatically generated by FastAPI using the OpenAPI standard. A user friendly interface provided by Swagger is available under the /docs
route, where the endpoints of the service are described.
This simple service only has one route /compute
that takes an image as input, which will be used to guess the number.
Info
All following commands are done in the model-serving
directory.
Retrieve the model¶
Run the following command to get the model created from the previous step.
Environment variables¶
Check the Core concepts > Service > Environment variables documentation for more details.
Start the service locally¶
Check the Core concepts > Service > Start the service locally documentation for more details.
Run the tests with Python¶
Check the Core concepts > Service > Run the tests with Python documentation for more details.