Spaces:
Runtime error
Runtime error
anonymousatom
commited on
Commit
β’
0bafdb3
1
Parent(s):
31c06b5
Upload 3 files
Browse files- README.md +5 -4
- app.py +18 -0
- requirements.txt +4 -0
README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.23.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: AdLLaVA
|
3 |
+
emoji: π
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.23.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers import BitsAndBytesConfig, pipeline
|
4 |
+
|
5 |
+
# Load model directly
|
6 |
+
|
7 |
+
|
8 |
+
model_id = "marianna13/llava-phi-2-3b"
|
9 |
+
pipe = pipeline("image-to-text", model=model_id)
|
10 |
+
|
11 |
+
def generate_text(image):
|
12 |
+
max_new_tokens = 200
|
13 |
+
prompt = "USER: <image>\nWhat are the things I should be cautious about when I visit this place?\nASSISTANT:"
|
14 |
+
outputs = pipe(image, prompt=prompt, generate_kwargs={"max_new_tokens": 200})
|
15 |
+
return outputs[0]["generated_text"]
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=generate_text, inputs=gr.inputs.Image(), outputs="text")
|
18 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers==4.37.2
|
2 |
+
bitsandbytes==0.41.3
|
3 |
+
accelerate==0.25.0
|
4 |
+
gradio
|