Spaces:
Running
Running
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,65 @@
|
|
| 1 |
---
|
| 2 |
-
title: Gemma
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Gemma 4 API
|
| 3 |
+
emoji: 🤖
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# Gemma 4 API
|
| 11 |
+
|
| 12 |
+
Flask REST API for [Gemma 4 E2B](https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm) running on-device via LiteRT-LM.
|
| 13 |
+
|
| 14 |
+
## Endpoints
|
| 15 |
+
|
| 16 |
+
| Method | Path | Description |
|
| 17 |
+
|--------|------|-------------|
|
| 18 |
+
| `GET` | `/gemma?ask=hello` | Text query |
|
| 19 |
+
| `POST` | `/gemma` | JSON `{ask, image?}` — text + optional base64 image |
|
| 20 |
+
| `POST` | `/gemma` | `multipart/form-data` — text + image file upload |
|
| 21 |
+
| `GET` | `/gemma/download` | Download model from HuggingFace into `models/gemma/` |
|
| 22 |
+
| `GET` | `/gemma/download?status=1` | Poll download progress |
|
| 23 |
+
| `GET` | `/health` | Health + model status |
|
| 24 |
+
|
| 25 |
+
## Setup
|
| 26 |
+
|
| 27 |
+
### Option 1 — Docker with model already downloaded
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
docker build -t gemma-api .
|
| 31 |
+
docker run -p 7860:7860 \
|
| 32 |
+
-v /your/model/dir:/app/models/gemma \
|
| 33 |
+
gemma-api
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### Option 2 — Download model at runtime
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
docker build -t gemma-api .
|
| 40 |
+
docker run -p 7860:7860 gemma-api
|
| 41 |
+
# then hit:
|
| 42 |
+
curl http://localhost:7860/gemma/download
|
| 43 |
+
# poll until done:
|
| 44 |
+
curl http://localhost:7860/gemma/download?status=1
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Model file: `gemma-4-E2B-it.litertlm` (~2.5 GB)
|
| 48 |
+
Expected path inside container: `/app/models/gemma/gemma-4-E2B-it.litertlm`
|
| 49 |
+
|
| 50 |
+
## Example
|
| 51 |
+
|
| 52 |
+
```bash
|
| 53 |
+
# Text
|
| 54 |
+
curl "http://localhost:7860/gemma?ask=hello"
|
| 55 |
+
|
| 56 |
+
# Image (base64)
|
| 57 |
+
curl -X POST http://localhost:7860/gemma \
|
| 58 |
+
-H "Content-Type: application/json" \
|
| 59 |
+
-d '{"ask":"what is in this image?","image":"<base64>"}'
|
| 60 |
+
|
| 61 |
+
# Image (file upload)
|
| 62 |
+
curl -X POST http://localhost:7860/gemma \
|
| 63 |
+
-F "ask=describe this" \
|
| 64 |
+
-F "image=@photo.jpg"
|
| 65 |
+
```
|