CoolFace
Apppublic

chenhaoq87/MilkSpoilageClassifier-API-Variants

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes
App README

Milk Spoilage Classification API - Multi-Variant

AI-powered milk spoilage classification with 10 specialized model variants optimized for different data availability scenarios.

๐Ÿš€ Features

  • โ€”10 Model Variants with test accuracies from 62.8% to 95.8%
  • โ€”Automatic Feature Validation - API validates required features for each variant
  • โ€”RESTful API with comprehensive OpenAPI documentation
  • โ€”Custom GPT Ready - Designed for seamless ChatGPT integration

๐Ÿ“Š Available Model Variants

RankVariantTest AccuracyFeatures Required
๐Ÿฅ‡baseline95.8%All 6 features
๐Ÿฅˆscenario1days14_2194.2%Days 14 & 21 (SPC+TGN)
๐Ÿฅ‰scenario3day2193.7%Day 21 only (SPC+TGN)
4scenario4day1487.4%Day 14 only (SPC+TGN)
5scenario2days7_1487.3%Days 7 & 14 (SPC+TGN)
6scenario6spc_all78.3%SPC only (All Days)
7scenario8spc71473.3%SPC only (Days 7 & 14)
8scenario9tgn71473.1%TGN only (Days 7 & 14)
9scenario7tgn_all69.9%TGN only (All Days)
10scenario5day762.8%Day 7 only (SPC+TGN)

๐Ÿ”ง API Endpoints

GET /variants

List all available model variants with metadata

POST /predict

Make a prediction using the specified model variant

Example Request:

json
{
  "spc_d7": 2.1,
  "spc_d14": 4.7,
  "spc_d21": 6.4,
  "tgn_d7": 1.0,
  "tgn_d14": 3.7,
  "tgn_d21": 5.3,
  "model_variant": "baseline"
}

Example Response:

json
{
  "prediction": "PPC",
  "probabilities": {
    "PPC": 0.97,
    "no spoilage": 0.02,
    "spore spoilage": 0.01
  },
  "confidence": 0.97,
  "variant_used": {
    "variant_id": "baseline",
    "name": "Baseline (All Features)",
    "test_accuracy": 0.9576,
    "features": ["SPC_D7", "SPC_D14", "SPC_D21", "TGN_D7", "TGN_D14", "TGN_D21"]
  }
}

๐Ÿ“– Spoilage Classes

ClassDescription
PPCPost-Pasteurization Contamination - Bacteria introduced after pasteurization
no spoilageNo significant spoilage detected
spore spoilageHeat-resistant spore-forming bacteria survived pasteurization

๐Ÿ”— Interactive Documentation

Visit /docs for interactive Swagger UI documentation where you can test the API directly.

๐Ÿ’ป Usage Example

bash
curl -X POST https://chenhaoq87-milkspoilageclassifier-api-variants.hf.space/predict \
  -H "Content-Type: application/json" \
  -d '{
    "spc_d21": 6.4,
    "tgn_d21": 5.3,
    "model_variant": "scenario_3_day21"
  }'

๐Ÿค– Custom GPT Integration

This API is designed for Custom GPT integration. The GPT will automatically select the best variant based on available data.

See the Custom GPT Setup Guide for complete integration instructions.

๐Ÿ“ Input Format

All microbial count values should be in log CFU/mL (base 10):

  • โ€”SPC (Standard Plate Count): Total bacterial count
  • โ€”TGN (Total Gram-Negative): Gram-negative bacteria count
  • โ€”Measured at Day 7, 14, and 21

๐Ÿ” Variant Selection Guide

  • โ€”Have all measurements? โ†’ Use baseline (best accuracy)
  • โ€”Only Day 21 data? โ†’ Use scenario_3_day21 (nearly as good!)
  • โ€”Only Day 14 data? โ†’ Use scenario_4_day14
  • โ€”Only SPC measurements? โ†’ Use scenario_6_spc_all
  • โ€”Only TGN measurements? โ†’ Use scenario_7_tgn_all

๐Ÿ“š Research

Based on predictive modeling for milk spoilage classification using microbial growth patterns.


Model Repository: MilkSpoilageClassifier