{"id":26276216,"url":"https://github.com/tanujjain/deploy-ml-model","last_synced_at":"2025-05-06T20:22:03.510Z","repository":{"id":54700471,"uuid":"181222049","full_name":"tanujjain/deploy-ml-model","owner":"tanujjain","description":"Deploying a simple machine learning model to an AWS ec2 instance using flask and docker.","archived":false,"fork":false,"pushed_at":"2019-04-14T15:00:40.000Z","size":12,"stargazers_count":81,"open_issues_count":1,"forks_count":71,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T02:34:30.905Z","etag":null,"topics":["ai","aws","docker","ec2-instance","flask","machine-learning","webservice"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanujjain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-13T19:57:22.000Z","updated_at":"2024-10-21T08:31:51.000Z","dependencies_parsed_at":"2022-08-14T00:30:31.392Z","dependency_job_id":null,"html_url":"https://github.com/tanujjain/deploy-ml-model","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanujjain%2Fdeploy-ml-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanujjain%2Fdeploy-ml-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanujjain%2Fdeploy-ml-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanujjain%2Fdeploy-ml-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanujjain","download_url":"https://codeload.github.com/tanujjain/deploy-ml-model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252761766,"owners_count":21800206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","aws","docker","ec2-instance","flask","machine-learning","webservice"],"created_at":"2025-03-14T11:17:14.396Z","updated_at":"2025-05-06T20:22:03.441Z","avatar_url":"https://github.com/tanujjain.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serve a Machine Learning Model as a Webservice\nServing a simple machine learning model as a webservice using [flask](http://flask.pocoo.org/) and [docker](https://www.docker.com/).\n\n## Getting Started\n1. Use Model_training.ipynb to train a logistic regression model on the [iris dataset](http://archive.ics.uci.edu/ml/datasets/iris) and generate a pickled model file (iris_trained_model.pkl)\n2. Use app.py to wrap the inference logic in a flask server to serve the model as a REST webservice:\n    * Execute the command `python app.py` to run the flask app.\n    * Go to the browser and hit the url `0.0.0.0:80` to get a message `Hello World!` displayed. **NOTE**: A permission error may be received at this point. In this case, change the port number to 5000 in `app.run()` command in `app.py`. \n    (Port 80 is a privileged port, so change it to some port that isn't, eg: 5000)\n    * Next, run the below command in terminal to query the flask server to get a reply ```2``` for the model file provided in this repo:\n     ```\n        curl -X POST \\\n        0.0.0.0:80/predict \\\n        -H 'Content-Type: application/json' \\\n        -d '[5.9,3.0,5.1,1.8]'\n     ```\n 3. Run ```docker build -t app-iris .``` to  build the docker image using ```Dockerfile```. (Pay attention to the period in the docker build command)\n 4. Run ```docker run -p 80:80 app-iris``` to run the docker container that got generated using the `app-iris` docker image. (This assumes that the port in app.py is set to 80)\n 5. Use the below command in terminal to query the flask server to get a reply ```2``` for the model file provided in this repo:\n    ```\n        curl -X POST \\\n        0.0.0.0:80/predict \\\n        -H 'Content-Type: application/json' \\\n        -d '[5.9,3.0,5.1,1.8]'\n    ```\n    \nFor details on floating the containerized app on [AWS ec2 instance](https://aws.amazon.com/ec2/), see the [blog](https://medium.com/@tanuj.jain.10/simple-way-to-deploy-machine-learning-models-to-cloud-fd58b771fdcf).\n\n## LICENSE\nSee [LICENSE](LICENSE) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanujjain%2Fdeploy-ml-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanujjain%2Fdeploy-ml-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanujjain%2Fdeploy-ml-model/lists"}