Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
-
import requests
|
3 |
-
from PIL import Image
|
4 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
5 |
|
6 |
-
|
7 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
8 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
9 |
|
10 |
def execute(image):
|
11 |
-
|
12 |
-
|
13 |
-
output = processor.decode(out[0], skip_special_tokens=True)
|
14 |
return output
|
15 |
|
16 |
-
iface = gr.Interface(
|
17 |
-
execute,
|
18 |
-
inputs=[
|
19 |
-
"image",
|
20 |
-
],
|
21 |
-
outputs="textbox"
|
22 |
-
)
|
23 |
-
|
24 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
3 |
|
|
|
4 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
5 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
6 |
|
7 |
def execute(image):
|
8 |
+
model_inputs = processor(image, return_tensors="pt")
|
9 |
+
output = processor.decode(model.generate(**model_inputs)[0], skip_special_tokens=True)
|
|
|
10 |
return output
|
11 |
|
12 |
+
iface = gr.Interface(fn=execute, inputs="image", outputs="textbox")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
iface.launch()
|