Skip to content

Commit 8acc7cf

Browse files
committed
Finalize project structure, update URLs, and clean up for deployment
1 parent c815d3c commit 8acc7cf

19 files changed

+351
-326
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# GitHub Actions workflow for training and uploading models to Hugging Face Hub
2+
# Place this file in .github/workflows/train-and-upload.yml
3+
4+
name: Train and Upload Model to Hugging Face Hub
5+
6+
on:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
jobs:
12+
train-and-upload:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
lfs: true
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
pip install huggingface_hub tensorflowjs
30+
31+
- name: Train model (replace with your script)
32+
run: |
33+
python main.py # or your training script
34+
35+
- name: Convert Keras model to TensorFlow.js
36+
run: |
37+
tensorflowjs_converter --input_format=keras image_classifier.keras tfjs_model/
38+
39+
- name: Upload models to Hugging Face Hub
40+
env:
41+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
42+
run: |
43+
python scripts/upload_to_hub.py

.gitignore

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
debug.log
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Jupyter Notebook
52+
.ipynb_checkpoints
53+
54+
# pyenv
55+
.python-version
56+
57+
# mypy
58+
.mypy_cache/
59+
.dmypy.json
60+
61+
# VS Code
62+
.vscode/
63+
64+
# Local model artifacts
65+
model/
66+
models/
67+
tfjs_model/
68+
*.keras
69+
*.h5
70+
*.pt
71+
*.pth
72+
73+
# System files
74+
.DS_Store
75+
Thumbs.db

README.md

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
---
32
title: Multi-Object Detection using YOLO
43
emoji: 🦾
@@ -9,66 +8,18 @@ app_file: app.py
98
pinned: false
109
---
1110

12-
# Multi-Object Detection API (YOLO + CNN)
13-
14-
A FastAPI backend for multi-object detection and image classification using YOLOv8 and a custom CNN. Deployable on Hugging Face Spaces.
15-
16-
## API Endpoints
17-
18-
- **POST `/detect-object`**: Upload an image (form-data, key: `file`). Returns detected objects, their counts, and CNN class prediction.
19-
- **GET `/health`**: Health check endpoint. Returns `{ "status": "ok" }`.
20-
21-
## Deployment
22-
- All files (`app.py`, `requirements.txt`, `space.yaml`, `image_classifier.keras`, `yolov8n-seg.pt`) must be in the repo.
23-
- Deploy on Hugging Face Spaces with FastAPI SDK.
24-
25-
## Example (Python)
26-
```python
27-
import requests
28-
files = {'file': open('your_image.jpg', 'rb')}
29-
r = requests.post('https://your-space-url.hf.space/detect-object', files=files)
30-
print(r.json())
31-
```
32-
=======
3311
# Multi-Object Detection using YOLO and Custom CNN
3412

35-
This project performs real-time multi-object detection and image classification using YOLOv8 and a custom-trained CNN on CIFAR-10. It captures webcam video, detects objects, classifies images, and displays results live.
13+
A robust, cloud-ready multi-object detection system using FastAPI, YOLOv8, and a custom CNN. Supports MLOps, edge (browser) inference, and cloud deployment.
3614

37-
## Video Preview
38-
Original Video Speed: 0.5X
39-
40-
[![Demo Video](https://github.com/user-attachments/assets/22620da8-8508-4100-b455-af382fc313c5)](https://github.com/user-attachments/assets/22620da8-8508-4100-b455-af382fc313c5)
41-
42-
## Features
43-
- Real-time object detection using YOLOv8 segmentation
44-
- Image classification using a custom CNN trained on CIFAR-10
45-
- Live webcam video processing
46-
- Model saving and loading
47-
48-
## Requirements
49-
Install dependencies with:
50-
```bash
51-
pip install -r requirements.txt
52-
```
15+
- **Backend:** FastAPI (`app.py`)
16+
- **Frontend:** TensorFlow.js demo (`tfjs_demo/index.html`)
17+
- **Model Hub:** [Hugging Face Model Repo](https://huggingface.co/harithkavish/SkinNet-Analyzer)
18+
- **Spaces Demo:** [Hugging Face Spaces](https://huggingface.co/spaces/harithkavish/Multi-Object-Detection-using-YOLO)
5319

5420
## Usage
55-
1. Clone the repository and navigate to the project folder.
56-
2. Ensure you have a webcam connected.
57-
3. Run the main script:
58-
```bash
59-
python main.py
60-
```
61-
4. Follow the prompts to train the model and start detection.
62-
5. Press 'q' to quit the video window.
21+
- Run the backend: `uvicorn app:app`
22+
- Try the browser demo: open `tfjs_demo/index.html`
23+
- See `.github/workflows/train-and-upload.yml` for CI/CD
6324

64-
## Files
65-
- `main.py`: Main script for training and detection
66-
- `yolov8n-seg.pt`: YOLOv8 model weights
67-
- `image_classifier.keras`: Saved CNN model
68-
- `requirements.txt`: Python dependencies
69-
70-
## Contributors
71-
- Harith Kavish S
72-
- Sharwan Krishnan P
73-
- Sanjay R
74-
>>>>>>> 1c3894d2065701b19ab2a500433a6d7f7a075d13
25+
---

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# Load CNN model
2727
try:
28-
keras_model_path = hf_hub_download(repo_id="harithkavish/multi-object-detection-models", filename="image_classifier.keras")
28+
keras_model_path = hf_hub_download(repo_id="harithkavish/SkinNet-Analyzer", filename="image_classifier.keras")
2929
cnn_model = keras.models.load_model(keras_model_path)
3030
except Exception as e:
3131
from tensorflow import keras as keras_build
@@ -114,7 +114,7 @@ def patched_load(*args, **kwargs):
114114

115115
# Load YOLOv8 model robustly
116116
try:
117-
yolo_model_path = hf_hub_download(repo_id="harithkavish/multi-object-detection-models", filename="yolov8n-seg.pt")
117+
yolo_model_path = hf_hub_download(repo_id="harithkavish/SkinNet-Analyzer", filename="yolov8n-seg.pt")
118118
yolo_model = load_yolo_model(yolo_model_path)
119119
except Exception as e:
120120
print('Error in YOLO model loading logic:', e)

docs/index.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/script.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

docs/style.css

Lines changed: 0 additions & 41 deletions
This file was deleted.

index.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)