Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
CHANGED
@@ -1,7 +1,16 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
def greet(
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
7 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModel, AutoProcessor
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
|
6 |
+
def greet(image):
|
7 |
+
model_name_or_path = "lyttt/VLV_captioner"
|
8 |
+
model = AutoModel.from_pretrained(model_name_or_path, revision="master", trust_remote_code=True,low_cpu_mem_usage=False)
|
9 |
+
image = Image.open(image).convert("RGB")
|
10 |
+
with torch.no_grad():
|
11 |
+
outputs = model([image]).generated_text
|
12 |
|
13 |
+
return output
|
14 |
+
|
15 |
+
demo = gr.Interface(fn=greet, inputs="image", outputs="text")
|
16 |
demo.launch()
|