gouravshah commited on
Commit
251fdfe
Β·
1 Parent(s): 62af38c

updated README for building and deploying the project along with hugging face metadata

Browse files
Files changed (1) hide show
  1. README.md +188 -2
README.md CHANGED
@@ -1,2 +1,188 @@
1
- # tech-stack-advisor
2
- Tech Stack Advisor Sample ML App
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Tech Stack Advisor
3
+ emoji: 🧠
4
+ colorFrom: indigo
5
+ colorTo: pink
6
+ sdk: docker
7
+ app_file: app.py
8
+ pinned: false
9
+ license: apache-2.0
10
+ duplicable: true
11
+ ---
12
+
13
+ # 🧠 Tech Stack Advisor – ML App (with Docker & Hugging Face Deployment)
14
+
15
+ **Tech Stack Advisor** is a hands-on machine learning project designed to teach you how to build, containerize, and deploy an ML-powered web application using Docker and Hugging Face Spaces.
16
+
17
+ > 🎯 This project is part of the **"Artificial Intelligence and Machine Learning (AI/ML) with Docker"** course from **School of DevOps**.
18
+
19
+ ---
20
+
21
+ ## πŸš€ What You'll Learn
22
+
23
+ - Build and train a simple ML model using `scikit-learn`
24
+ - Create a UI using `Gradio`
25
+ - Containerize your app using a Dockerfile
26
+ - Push your Docker image to Docker Hub
27
+ - Deploy the Dockerized app on Hugging Face Spaces (free tier)
28
+
29
+ ---
30
+
31
+ ## πŸ“ Project Structure
32
+
33
+ ```
34
+
35
+ tech-stack-advisor/
36
+ β”œβ”€β”€ app.py # Gradio web app
37
+ β”œβ”€β”€ train.py # Script to train and save ML model
38
+ β”œβ”€β”€ requirements.txt # Python dependencies
39
+ β”œβ”€β”€ Dockerfile # Docker build file (added during the lab)
40
+ β”œβ”€β”€ model.pkl # Trained ML model (generated after training)
41
+ β”œβ”€β”€ encoders.pkl # Encoders for categorical inputs (generated after training)
42
+ β”œβ”€β”€ LICENSE # Apache 2.0 license
43
+ └── README.md # This guide
44
+
45
+ ````
46
+
47
+ ---
48
+
49
+ ## 🧠 Step 1: Setup and Train Your ML Model
50
+
51
+ 1. **Clone the repository**
52
+
53
+ ```bash
54
+ git clone https://github.com/<your-username>/tech-stack-advisor.git
55
+ cd tech-stack-advisor
56
+ ````
57
+
58
+ 2. **Install dependencies**
59
+
60
+ (Optional: Use a virtual environment)
61
+
62
+ ```bash
63
+ pip install -r requirements.txt
64
+ ```
65
+
66
+ 3. **Train the model**
67
+
68
+ ```bash
69
+ python train.py
70
+ ```
71
+
72
+ This creates:
73
+
74
+ * `model.pkl`: the trained ML model
75
+ * `encoders.pkl`: label encoders for input/output features
76
+
77
+ ---
78
+
79
+ ## πŸ–₯️ Step 2: Run the App Locally (Without Docker)
80
+
81
+ ```bash
82
+ python app.py
83
+ ```
84
+
85
+ Visit the app in your browser at:
86
+
87
+ ```
88
+ http://localhost:7860
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 🐳 Step 3: Add Docker Support
94
+
95
+ Create a file named `Dockerfile` in the root of the project:
96
+
97
+ ```dockerfile
98
+ FROM python:3.11-slim
99
+
100
+ WORKDIR /app
101
+
102
+ COPY requirements.txt .
103
+ RUN pip install --no-cache-dir -r requirements.txt
104
+
105
+ COPY . .
106
+
107
+ EXPOSE 7860
108
+
109
+ CMD ["python", "app.py"]
110
+ ```
111
+
112
+ ---
113
+
114
+ ## πŸ”§ Step 4: Build and Run the Docker Container
115
+
116
+ 1. **Build the image**
117
+
118
+ ```bash
119
+ docker build -t tech-stack-advisor .
120
+ ```
121
+
122
+ 2. **Run the container**
123
+
124
+ ```bash
125
+ docker run -p 7860:7860 tech-stack-advisor
126
+ ```
127
+
128
+ Visit: `http://localhost:7860`
129
+
130
+ ---
131
+
132
+ ## ☁️ Step 5: Publish to Docker Hub
133
+
134
+ 1. **Login to Docker Hub**
135
+
136
+ ```bash
137
+ docker login
138
+ ```
139
+
140
+ 2. **Tag the image**
141
+
142
+ ```bash
143
+ docker tag tech-stack-advisor <your-dockerhub-username>/tech-stack-advisor:latest
144
+ ```
145
+
146
+ 3. **Push it**
147
+
148
+ ```bash
149
+ docker push <your-dockerhub-username>/tech-stack-advisor:latest
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 🌐 Step 6: Deploy to Hugging Face Spaces
155
+
156
+ 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
157
+ 2. Click **Create New Space**
158
+ 3. Select:
159
+
160
+ * **SDK**: Docker
161
+ * **Repository**: Link to your GitHub repo with the Dockerfile
162
+ 4. Hugging Face will auto-build and deploy your container.
163
+
164
+ ---
165
+
166
+ ## πŸ§ͺ Test Your Skills
167
+
168
+ * Can you swap the model in `train.py` for a `LogisticRegression` model?
169
+ * Can you add logging to show which inputs were passed?
170
+ * Try changing the Gradio layout or theme!
171
+
172
+ ---
173
+
174
+ ## 🧾 License
175
+
176
+ This project is licensed under the **Apache License 2.0**.
177
+ See the [LICENSE](./LICENSE) file for details.
178
+
179
+ ---
180
+
181
+ ## πŸ™Œ Credits
182
+
183
+ Created by \[Your Name] as part of the **AI/ML with Docker** course at **School of DevOps**.
184
+
185
+ ---
186
+
187
+ > πŸ›  Happy shipping, DevOps builders!
188
+