{"id":18769796,"url":"https://github.com/buarki/snapmath","last_synced_at":"2026-05-05T17:33:18.859Z","repository":{"id":215430830,"uuid":"736448458","full_name":"buarki/snapmath","owner":"buarki","description":"Simple calculator using ML and image processing.","archived":false,"fork":false,"pushed_at":"2024-07-06T16:16:57.000Z","size":13428,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T03:59:36.123Z","etag":null,"topics":["cnn","docker","jupyter-notebook","machine-learning","mlops","tensorflow"],"latest_commit_sha":null,"homepage":"https://snapmath-azure.vercel.app","language":"Jupyter Notebook","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/buarki.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,"zenodo":null}},"created_at":"2023-12-28T00:03:42.000Z","updated_at":"2024-07-24T23:22:28.000Z","dependencies_parsed_at":"2025-05-20T23:42:52.181Z","dependency_job_id":null,"html_url":"https://github.com/buarki/snapmath","commit_stats":null,"previous_names":["buarki/snapmath"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/buarki/snapmath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buarki%2Fsnapmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buarki%2Fsnapmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buarki%2Fsnapmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buarki%2Fsnapmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buarki","download_url":"https://codeload.github.com/buarki/snapmath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buarki%2Fsnapmath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32660347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["cnn","docker","jupyter-notebook","machine-learning","mlops","tensorflow"],"created_at":"2024-11-07T19:16:56.503Z","updated_at":"2026-05-05T17:33:18.841Z","avatar_url":"https://github.com/buarki.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snapmath\n\n## Project TOC\n1. [Just want to run the project](#running-from-docker);\n2. [The app in action](#app-in-action);\n3. [Design Document](./design-doc.md);\n4. [Jupyter Notebook of model](./machine-learning/snapmath.ipynb);\n5. [App local development (Python)](#running-python-app-from-source-code);\n6. [App local development (React)](#running-react-app-from-source-code);\n7. [Saving a built and trained model](#saving-a-built-and-trained-mode);\n8. [Exposing the model on Tensorflow serving](#exposing-the-model-using-tensorflow-serving);\n9. [Next steps](#next-steps);\n10. [Contribution](#contribution);\n\n## Running from docker\n\n```sh\ndocker run -p 5000:5000 -e MODEL_PATH=\"./models/1703825980\" buarki/snapmath-app\n```\n\nOnce running go to http://localhost:5000. You can find some images to use at the ML directory.\n\n## App in action\n\n\u003cimg src=\"./imgs/app-in-action-1.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-2.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-3.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-4.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-5.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-6.png\" width=\"350\" alt=\"App in action\"\u003e\n\u003cimg src=\"./imgs/app-in-action-7.png\" width=\"350\" alt=\"App in action\"\u003e\n\n\n## Running Python app from source code\n\nTo develop the app you can follow this steps:\n\n1. enter the app directory:\n\n```sh\ncd app\n```\n\n2. Initialize virtual env:\n\n```sh\npython3 -m venv app/snapmath\n```\n\n3. Activate the virtual env:\n\n```sh\nsource snapmath/bin/activate\n```\n\n4. Install dependencies:\n\n```sh\npip3 install -r requirements.txt\n```\n\n5. To Run the app:\n\n```sh\nMODEL_PATH=\"../models/1703825980\" python3 -m flask run --host=0.0.0.0\n```\n\nMODEL_PATH is pointing to the saved model [1703825980](./models/1703825980/).\n\nOnce running go to http://localhost:5000. You can find some images to use at the [ML directory](/machine-learning/numbers/).\n\n## Running React app from source code\n\nTo develop the app you can follow this steps:\n\n1. enter the app directory:\n\n```sh\ncd app-js\n```\n\n2. Set Node version to 19.0.0:\n\n```sh\nnvm 19.0.0\n```\n\n3. Install dependencies:\n\n```sh\nnpm i\n```\n\n4. Run\n\n```sh\nnpm run dev\n```\n\nOnce running go to http://localhost:3000. You can find some images to use at the [ML directory](/machine-learning/numbers/).\n\nFor more info, see the full [project here](/app-js).\n\n## Saving a built and trained mode\n\nYou can collect and save your built model by using this script. Just follow bellow steps:\n1. Collect the path of the model inside jupyter notebook. You can do so by running:\n\n```sh\ndocker-compose exec jupyter-notebook sh -c \"ls -td snapmath-model/* | head -n 1\"\n```\n\n2. Get the base path of the jupyter container:\n\n```sh\ndocker-compose exec jupyter-notebook pwd\n```\n\n3. Get the container id of jupyter notebook:\n\n```sh\ndocker ps | grep \"jupyter-notebook\" \n```\n\nIf you are using docker-compose you can also use the container name;\n\n4. Now call the script [collect-model.sh](./collect-model.sh) proving these arguments:\n\n```sh\n./collect-model.sh jupyter-notebook CONTAINER_BASE_PATH/MODEL_PATH\n```\n\nA concrete example is bellow one:\n\n```sh\n./collect-model.sh 2c40e8ce7197 /home/jovyan/snapmath-model/1703825980\n```\n\nwhere:\n- 2c40e8ce7197 is the container jupyter notebook container id\n- /home/jovyan/snapmath-model/1703825980 is the new model to be saved\n\n## Exposing the model using TensorFlow Serving\nIn order to see a trained model running performing the inferences, we can leverage [TensorFlow Serving](https://www.tensorflow.org/tfx/serving/architecture), which is a prepared docker image able to load the model and make it available via REST or gRPC. The [Makefile](./Makefile) already has a command to expose a collected model in it. First, we need to build the image based on the [provided Dockerfile](./tensor-flow-serving/Dockerfile) adding the [collected models](./models/) inside of it:\n\n```sh\nmake build-tf-serving\n```\n\nThen we can run:\n\n```sh\nmake run-tf-service\n```\n\nThe REST API will be available at localhost:8501, and you can easily call this API using the [provided client using Jupyter Notebook](./machine-learning/tensorflow-serving-client.ipynb).\n\n## Next steps\nFor now I see two interesting points to inspect:\n- Check if is it possible to run this model using Go;\n\n## Contribution\n\nContributions are welcome!\nIf you find something interesting to improve just open a PR :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuarki%2Fsnapmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuarki%2Fsnapmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuarki%2Fsnapmath/lists"}