File size: 1,585 Bytes
7b04b3a
881a3d3
 
 
 
f76da4e
881a3d3
7b04b3a
881a3d3
 
 
 
7b04b3a
881a3d3
a97640e
7b04b3a
 
881a3d3
7b04b3a
881a3d3
7b04b3a
881a3d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf87feb
881a3d3
 
 
 
bf87feb
881a3d3
 
 
 
 
 
 
 
bf87feb
881a3d3
 
71786b7
881a3d3
71786b7
881a3d3
71786b7
 
 
 
881a3d3
71786b7
 
 
 
 
 
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
---
title: AgriLens AI FastAPI
emoji: 🌱
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
tags:
- fastapi
- agriculture
- ai
- plant-disease
pinned: false
short_description: AI-powered plant disease diagnosis API using Gemma-3n model
license: mit
---

# AgriLens AI FastAPI

AI-powered plant disease diagnosis API using Google's Gemma-3n model.

## Features

- Plant disease diagnosis from leaf images
- RESTful API endpoints
- Model sharing with Streamlit application
- CORS enabled for cross-origin requests

## API Endpoints

- `GET /` - API status and information
- `GET /health` - Health check
- `POST /load` - Load the AI model
- `POST /diagnose` - Diagnose plant disease from image

## Usage

### Health Check
```bash
curl https://huggingface.co/spaces/sido1991/apiagrilens/health
```

### Load Model
```bash
curl -X POST https://huggingface.co/spaces/sido1991/apiagrilens/load
```

### Diagnose Plant Disease
```bash
curl -X POST \
  -F "image=@plant_leaf.jpg" \
  -F "culture=tomato" \
  -F "notes=Yellow spots on leaves" \
  https://huggingface.co/spaces/sido1991/apiagrilens/diagnose
```

## Configuration

### Variables d'environnement

- **Model**: google/gemma-3n-E4B-it
- **Device**: CPU (optimisé pour Hugging Face Spaces)
- **Max Tokens**: 256
- **Cache Directory**: /tmp/hf_home

### Variables configurables

- `MODEL_ID`: Model identifier (default: google/gemma-3n-E4B-it)
- `DEVICE_MAP`: Device mapping (default: cpu)
- `MAX_NEW_TOKENS`: Maximum new tokens for generation (default: 256)
- `HF_HOME`: Hugging Face cache directory (default: /tmp/hf_home)