{"id":20202785,"url":"https://github.com/froukje/mnist-deployment","last_synced_at":"2026-02-17T00:31:34.612Z","repository":{"id":178146232,"uuid":"514638234","full_name":"froukje/mnist-deployment","owner":"froukje","description":"Deploy App for MNIST Classification using TorchServe and Flask","archived":false,"fork":false,"pushed_at":"2022-07-16T17:25:00.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T20:08:55.528Z","etag":null,"topics":["deep-learning","docker","docker-compose","flask","pytorch","torchserve"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/froukje.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-16T17:05:09.000Z","updated_at":"2023-11-06T18:26:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"296dfe31-3b1d-43e0-8c4c-65c763043fb9","html_url":"https://github.com/froukje/mnist-deployment","commit_stats":null,"previous_names":["froukje/mnist-deployment"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/froukje/mnist-deployment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/froukje%2Fmnist-deployment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/froukje%2Fmnist-deployment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/froukje%2Fmnist-deployment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/froukje%2Fmnist-deployment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/froukje","download_url":"https://codeload.github.com/froukje/mnist-deployment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/froukje%2Fmnist-deployment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29526681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T21:45:09.491Z","status":"ssl_error","status_checked_at":"2026-02-16T21:44:58.452Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","docker","docker-compose","flask","pytorch","torchserve"],"created_at":"2024-11-14T04:58:10.062Z","updated_at":"2026-02-17T00:31:34.572Z","avatar_url":"https://github.com/froukje.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MNIST Web app\n\nThis repository contains a simple web app for making predictions using the MNIST dataset. The purpose is to understand torchserve and how to combine it with a webservice. The model for making the predictions has been downloaded from https://github.com/pytorch/serve/tree/master/examples/image_classifier/mnist/mnist_cnn.pt\n\n## Torchserve only\n\nIn the repo https://github.com/pytorch/serve/tree/master/examples/image_classifier/mnist/ an example how to serve this model using a customized handler based on the ImageClassifier. I used the BaseHandler to get familiar with it. The handler script is called mnist_handler_base.py and I used this post to write it: https://towardsdatascience.com/deploy-models-and-create-custom-handlers-in-torchserve-fc2d048fbe91. The base handler script can be found here: https://github.com/pytorch/serve/blob/master/ts/torch_handler/base_handler.py\n\nCreate the ```.mar``` file, which contains all information to deploy the model (in order to execute this some dependencies need to be installed)\n ```torch-model-archiver --model-name mnist --version 2.0 --model-file mnist.py --serialized-file mnist_cnn.pt --handler mnist_handler_base.py --force```\n\nMove the created file into the ```model-store``` folder\n\n ```mv mnist.mar model-store/```\n\nUse docker to serve the model\n\n```\ndocker run --rm -it -p 8080:8080 -p 8081:8081 --name mar -v $(pwd)/model-store:/home/model-server/model-store -v $(pwd):/home/model-server/examples pytorch/torchserve:latest torchserve --start --model-store model-store --models mnist=mnist.mar\n```\n\nCheck which models are registered:\n\n```curl http://127.0.0.1:8081/models/```\n\n output\n```\n{\n  \"models\": [\n    {\n      \"modelName\": \"mnist\",\n      \"modelUrl\": \"mnist.mar\"\n    }\n  ]\n}\n```\n\nMake predictions: \n```curl http://127.0.0.1:8080/predictions/mnist -T 3.png```, output  ```3```\n\n## Web-App\nnow we want to combine the above with a simple web app to make the predictions from an uploaded image:\n\n* in folder ```deployment``` is a Dockerfile from ```pytorch/torchserve:latest```, which only copies the ```.mar``` file to the ```model-store``` folder. nd starts torchserve (Note: change latest to other version)\n    * build the image: ```build -t torchserve-mar:v1```\n* In subfolder ```app```\n    * create file ```app.py``` and subfolders ```templates``` and ```static```\n    * ```templates``` contains html content of app\n    * ```static``` is for saveig the uploaded images\n    * ```app.py``` is script that creates the app to make predictions\n    * in folder ```app``` create Dockerfile to run the app\n    * build the image ```docker-build -t app:v1```\n* in folder ```deployment``` use ```docker-compose.yaml``` to run both services\n* start services with ```docker-compose up```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffroukje%2Fmnist-deployment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffroukje%2Fmnist-deployment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffroukje%2Fmnist-deployment/lists"}