RaheelShah commited on
Commit
496fb01
Β·
1 Parent(s): 6538f2b

Upload Push

Browse files
Files changed (8) hide show
  1. .dockerignore +36 -0
  2. .python-version +1 -0
  3. Dockerfile +41 -0
  4. README.md +160 -0
  5. pyproject.toml +10 -0
  6. requirements.txt +0 -0
  7. streamlit_app.py +1 -1
  8. uv.lock +0 -0
.dockerignore ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ venv/
9
+ ENV/
10
+ .venv
11
+
12
+ # Docker
13
+ Dockerfile
14
+ .dockerignore
15
+
16
+ # Git
17
+ .git
18
+ .gitignore
19
+
20
+ # IDE
21
+ .vscode
22
+ .idea
23
+ *.swp
24
+ *.swo
25
+ *~
26
+
27
+ # Project specific
28
+ uv.lock
29
+ mobilenet_v2_1.0_224.tflite
30
+ main.py
31
+ README.md
32
+
33
+ # OS
34
+ .DS_Store
35
+ Thumbs.db
36
+
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.12
Dockerfile ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.13.5-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies required for OpenCV and MediaPipe
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ git \
10
+ libglib2.0-0 \
11
+ libsm6 \
12
+ libxext6 \
13
+ libxrender-dev \
14
+ libgomp1 \
15
+ libglib2.0-0 \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Set Streamlit configuration
19
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
20
+
21
+ # Copy requirements and install Python dependencies
22
+ COPY requirements.txt ./
23
+ RUN pip3 install --no-cache-dir -r requirements.txt
24
+
25
+ # Copy application files
26
+ COPY streamlit_app.py ./
27
+ COPY classifier.tflite ./
28
+
29
+ # Copy optional images folder if it exists
30
+ COPY images/ ./images/
31
+
32
+ # Expose Streamlit port
33
+ EXPOSE 8501
34
+
35
+ # Health check
36
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
37
+
38
+ # Run the Streamlit app
39
+ ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
40
+
41
+
README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: E-Commerce Image Classifier
3
+ emoji: πŸ›’
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 8501
8
+ tags:
9
+ - streamlit
10
+ license: apache-2.0
11
+ ---
12
+
13
+ # E-Commerce Image Classifier πŸ›’
14
+
15
+ An intelligent image classification application powered by MediaPipe and Streamlit that automatically categorizes e-commerce product images using a pre-trained deep learning model.
16
+
17
+ ## 🌟 Features
18
+
19
+ - **Real-time Image Classification**: Upload images and get instant classification results
20
+ - **Batch Processing**: Upload multiple images or entire directories
21
+ - **Interactive Navigation**: Browse through multiple images with intuitive arrow controls
22
+ - **Customizable Results**: Choose how many classification results to display (1-5)
23
+ - **Confidence Scores**: Visual progress bars showing prediction confidence
24
+ - **Modern UI**: Clean, responsive interface optimized for all screen sizes
25
+ - **Pre-loaded Samples**: Default images available for quick testing
26
+
27
+ ## πŸš€ Live Demo
28
+
29
+ Try the live demo on Hugging Face Spaces: [Your Space URL]
30
+
31
+ ## 🎯 How to Use
32
+
33
+ 1. **Upload Images**:
34
+ - Choose between "Directory" mode to upload a folder of images
35
+ - Or "Select Images" mode to pick individual files
36
+
37
+ 2. **View Results**:
38
+ - See the original image on the left
39
+ - Classification results with confidence scores on the right
40
+
41
+ 3. **Navigate**:
42
+ - Use arrow buttons (⬅️ ➑️) to browse through multiple images
43
+ - Current image counter shows your position in the gallery
44
+
45
+ 4. **Customize**:
46
+ - Adjust "Number of classes to display" in the sidebar (1-5)
47
+ - View top predictions based on your preference
48
+
49
+ ## πŸ› οΈ Tech Stack
50
+
51
+ - **Frontend**: Streamlit
52
+ - **ML Framework**: MediaPipe
53
+ - **Computer Vision**: OpenCV
54
+ - **Model**: Pre-trained TFLite classifier (ImageNet 1000 categories)
55
+ - **Language**: Python 3.12+
56
+
57
+ ## πŸ“¦ Installation
58
+
59
+ ### Local Setup
60
+
61
+ ```bash
62
+ # Clone the repository
63
+ git clone <your-repo-url>
64
+ cd Image_Classifier
65
+
66
+ # Install dependencies
67
+ pip install -r requirements.txt
68
+
69
+ # Run the application
70
+ streamlit run streamlit_app.py
71
+ ```
72
+
73
+ ### Docker Deployment
74
+
75
+ ```bash
76
+ # Build the Docker image
77
+ docker build -t image-classifier .
78
+
79
+ # Run the container
80
+ docker run -p 8501:8501 image-classifier
81
+
82
+ # Access at http://localhost:8501
83
+ ```
84
+
85
+ ## πŸ€— Deploy on Hugging Face Spaces
86
+
87
+ 1. **Create a new Space**:
88
+ - Go to [Hugging Face Spaces](https://huggingface.co/spaces)
89
+ - Click "Create new Space"
90
+ - Select "Streamlit" as the SDK
91
+
92
+ 2. **Upload your files**:
93
+ - `streamlit_app.py`
94
+ - `requirements.txt`
95
+ - `classifier.tflite`
96
+ - `images/` folder (optional)
97
+ - `README.md`
98
+
99
+ 3. **Configure**:
100
+ - The app will automatically deploy using the settings in this README's header
101
+ - Wait for the build to complete
102
+ - Your app will be live!
103
+
104
+ ## πŸ“‹ Requirements
105
+
106
+ ```
107
+ streamlit>=1.51.0
108
+ opencv-python-headless
109
+ mediapipe>=0.10.21
110
+ ```
111
+
112
+ ## ⚠️ Known Limitations
113
+
114
+ - Uses pre-trained MediaPipe general classifier
115
+ - Limited to 1000 ImageNet categories
116
+ - Not customized for specific product domains
117
+ - Maximum 10MB per image
118
+ - Best results with clear, single-subject images
119
+
120
+ ## πŸ’‘ Tips for Best Results
121
+
122
+ - Use clear, well-lit images
123
+ - Single subject per image works best
124
+ - Avoid ambiguous or complex scenes
125
+ - Common objects and scenes perform better
126
+ - Good focus and resolution recommended
127
+
128
+ ## πŸ”§ Model Information
129
+
130
+ - **Model**: MediaPipe Image Classifier
131
+ - **Format**: TensorFlow Lite (.tflite)
132
+ - **Categories**: 1000 ImageNet classes
133
+ - **Input Size**: Variable (automatically resized to 450x300 for display)
134
+ - **Architecture**: MobileNet-based
135
+
136
+ ## πŸ“„ License
137
+
138
+ This project is licensed under the MIT License - see the LICENSE file for details.
139
+
140
+ ## πŸ™ Credits
141
+
142
+ **Developed by [Techtics.ai](https://techtics.ai)**
143
+
144
+ Built with:
145
+ - [MediaPipe](https://mediapipe.dev/) by Google
146
+ - [Streamlit](https://streamlit.io/)
147
+ - [OpenCV](https://opencv.org/)
148
+
149
+ ## πŸ› Issues and Contributions
150
+
151
+ Found a bug or want to contribute? Please open an issue or submit a pull request on [GitHub](https://github.com/travelmateen/image-classification-ecommerce).
152
+
153
+ ## πŸ“§ Contact
154
+
155
+ For questions or collaborations, visit [Techtics.ai](https://techtics.ai)
156
+
157
+ ---
158
+
159
+ Made with ❀️ by Techtics.ai
160
+
pyproject.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "image-classifier"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "mediapipe>=0.10.21",
9
+ "streamlit>=1.51.0",
10
+ ]
requirements.txt ADDED
Binary file (90 Bytes). View file
 
streamlit_app.py CHANGED
@@ -45,7 +45,7 @@ st.title("E-Commerce Image Classifier")
45
  st.write(
46
  "Try uploading an image or a folder to see automatic classification results. "
47
  "You can navigate between images using the arrow buttons below. "
48
- "This project is open source β€” check it out on [GitHub](https://github.com/travelmateen/ImageClassifier). πŸš€"
49
  )
50
  st.markdown("<style> div[data-testid='stStatusWidget']{display:none}</style>", unsafe_allow_html=True)
51
 
 
45
  st.write(
46
  "Try uploading an image or a folder to see automatic classification results. "
47
  "You can navigate between images using the arrow buttons below. "
48
+ "This project is open source β€” check it out on [GitHub](https://github.com/travelmateen/image-classification-ecommerce). πŸš€"
49
  )
50
  st.markdown("<style> div[data-testid='stStatusWidget']{display:none}</style>", unsafe_allow_html=True)
51
 
uv.lock ADDED
The diff for this file is too large to render. See raw diff