File size: 1,757 Bytes
1387cb8
8cc2137
 
1387cb8
 
 
8cc2137
1387cb8
8cc2137
1387cb8
 
8cc2137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: Mold Detection API
emoji: 🦠
colorFrom: blue
colorTo: green
sdk: docker
app_file: app.py
pinned: false
license: mit
---

# Mold Detection API

FastAPI backend for mold detection using multi-task ResNet50 deep learning model, deployed with Docker.

# Mold Detection API

FastAPI backend for mold detection using multi-task ResNet50 deep learning model.

## Features

- **Multi-task Learning**: Classifies mold types and detects biological material
- **3-Level Decision System**: 
  - High confidence (≥80%): "Mold"
  - Medium confidence (50-80%) + biological detection: "Possible Mold"
  - Low confidence: "Not Mold"
- **RESTful API**: Easy integration with any frontend

## API Endpoints

### `GET /`
Health check and API information

### `GET /health`
Simple health check

### `POST /predict`
Predict mold detection from an image

**Request:**
- Content-Type: `multipart/form-data`
- File: Image file (jpg, png, jpeg)

**Response:**
```json
{
  "decision": "Mold" | "Possible Mold" | "Not Mold",
  "mold_probability": 0.0-1.0,
  "biological_probability": 0.0-1.0
}
```

## Usage

### Using curl:
```bash
curl -X POST "https://YOUR_USERNAME-SPACE_NAME.hf.space/predict" \
  -F "file=@/path/to/your/image.jpg"
```

### Using Python:
```python
import requests

url = "https://YOUR_USERNAME-SPACE_NAME.hf.space/predict"
with open("test_image.jpg", "rb") as f:
    response = requests.post(url, files={"file": f})
    print(response.json())
```

## Documentation

Interactive API documentation available at `/docs` endpoint.

## Model

- **Architecture**: ResNet50 with multi-task heads
- **Input**: RGB images (224x224)
- **Output**: 
  - Classification head: 9 classes (mold class at index 4)
  - Biological detection head: 2 classes (binary)