File size: 1,653 Bytes
299866a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Project Report

## Model Selection

- Model: `timm/mobilenetv4_conv_medium.e500_r224_in1k`
- Task: image classification on ImageNet-1k
- Input size: `224 x 224`
- Reason for selection: compact backbone, low CPU cost, and straightforward export to ONNX

## Optimization Phase

Run `python scripts/export_models.py` and `python scripts/benchmark_models.py --image path/to/sample.jpg` to produce the measured values below.

| Model | Size | Latency |
| --- | ---: | ---: |
| Original | TBD MB | TBD ms |
| ONNX | TBD MB | TBD ms |
| Quantized | TBD MB | TBD ms |

## Error Handling Strategy

- Missing file: `422`
- Invalid file type: `415`
- Too large file: `413`
- Corrupted image: `422`
- Unexpected server crash: `500`

Validation checks cover file extension, MIME type, upload size, and image decodability before inference starts.

## System Architecture

```mermaid
flowchart TD
    Client --> FastAPI
    FastAPI --> ProcessPool
    ProcessPool --> ONNXModel
    ONNXModel --> Response
```

## CI/CD Pipeline

```mermaid
flowchart TD
    Push --> GitHubActions
    GitHubActions --> Pytest
    Pytest --> DockerBuild
    DockerBuild --> HuggingFaceSpaces
```

## Performance Testing

Load testing is intended for both local Docker and Hugging Face Spaces with JMeter against `POST /predict`. Collect throughput, request latency, and P95 latency, then identify the CPU saturation point where response time rises sharply.

## Deliverables Checklist

- FastAPI application
- Model export scripts
- Benchmarking script
- Quantized ONNX model path
- Pytest suite
- Docker packaging
- GitHub Actions workflow
- Deployment script for Hugging Face Spaces