Commit
Β·
1b858e0
1
Parent(s):
3f6eee9
chore: Write README file
Browse files- README.md +160 -1
- src/assets/app-demo.jpg +3 -0
README.md
CHANGED
|
@@ -12,4 +12,163 @@ short_description: A CNN-based image classification with TensorFlow
|
|
| 12 |
license: mit
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
license: mit
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# πΌοΈ Image Classification with ResNet50
|
| 16 |
+
|
| 17 |
+
## Table of Contents
|
| 18 |
+
|
| 19 |
+
1. [Project Description](#1-project-description)
|
| 20 |
+
2. [Methodology & Key Features](#2-methodology--key-features)
|
| 21 |
+
3. [Technology Stack](#3-technology-stack)
|
| 22 |
+
4. [Deployment Options](#4-deployment-options)
|
| 23 |
+
5. [Dataset](#5-dataset)
|
| 24 |
+
|
| 25 |
+
## 1. Project Description
|
| 26 |
+
|
| 27 |
+
This project implements an **image classification system** using a pre-trained **ResNet50 CNN** (trained on ImageNet with 1,000+ categories).
|
| 28 |
+
|
| 29 |
+
The repository includes **two versions**:
|
| 30 |
+
|
| 31 |
+
1. **Full Architecture (local, Dockerized):**
|
| 32 |
+
|
| 33 |
+
- Built as a **multi-service ML system** with FastAPI (backend inference), Redis (queue/cache), and Streamlit (frontend).
|
| 34 |
+
- Designed to demonstrate a scalable, production-like workflow.
|
| 35 |
+
|
| 36 |
+
2. **Lightweight Streamlit App (deployed):**
|
| 37 |
+
- Adapted into a **single Streamlit app** for cost-effective deployment on **Hugging Face Spaces**.
|
| 38 |
+
- Lets users upload an image and instantly see the **predicted category** with confidence.
|
| 39 |
+
|
| 40 |
+
This dual approach allows others to explore both a **realistic ML architecture** and a **lightweight, deployable demo**.
|
| 41 |
+
|
| 42 |
+
> [!IMPORTANT]
|
| 43 |
+
>
|
| 44 |
+
> - Check out the deployed app here: ποΈ [Image Classification App](https://huggingface.co/spaces/iBrokeTheCode/Image_Classifier_with_CNN) ποΈ
|
| 45 |
+
> - Check out the source code for multi-service setup: ποΈ [Multi-Service - Source Code](https://huggingface.co/spaces/iBrokeTheCode/Image_Classifier_with_CNN/tree/main) ποΈ
|
| 46 |
+
> - Check out the source code for lightweight Streamlit App: ποΈ [Lightweight App - Source Code](https://huggingface.co/spaces/iBrokeTheCode/Image_Classifier_with_CNN/tree/main/src) ποΈ
|
| 47 |
+
|
| 48 |
+

|
| 49 |
+
|
| 50 |
+
## 2. Methodology & Key Features
|
| 51 |
+
|
| 52 |
+
- **Model:** ResNet50 (pre-trained on **ImageNet** with 1,000+ classes).
|
| 53 |
+
- **Pipeline:** Input images are resized, normalized, and passed to the model.
|
| 54 |
+
- **Output:** Top-1 prediction with **confidence score** is displayed.
|
| 55 |
+
- **Multi-service architecture:**
|
| 56 |
+
- **FastAPI** serves inference requests.
|
| 57 |
+
- **Redis** handles caching and task queueing.
|
| 58 |
+
- **Streamlit** provides the interactive UI.
|
| 59 |
+
- **Lightweight deployment:** Direct **Streamlit-only** version for Hugging Face Spaces.
|
| 60 |
+
|
| 61 |
+
## 3. Technology Stack
|
| 62 |
+
|
| 63 |
+
This project was built using the following technologies:
|
| 64 |
+
|
| 65 |
+
**Deployment & Hosting:**
|
| 66 |
+
|
| 67 |
+
- [Docker](https://www.docker.com/) β containerization for the full architecture.
|
| 68 |
+
- [Hugging Face Spaces](https://huggingface.co/docs/hub/spaces) β for lightweight deployment.
|
| 69 |
+
- [Streamlit](https://streamlit.io/) β interactive web app frontend.
|
| 70 |
+
|
| 71 |
+
**Backend & Infrastructure:**
|
| 72 |
+
|
| 73 |
+
- [FastAPI](https://fastapi.tiangolo.com/) β high-performance inference API.
|
| 74 |
+
- [Redis](https://redis.io/) β caching and message queue.
|
| 75 |
+
|
| 76 |
+
**Modeling & Training:**
|
| 77 |
+
|
| 78 |
+
- [TensorFlow / Keras](https://www.tensorflow.org/) β ResNet50 model (pre-trained on ImageNet).
|
| 79 |
+
|
| 80 |
+
**Development Tools:**
|
| 81 |
+
|
| 82 |
+
- [Ruff](https://github.com/charliermarsh/ruff) β Python linter and formatter.
|
| 83 |
+
- [uv](https://github.com/astral-sh/uv) β fast Python package installer and resolver.
|
| 84 |
+
|
| 85 |
+
## 4. Deployment Options
|
| 86 |
+
|
| 87 |
+
You can run this project in two ways:
|
| 88 |
+
|
| 89 |
+
### A. Run the Lightweight Version (Streamlit-only)
|
| 90 |
+
|
| 91 |
+
1. Clone the repo:
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
git clone https://huggingface.co/spaces/iBrokeTheCode/Image_Classifier_with_CNN
|
| 95 |
+
|
| 96 |
+
cd Image_Classifier_with_CNN
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
2. Install dependencies:
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
pip install -r requirements.txt
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
3. Run the app:
|
| 106 |
+
|
| 107 |
+
```bash
|
| 108 |
+
streamlit run src/streamlit_app.py
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
### B. Run the Full Architecture (Dockerized)
|
| 112 |
+
|
| 113 |
+
The repository also contains **Dockerfiles** for each service.
|
| 114 |
+
|
| 115 |
+
1. Clone the repo:
|
| 116 |
+
|
| 117 |
+
```bash
|
| 118 |
+
git clone https://huggingface.co/spaces/iBrokeTheCode/Image_Classifier_with_CNN
|
| 119 |
+
|
| 120 |
+
cd Image_Classifier_with_CNN
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
2. Pre-configure your environment variables:
|
| 124 |
+
|
| 125 |
+
```bash
|
| 126 |
+
cp .env.original .env
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
3. Create a network for containers
|
| 130 |
+
|
| 131 |
+
```bash
|
| 132 |
+
docker network create shared_network
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
4. Build and start all services:
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
docker compose up --build -d
|
| 139 |
+
|
| 140 |
+
# Stop services
|
| 141 |
+
docker compose down
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
5. Populate the database
|
| 145 |
+
|
| 146 |
+
```bash
|
| 147 |
+
cd api
|
| 148 |
+
cp .env.original .env
|
| 149 |
+
docker-compose up --build -d
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
6. Access the app at:
|
| 153 |
+
|
| 154 |
+
```
|
| 155 |
+
http://localhost:9090
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
Then use this credentials to pass the login:
|
| 159 |
+
|
| 160 |
+
- Username: admin@example.com
|
| 161 |
+
- Password: admin
|
| 162 |
+
|
| 163 |
+
7. Access the FastAPI app at:
|
| 164 |
+
|
| 165 |
+
```
|
| 166 |
+
http://localhost:8000/docs
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
## 5. Dataset
|
| 170 |
+
|
| 171 |
+
This project uses the pre-training model ResNet50.
|
| 172 |
+
|
| 173 |
+
- **Model:** [ResNet50](https://www.tensorflow.org/api_docs/python/tf/keras/applications/ResNet50)
|
| 174 |
+
- **Classes:** 1,000+ categories (objects, animals, everyday items).
|
src/assets/app-demo.jpg
ADDED
|
Git LFS Details
|