ved1beta
commited on
Commit
·
ef13ec4
1
Parent(s):
44157d6
hope
Browse files
README.md
CHANGED
@@ -11,3 +11,29 @@ license: mit
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
# PaliGemma Image Captioning Gradio App
|
15 |
+
|
16 |
+
## Deployment Instructions
|
17 |
+
|
18 |
+
1. Create a new Hugging Face Space
|
19 |
+
2. Choose Python as the SDK
|
20 |
+
3. Select 16GB CPU hardware
|
21 |
+
4. Upload the following files:
|
22 |
+
- `app.py`
|
23 |
+
- `requirements.txt`
|
24 |
+
|
25 |
+
### HuggingFace Access Token
|
26 |
+
|
27 |
+
1. Go to HuggingFace settings
|
28 |
+
2. Create a new access token with "Read" permissions
|
29 |
+
3. Add the token as a secret named `HF_TOKEN` in your Space settings
|
30 |
+
|
31 |
+
### Features
|
32 |
+
- Multi-language image captioning
|
33 |
+
- Upload custom images
|
34 |
+
- Example images included
|
35 |
+
- Supports English, Spanish, French, German captions
|
36 |
+
|
37 |
+
## Model Details
|
38 |
+
- Model: google/paligemma-3b-mix-224
|
39 |
+
- Task: Multilingual Image Captioning
|
app.py
CHANGED
@@ -1,13 +1,17 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
import requests
|
6 |
|
|
|
|
|
|
|
7 |
# Load the model and processor
|
8 |
model_id = "google/paligemma-3b-mix-224"
|
9 |
-
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, token=
|
10 |
-
processor = AutoProcessor.from_pretrained(model_id, token=
|
11 |
|
12 |
# Supported languages and example prompts
|
13 |
LANGUAGES = {
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
|
4 |
from PIL import Image
|
5 |
import torch
|
6 |
import requests
|
7 |
|
8 |
+
# Get token from environment variable
|
9 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
10 |
+
|
11 |
# Load the model and processor
|
12 |
model_id = "google/paligemma-3b-mix-224"
|
13 |
+
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, token=HF_TOKEN).eval()
|
14 |
+
processor = AutoProcessor.from_pretrained(model_id, token=HF_TOKEN)
|
15 |
|
16 |
# Supported languages and example prompts
|
17 |
LANGUAGES = {
|