{"id":21744129,"url":"https://github.com/lobe/flask-server","last_synced_at":"2025-04-13T05:07:44.042Z","repository":{"id":46183626,"uuid":"337830188","full_name":"lobe/flask-server","owner":"lobe","description":"Bootstrap your Lobe machine learning model with our REST API starter project.","archived":false,"fork":false,"pushed_at":"2021-11-08T21:42:52.000Z","size":1969,"stargazers_count":32,"open_issues_count":1,"forks_count":17,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T05:07:37.663Z","etag":null,"topics":["api","bootstrap","flask","lobe","machine-learning","rest"],"latest_commit_sha":null,"homepage":"https://lobe.ai","language":"Python","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/lobe.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":"2021-02-10T19:24:22.000Z","updated_at":"2025-01-31T03:24:18.000Z","dependencies_parsed_at":"2022-09-25T05:51:40.977Z","dependency_job_id":null,"html_url":"https://github.com/lobe/flask-server","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/lobe%2Fflask-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobe%2Fflask-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobe%2Fflask-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lobe%2Fflask-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lobe","download_url":"https://codeload.github.com/lobe/flask-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"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":["api","bootstrap","flask","lobe","machine-learning","rest"],"created_at":"2024-11-26T07:10:09.091Z","updated_at":"2025-04-13T05:07:44.010Z","avatar_url":"https://github.com/lobe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align:center\"\u003e\u003cimg src=\"https://github.com/lobe/flask-server/blob/main/assets/header.jpg\" /\u003e\u003c/div\u003e\u003cbr\u003e\n\n[Lobe](http://lobe.ai/) is a free, easy to use app that has everything you need to bring your machine learning ideas to life. This Flask starter project creates a REST API to get predictions from a TensorFlow model on your projects or apps. To start using it, follow the instructions below:\n\n## Get Started\n\n1. Clone or download the project on your computer to get started. You'll need Python 3.6, 3.7, 3.8, or 3.9 to run this starter project as well.\n\n2. Export a TensorFlow model from Lobe\n\n3. Move the `saved_model.pb` file, `variables` folder, and `signature.json` file exported from Lobe to the `/model` folder\n\n#### Windows\n\n3. Create and activate a virtual environment  \n```python\npython -m venv .venv\n.venv\\Scripts\\activate\n```\n\n4. Install dependencies  \n```python\npython -m pip install --upgrade pip \u0026\u0026 pip install -r requirements.txt\n```\n\n5. Run the server locally  \n```python\npython app.py\n```\n\n#### macOS\n\n3. Create and activate a virtual environment\n```python\npython -m venv .venv\nsource .venv/bin/activate\n```\n\n4. Install dependencies\n```python\npython -m pip install --upgrade pip \u0026\u0026 pip install -r requirements.txt\n```\n\n5. Run the server\n```python\npython app.py\n# or\nexport FLASK_APP=app.py\nflask run\n```\n#### Deploy to Azure App Service\n\n1. Have version 2.0.80 or higher of [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) installed.  \n   `az --version`\n2. Login by running this command and following prompts   \n`az login`\n3. Deploy to the cloud!  \n`az webapp up --sku B1 --name \u003cyour unique app name\u003e`\n\nAzure documentation is available if you run into issues. \nThis [quick start](https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?toc=%2Fpython%2Fazure%2FTOC.json\u0026tabs=bash\u0026pivots=python-framework-flask) is a good starting point.\n\n\n### Sending a request\n\n1. Perform a post request to the target url/predict with your base64 image. Refer to `testing.py` for getting started sending requests to the server.\n```JSON\n{\n  \"image\": \"\u003cbase64 image\u003e\"\n}\n```\n\n2. Successful requests return JSON with the confidences of your predictions.\n```JSON\n{\n  \"predictions\": [\n    {\n      \"predicted_label\": 0.9105\n    },\n    {\n      \"another_label\": 0.0895\n    }\n  ]\n}\n```\n\n## Additional Information\n\nThe Flask starter project is optimized for models exported from Lobe but could be used with any TensorFlow models with some small updates.\n\nLobe has an endpoint built in called Lobe Connect that can be used while running the app and this starter project works the same way. If your app works with Lobe Connect, it will work with this starter project just by updating the URL.\n\nWe are using TensorFlow 2.7.0 to run the tf_example.py file. If you see any GPU errors or want to run the script on GPU please refer to https://www.tensorflow.org/install/gpu\n\nThe code takes in a `base64` image and returns an array of predictions and confidences. The server code that defines endpoints is in `app.py`. And the code for using your model including image pre-processing and output formatting for a prediction is in `tf_model_helper.py`. For reference, the Swagger definition file lives in `swagger/`.\n\n## Contributing\n\nGitHub Issues are for reporting bugs, discussing features and general feedback on the Flask starter project. Be sure to check our documentation, FAQ and past issues before opening any new ones.\n\nTo share your project, get feedback on it, and learn more about Lobe, please visit our community on [Reddit](https://www.reddit.com/r/Lobe/). We look forward to seeing the amazing projects that can be built, when machine learning is made accessible to you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flobe%2Fflask-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flobe%2Fflask-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flobe%2Fflask-server/lists"}