chenhaoq87 commited on
Commit
7149c09
Β·
verified Β·
1 Parent(s): 5718fcc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +123 -5
README.md CHANGED
@@ -1,10 +1,128 @@
1
  ---
2
- title: MilkSpoilageClassifier API Variants
3
- emoji: πŸ”₯
4
- colorFrom: purple
5
- colorTo: indigo
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)