Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,128 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Milk Spoilage Classifier - Multi-Variant API
|
| 3 |
+
emoji: π₯
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Milk Spoilage Classification API - Multi-Variant
|
| 12 |
+
|
| 13 |
+
AI-powered milk spoilage classification with **10 specialized model variants** optimized for different data availability scenarios.
|
| 14 |
+
|
| 15 |
+
## π Features
|
| 16 |
+
|
| 17 |
+
- **10 Model Variants** with test accuracies from 62.8% to 95.8%
|
| 18 |
+
- **Automatic Feature Validation** - API validates required features for each variant
|
| 19 |
+
- **RESTful API** with comprehensive OpenAPI documentation
|
| 20 |
+
- **Custom GPT Ready** - Designed for seamless ChatGPT integration
|
| 21 |
+
|
| 22 |
+
## π Available Model Variants
|
| 23 |
+
|
| 24 |
+
| Rank | Variant | Test Accuracy | Features Required |
|
| 25 |
+
|------|---------|---------------|-------------------|
|
| 26 |
+
| π₯ | baseline | **95.8%** | All 6 features |
|
| 27 |
+
| π₯ | scenario_1_days14_21 | **94.2%** | Days 14 & 21 (SPC+TGN) |
|
| 28 |
+
| π₯ | scenario_3_day21 | **93.7%** | Day 21 only (SPC+TGN) |
|
| 29 |
+
| 4 | scenario_4_day14 | 87.4% | Day 14 only (SPC+TGN) |
|
| 30 |
+
| 5 | scenario_2_days7_14 | 87.3% | Days 7 & 14 (SPC+TGN) |
|
| 31 |
+
| 6 | scenario_6_spc_all | 78.3% | SPC only (All Days) |
|
| 32 |
+
| 7 | scenario_8_spc_7_14 | 73.3% | SPC only (Days 7 & 14) |
|
| 33 |
+
| 8 | scenario_9_tgn_7_14 | 73.1% | TGN only (Days 7 & 14) |
|
| 34 |
+
| 9 | scenario_7_tgn_all | 69.9% | TGN only (All Days) |
|
| 35 |
+
| 10 | scenario_5_day7 | 62.8% | Day 7 only (SPC+TGN) |
|
| 36 |
+
|
| 37 |
+
## π§ API Endpoints
|
| 38 |
+
|
| 39 |
+
### `GET /variants`
|
| 40 |
+
List all available model variants with metadata
|
| 41 |
+
|
| 42 |
+
### `POST /predict`
|
| 43 |
+
Make a prediction using the specified model variant
|
| 44 |
+
|
| 45 |
+
**Example Request:**
|
| 46 |
+
```json
|
| 47 |
+
{
|
| 48 |
+
"spc_d7": 2.1,
|
| 49 |
+
"spc_d14": 4.7,
|
| 50 |
+
"spc_d21": 6.4,
|
| 51 |
+
"tgn_d7": 1.0,
|
| 52 |
+
"tgn_d14": 3.7,
|
| 53 |
+
"tgn_d21": 5.3,
|
| 54 |
+
"model_variant": "baseline"
|
| 55 |
+
}
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
**Example Response:**
|
| 59 |
+
```json
|
| 60 |
+
{
|
| 61 |
+
"prediction": "PPC",
|
| 62 |
+
"probabilities": {
|
| 63 |
+
"PPC": 0.97,
|
| 64 |
+
"no spoilage": 0.02,
|
| 65 |
+
"spore spoilage": 0.01
|
| 66 |
+
},
|
| 67 |
+
"confidence": 0.97,
|
| 68 |
+
"variant_used": {
|
| 69 |
+
"variant_id": "baseline",
|
| 70 |
+
"name": "Baseline (All Features)",
|
| 71 |
+
"test_accuracy": 0.9576,
|
| 72 |
+
"features": ["SPC_D7", "SPC_D14", "SPC_D21", "TGN_D7", "TGN_D14", "TGN_D21"]
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## π Spoilage Classes
|
| 78 |
+
|
| 79 |
+
| Class | Description |
|
| 80 |
+
|-------|-------------|
|
| 81 |
+
| **PPC** | Post-Pasteurization Contamination - Bacteria introduced after pasteurization |
|
| 82 |
+
| **no spoilage** | No significant spoilage detected |
|
| 83 |
+
| **spore spoilage** | Heat-resistant spore-forming bacteria survived pasteurization |
|
| 84 |
+
|
| 85 |
+
## π Interactive Documentation
|
| 86 |
+
|
| 87 |
+
Visit `/docs` for interactive Swagger UI documentation where you can test the API directly.
|
| 88 |
+
|
| 89 |
+
## π» Usage Example
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
curl -X POST https://chenhaoq87-milkspoilageclassifier-api-variants.hf.space/predict \
|
| 93 |
+
-H "Content-Type: application/json" \
|
| 94 |
+
-d '{
|
| 95 |
+
"spc_d21": 6.4,
|
| 96 |
+
"tgn_d21": 5.3,
|
| 97 |
+
"model_variant": "scenario_3_day21"
|
| 98 |
+
}'
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## π€ Custom GPT Integration
|
| 102 |
+
|
| 103 |
+
This API is designed for Custom GPT integration. The GPT will automatically select the best variant based on available data.
|
| 104 |
+
|
| 105 |
+
See the [Custom GPT Setup Guide](https://huggingface.co/chenhaoq87/MilkSpoilageClassifier/blob/main/docs/CUSTOM_GPT_SETUP_MULTIVARIANT.md) for complete integration instructions.
|
| 106 |
+
|
| 107 |
+
## π Input Format
|
| 108 |
+
|
| 109 |
+
All microbial count values should be in **log CFU/mL (base 10)**:
|
| 110 |
+
- **SPC** (Standard Plate Count): Total bacterial count
|
| 111 |
+
- **TGN** (Total Gram-Negative): Gram-negative bacteria count
|
| 112 |
+
- Measured at **Day 7, 14, and 21**
|
| 113 |
+
|
| 114 |
+
## π Variant Selection Guide
|
| 115 |
+
|
| 116 |
+
- **Have all measurements?** β Use `baseline` (best accuracy)
|
| 117 |
+
- **Only Day 21 data?** β Use `scenario_3_day21` (nearly as good!)
|
| 118 |
+
- **Only Day 14 data?** β Use `scenario_4_day14`
|
| 119 |
+
- **Only SPC measurements?** β Use `scenario_6_spc_all`
|
| 120 |
+
- **Only TGN measurements?** β Use `scenario_7_tgn_all`
|
| 121 |
+
|
| 122 |
+
## π Research
|
| 123 |
+
|
| 124 |
+
Based on predictive modeling for milk spoilage classification using microbial growth patterns.
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
**Model Repository:** [MilkSpoilageClassifier](https://huggingface.co/chenhaoq87/MilkSpoilageClassifier)
|