{"id":28864640,"url":"https://github.com/alihassanml/illegal-activity-detection","last_synced_at":"2026-05-11T09:28:56.468Z","repository":{"id":273394751,"uuid":"919561939","full_name":"alihassanml/Illegal-Activity-Detection","owner":"alihassanml","description":"This project is a YOLO (You Only Look Once) object detection system built using FastAPI. It provides real-time predictions and visualizations, leveraging the YOLO model for detecting specific activities or objects. This project is developed for a final-year academic project.","archived":false,"fork":false,"pushed_at":"2025-05-19T06:43:03.000Z","size":35002,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T07:41:16.485Z","etag":null,"topics":["fastapi","opencv","yolo"],"latest_commit_sha":null,"homepage":"","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/alihassanml.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-20T16:08:20.000Z","updated_at":"2025-05-19T06:43:48.000Z","dependencies_parsed_at":"2025-05-19T07:49:39.974Z","dependency_job_id":null,"html_url":"https://github.com/alihassanml/Illegal-Activity-Detection","commit_stats":null,"previous_names":["alihassanml/yolo-final-year-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alihassanml/Illegal-Activity-Detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alihassanml%2FIllegal-Activity-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alihassanml%2FIllegal-Activity-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alihassanml%2FIllegal-Activity-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alihassanml%2FIllegal-Activity-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alihassanml","download_url":"https://codeload.github.com/alihassanml/Illegal-Activity-Detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alihassanml%2FIllegal-Activity-Detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260915905,"owners_count":23082041,"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":["fastapi","opencv","yolo"],"created_at":"2025-06-20T09:08:50.819Z","updated_at":"2026-03-03T12:44:16.850Z","avatar_url":"https://github.com/alihassanml.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# YOLO-Based Object Detection with FastAPI - Final Year Project\n![image](frontend.png)\n![image2](./predict/drinking.png)\n\nThis project is a YOLO (You Only Look Once) object detection system built using FastAPI. It provides real-time predictions and visualizations, leveraging the YOLO model for detecting specific activities or objects. This project is developed for a final-year academic project.\n\n## Features\n\n- **Object Detection:** Predict objects in uploaded images using a custom YOLO model (`best5.pt`).\n- **Custom Trained Classes:** Detects the following classes:\n  - Drinking\n  - Eating\n  - Violence\n  - Sleeping\n  - Smoking\n  - Walking\n  - Weapon\n- **Real-Time Prediction API:** Upload images and get annotated predictions with bounding boxes and confidence scores.\n- **Database Storage:** Stores prediction results (class name, accuracy, and timestamp) in a database.\n- **Data Visualization:** View class-wise prediction counts in a bar chart.\n\n## Technology Stack\n\n- **Backend Framework:** FastAPI\n- **Model:** YOLO (Ultralytics)\n- **Database:** SQLAlchemy with SQLite\n- **Frontend:** Jinja2 Templates, HTML, CSS, JavaScript (Bootstrap, Chart.js)\n\n## How to Run the Project\n\n### Prerequisites\n\n1. Python 3.8+ installed.\n2. Install dependencies using the `requirements.txt` file.\n\n### Steps to Run\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/alihassanml/Yolo-Final-Year-Project.git\n   cd Yolo-Final-Year-Project\n   ```\n\n2. Create and activate a virtual environment:\n   ```bash\n   python -m venv venv\n   source venv/bin/activate    # On Linux/Mac\n   venv\\Scripts\\activate       # On Windows\n   ```\n\n3. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n4. Start the FastAPI server:\n   ```bash\n   uvicorn app:app --reload\n   ```\n\n5. Open your browser and navigate to:\n   ```\n   http://127.0.0.1:8000\n   ```\n\n6. Use the web interface to upload images and view predictions.\n\n### API Endpoints\n\n- `GET /`  \n  Returns the homepage.\n\n- `POST /predict`  \n  Upload an image and receive predictions with annotated bounding boxes.\n\n- `GET /predictions`  \n  Retrieve a list of all predictions stored in the database.\n\n- `GET /class-counts`  \n  Get class-wise counts of predictions for visualization.\n\n## Project Structure\n\n```\nYolo-Final-Year-Project/\n│\n├── app.py                 # Main FastAPI application\n├── model/\n│   ├── best5.pt           # YOLO pre-trained model weights\n│   └── __init__.py        # Package initialization\n│\n├── database.py            # Database configuration\n├── model.py               # SQLAlchemy models\n├── static/\n│   ├── style.css          # CSS for styling\n│   ├── script.js          # JavaScript functionality\n│   └── uploads/           # Uploaded images folder\n│\n├── templates/\n│   └── index.html         # Jinja2 template for the frontend\n│\n├── requirements.txt       # Python dependencies\n├── README.md              # Project documentation\n└── .gitignore             # Files to ignore in the repository\n```\n\n## Future Enhancements\n\n- Add video-based detection for live streams.\n- Integrate a user authentication system for secure access.\n- Expand the model to detect additional classes.\n- Include export functionality for predictions (e.g., CSV or Excel).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n### Author\n\nDeveloped by [Ali Hassan](https://github.com/alihassanml). For questions or feedback, feel free to reach out.\n```\n\n---\n\n### `requirements.txt`\n\n```plaintext\nfastapi==0.95.2\nuvicorn==0.23.0\nsqlalchemy==2.0.21\njinja2==3.1.2\npydantic==2.0.3\nopencv-python==4.8.0.74\nnumpy==1.24.3\nultralytics==8.0.30\nPillow==9.5.0\nchart.js==3.9.1\n```\n\n---\n\n### Steps to Upload to GitHub\n\n1. Save the `README.md` and `requirements.txt` in the root directory of your project.\n2. Commit and push the changes to your GitHub repository:\n   ```bash\n   git add README.md requirements.txt\n   git commit -m \"Added README and requirements.txt for FastAPI-based YOLO project\"\n   git push origin main\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falihassanml%2Fillegal-activity-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falihassanml%2Fillegal-activity-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falihassanml%2Fillegal-activity-detection/lists"}