{"id":24917031,"url":"https://github.com/codernayeem/agro-care-flask","last_synced_at":"2026-05-08T14:15:52.639Z","repository":{"id":267487285,"uuid":"900380006","full_name":"codernayeem/agro-care-flask","owner":"codernayeem","description":"API Server for Plant Disease Prediction through leaf scanning","archived":false,"fork":false,"pushed_at":"2024-12-22T12:07:10.000Z","size":7993,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T22:37:49.070Z","etag":null,"topics":["agriculture","api","api-rest","deep-learning","flask","machine-learning","python","ultralytics","yolov8"],"latest_commit_sha":null,"homepage":"","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/codernayeem.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":"2024-12-08T16:22:37.000Z","updated_at":"2025-01-07T13:35:44.000Z","dependencies_parsed_at":"2025-02-02T08:30:52.467Z","dependency_job_id":"87a82f64-fb53-4310-a64a-cc93471afdbf","html_url":"https://github.com/codernayeem/agro-care-flask","commit_stats":null,"previous_names":["codernayeem/agro-care-flask"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codernayeem/agro-care-flask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codernayeem%2Fagro-care-flask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codernayeem%2Fagro-care-flask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codernayeem%2Fagro-care-flask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codernayeem%2Fagro-care-flask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codernayeem","download_url":"https://codeload.github.com/codernayeem/agro-care-flask/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codernayeem%2Fagro-care-flask/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32783722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["agriculture","api","api-rest","deep-learning","flask","machine-learning","python","ultralytics","yolov8"],"created_at":"2025-02-02T08:30:43.445Z","updated_at":"2026-05-08T14:15:52.624Z","avatar_url":"https://github.com/codernayeem.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask YOLO Prediction API\n\nThis project is a Flask-based API that performs image-based disease predictions using YOLO models for three crops: tomato, potato, and corn. The API allows users to upload images and specify the crop type to receive detailed predictions about the class and confidence level of the detected object.\n\n## Features\n- **YOLO-based Prediction**: Supports three pre-trained YOLO models for tomato, potato, and corn disease detection.\n- **Image Handling**: Accepts image uploads via POST requests.\n- **Dynamic Cropping**: Allows optional cropping of images before processing.\n- **Detailed Results**: Provides predicted class, confidence score, and additional details based on the crop type.\n- **File Storage**: Saves uploaded images in a designated `save` folder.\n\n## Requirements\n- Python 3.8+\n- Flask\n- Ultralytics (for YOLO models)\n- PIL (for image cropping)\n- NumPy\n\n## Setup\n1. Clone the repository.\n   ```bash\n   git clone https://github.com/codernayeem/agro-care-flask.git\n   cd agro-care-flask\n   ```\n2. Install the dependencies (you may use a virtual environment):\n   ```bash\n   pip install flask ultralytics pillow numpy\n   ```\n3. Ensure the required files and folders exist:\n   - `data.json`: Contains additional details for each crop class.\n   - `model/tomato.pt`, `model/potato.pt`, `model/corn.pt`: Pre-trained YOLO model files.\n   - Create a `save` folder in the root directory (if not already created).\n\n## Usage\n### Starting the Server\nRun the application with:\n```bash\npython app.py\n```\nThe server will start on `http://\u003cyour-local-ip\u003e:4000`. \n\nThe main purpose of this repository is to serve the machine learning model for the Agro Care app. The API endpoint will be stored in Firebase Cloud Firestore, from where the app will retrieve and call it. \n\nFor more information about the app, visit the [Agro Care App repository](https://github.com/codernayeem/agro-care-app).\n\n\n### API Endpoints\n#### `POST /predict`\nThis endpoint accepts an image file and processes it using the specified model.\n\n**Request Parameters**:\n- **file** (form-data): The image file to be processed.\n- **model_index** (form-data): Integer value (0 for tomato, 1 for potato, 2 for corn).\n- **src** (form-data, optional): Specify the source of the image (`gallery` or `camera`). Default is `gallery`.\n- **cropWidth** (form-data, optional): Specify the cropping width for the image (used if `src` is `camera`).\n\n**Example Request**:\n```bash\ncurl -X POST http://\u003cyour-local-ip\u003e:4000/predict \\\n-F \"file=@/path/to/image.jpg\" \\\n-F \"model_index=0\" \\\n-F \"src=camera\" \\\n-F \"cropWidth=300\"\n```\n\n**Response**:\nReturns a JSON object containing:\n- `plant`: The crop type (e.g., \"tomato\").\n- `class`: Predicted class label.\n- `class_index`: Index of the predicted disease.\n- `confidence`: Confidence score of the prediction.\n- `details`: Additional information about the predicted disease.\n\n## Project Structure\n```\n.\n├── app.py             # Main Flask application\n├── data.json          # Contains crop-specific class details\n├── model              # Folder containing YOLO model files\n│   ├── tomato.pt\n│   ├── potato.pt\n│   └── corn.pt\n└── save               # Folder to store uploaded images\n```\n\n## Notes\n- Ensure `data.json` contains appropriate mappings for the `details` field for each crop and class (disease).\n- The models should be pre-trained YOLO models compatible with the `ultralytics` library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodernayeem%2Fagro-care-flask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodernayeem%2Fagro-care-flask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodernayeem%2Fagro-care-flask/lists"}