lyttt commited on
Commit
c65a1f7
·
1 Parent(s): d1b0574

Add application file

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,7 +1,16 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
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()