VLV_Caption / app.py
lyttt's picture
Add application file
c65a1f7
raw
history blame
511 Bytes
import gradio as gr
from transformers import AutoModel, AutoProcessor
from PIL import Image
import torch
def greet(image):
model_name_or_path = "lyttt/VLV_captioner"
model = AutoModel.from_pretrained(model_name_or_path, revision="master", trust_remote_code=True,low_cpu_mem_usage=False)
image = Image.open(image).convert("RGB")
with torch.no_grad():
outputs = model([image]).generated_text
return output
demo = gr.Interface(fn=greet, inputs="image", outputs="text")
demo.launch()