FlameF0X commited on
Commit
8b657a5
Β·
verified Β·
1 Parent(s): e38b1c0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +281 -4
README.md CHANGED
@@ -11,9 +11,286 @@ pinned: false
11
  short_description: Streamlit template space
12
  ---
13
 
14
- # Welcome to Streamlit!
15
 
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
 
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  short_description: Streamlit template space
12
  ---
13
 
14
+ # πŸ€— ML Tracker - Free W&B Alternative
15
 
16
+ A free, open-source experiment tracking platform hosted on HuggingFace Spaces. Track your ML experiments with beautiful dashboards, all powered by HuggingFace infrastructure.
17
 
18
+ ## ✨ Features
19
+
20
+ - πŸ” **HuggingFace Authentication** - Connect with your HF token
21
+ - πŸ“Š **Interactive Dashboards** - Beautiful charts powered by Plotly
22
+ - πŸš€ **Easy API** - Simple Python client for logging metrics
23
+ - πŸ’Ύ **Free Storage** - Uses HuggingFace Hub for data persistence
24
+ - πŸ”„ **Real-time Updates** - Live dashboard updates
25
+ - πŸ“ˆ **Multiple Chart Types** - Line plots, scatter plots, histograms
26
+ - 🎯 **Experiment Comparison** - Compare multiple runs
27
+ - πŸ“‹ **Configuration Tracking** - Store and view experiment configs
28
+
29
+ ## πŸš€ Quick Start
30
+
31
+ ### 1. Deploy on HuggingFace Spaces
32
+
33
+ 1. Go to [HuggingFace Spaces](https://huggingface.co/new-space)
34
+ 2. Choose **Docker** as SDK
35
+ 3. Select **Streamlit** template
36
+ 4. Copy all the files from this repository
37
+ 5. Deploy your space
38
+
39
+ ### 2. Get Your API Key
40
+
41
+ 1. Visit your deployed space
42
+ 2. Connect with your HuggingFace token
43
+ 3. Copy your generated API key from the dashboard
44
+
45
+ ### 3. Install Client Library
46
+
47
+ ```bash
48
+ pip install requests
49
+ ```
50
+
51
+ ### 4. Start Tracking
52
+
53
+ ```python
54
+ from client import MLTracker
55
+
56
+ # Initialize tracker
57
+ tracker = MLTracker(
58
+ api_key="your-api-key-here",
59
+ base_url="https://your-space-name.hf.space"
60
+ )
61
+
62
+ # Start experiment
63
+ tracker.init("my_first_experiment", config={
64
+ "model": "ResNet50",
65
+ "dataset": "CIFAR-10",
66
+ "learning_rate": 0.001,
67
+ "batch_size": 32
68
+ })
69
+
70
+ # Log metrics during training
71
+ for epoch in range(100):
72
+ # Your training code here
73
+ loss = train_one_epoch()
74
+ accuracy = evaluate_model()
75
+
76
+ # Log to ML Tracker
77
+ tracker.log({
78
+ "loss": loss,
79
+ "accuracy": accuracy,
80
+ "epoch": epoch
81
+ })
82
+
83
+ # Finish experiment
84
+ tracker.finish()
85
+ ```
86
+
87
+ ## πŸ“ Project Structure
88
+
89
+ ```
90
+ ml-tracker/
91
+ β”œβ”€β”€ Dockerfile # HuggingFace Spaces Docker config
92
+ β”œβ”€β”€ requirements.txt # Python dependencies
93
+ β”œβ”€β”€ app.py # Main Streamlit dashboard
94
+ β”œβ”€β”€ api.py # FastAPI backend (optional)
95
+ β”œβ”€β”€ client.py # Python client library
96
+ └── README.md # This file
97
+ ```
98
+
99
+ ## πŸ”§ Configuration
100
+
101
+ ### Environment Variables
102
+
103
+ You can set these environment variables for easier usage:
104
+
105
+ ```bash
106
+ export ML_TRACKER_API_KEY="your-api-key"
107
+ export ML_TRACKER_BASE_URL="https://your-space-name.hf.space"
108
+ ```
109
+
110
+ ### HuggingFace Space Settings
111
+
112
+ In your Space settings, you can:
113
+ - Enable/disable public access
114
+ - Set custom domain
115
+ - Configure hardware (upgrade for better performance)
116
+
117
+ ## πŸ’‘ Usage Examples
118
+
119
+ ### Basic Usage
120
+
121
+ ```python
122
+ import mltracker
123
+
124
+ # Initialize with environment variables
125
+ mltracker.init("experiment_name", config={
126
+ "model": "BERT",
127
+ "dataset": "IMDB"
128
+ })
129
+
130
+ # Log metrics
131
+ mltracker.log({"loss": 0.5, "accuracy": 0.85})
132
+ mltracker.log({"loss": 0.3, "accuracy": 0.90})
133
+
134
+ # Finish
135
+ mltracker.finish()
136
+ ```
137
+
138
+ ### Advanced Usage
139
+
140
+ ```python
141
+ from client import MLTracker
142
+
143
+ tracker = MLTracker(api_key="...", base_url="...")
144
+
145
+ # Multiple experiments
146
+ for lr in [0.001, 0.01, 0.1]:
147
+ tracker.init(f"lr_{lr}", config={"learning_rate": lr})
148
+
149
+ for epoch in range(10):
150
+ # Training code
151
+ loss = train_with_lr(lr)
152
+ tracker.log({"loss": loss})
153
+
154
+ tracker.finish()
155
+
156
+ # Get experiment data
157
+ experiments = tracker.get_experiments()
158
+ for exp in experiments:
159
+ print(f"Experiment: {exp['experiment']}")
160
+ print(f"Steps: {exp['total_steps']}")
161
+ ```
162
+
163
+ ### PyTorch Integration
164
+
165
+ ```python
166
+ import torch
167
+ import torch.nn as nn
168
+ from client import MLTracker
169
+
170
+ # Initialize tracker
171
+ tracker = MLTracker(api_key="...", base_url="...")
172
+ tracker.init("pytorch_experiment", config={
173
+ "model": "ResNet18",
174
+ "optimizer": "Adam",
175
+ "learning_rate": 0.001
176
+ })
177
+
178
+ # Training loop
179
+ model = resnet18()
180
+ optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
181
+ criterion = nn.CrossEntropyLoss()
182
+
183
+ for epoch in range(100):
184
+ for batch_idx, (data, target) in enumerate(train_loader):
185
+ # Forward pass
186
+ output = model(data)
187
+ loss = criterion(output, target)
188
+
189
+ # Backward pass
190
+ optimizer.zero_grad()
191
+ loss.backward()
192
+ optimizer.step()
193
+
194
+ # Log metrics
195
+ if batch_idx % 100 == 0:
196
+ tracker.log({
197
+ "loss": loss.item(),
198
+ "epoch": epoch,
199
+ "batch": batch_idx
200
+ })
201
+
202
+ # Validation
203
+ val_accuracy = evaluate(model, val_loader)
204
+ tracker.log({"val_accuracy": val_accuracy})
205
+ ```
206
+
207
+ ## 🎨 Dashboard Features
208
+
209
+ ### Metrics Visualization
210
+ - **Line Charts** - Track metrics over time
211
+ - **Multi-metric Plots** - Compare different metrics
212
+ - **Real-time Updates** - Live dashboard refresh
213
+
214
+ ### Experiment Management
215
+ - **Experiment List** - View all your experiments
216
+ - **Configuration Viewer** - See experiment settings
217
+ - **Data Export** - Download raw data
218
+
219
+ ### Comparison Tools
220
+ - **Multi-experiment View** - Compare different runs
221
+ - **Metric Filtering** - Focus on specific metrics
222
+ - **Time Range Selection** - Zoom into specific periods
223
+
224
+ ## πŸ”’ Security
225
+
226
+ - **Token-based Auth** - Secure HuggingFace token authentication
227
+ - **API Key Management** - Unique API keys per user
228
+ - **Data Isolation** - Each user's data is separate
229
+ - **HTTPS Only** - All communication encrypted
230
+
231
+ ## πŸ› οΈ Development
232
+
233
+ ### Local Development
234
+
235
+ ```bash
236
+ # Clone repository
237
+ git clone https://github.com/yourusername/ml-tracker
238
+ cd ml-tracker
239
+
240
+ # Install dependencies
241
+ pip install -r requirements.txt
242
+
243
+ # Run locally
244
+ streamlit run app.py
245
+ ```
246
+
247
+ ### Contributing
248
+
249
+ 1. Fork the repository
250
+ 2. Create a feature branch
251
+ 3. Make your changes
252
+ 4. Submit a pull request
253
+
254
+ ## πŸ“š API Reference
255
+
256
+ ### MLTracker Class
257
+
258
+ ```python
259
+ class MLTracker:
260
+ def __init__(self, api_key: str, base_url: str)
261
+ def init(self, experiment_name: str, config: dict = None)
262
+ def log(self, metrics: dict, step: int = None)
263
+ def get_experiments(self) -> list
264
+ def get_experiment(self, name: str) -> dict
265
+ def delete_experiment(self, name: str)
266
+ def finish(self)
267
+ ```
268
+
269
+ ### Global Functions
270
+
271
+ ```python
272
+ def init(experiment_name: str, config: dict = None, api_key: str = None, base_url: str = None)
273
+ def log(metrics: dict, step: int = None)
274
+ def finish()
275
+ ```
276
+
277
+ ## 🀝 Support
278
+
279
+ - **Issues** - Report bugs on GitHub
280
+ - **Discussions** - Ask questions in GitHub Discussions
281
+ - **Documentation** - Check the wiki for detailed guides
282
+
283
+ ## πŸ“„ License
284
+
285
+ MIT License - See LICENSE file for details
286
+
287
+ ## πŸ™ Acknowledgments
288
+
289
+ - HuggingFace for providing free hosting
290
+ - Plotly for beautiful charts
291
+ - Streamlit for easy web apps
292
+ - The ML community for inspiration
293
+
294
+ ---
295
+
296
+ **Happy Experimenting!** πŸ§ͺ✨