Spaces:
Runtime error
Runtime error
change input
Browse files
app.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from uform import gen_model
|
| 3 |
from PIL import Image
|
| 4 |
-
import requests
|
| 5 |
|
| 6 |
# Load the model and processor
|
| 7 |
model = gen_model.VLMForCausalLM.from_pretrained("unum-cloud/uform-gen")
|
| 8 |
processor = gen_model.VLMProcessor.from_pretrained("unum-cloud/uform-gen")
|
| 9 |
|
| 10 |
-
|
| 11 |
def generate_caption(image, prompt):
|
| 12 |
# Process the image and the prompt
|
| 13 |
inputs = processor(text=prompt, images=image, return_tensors="pt", padding=True)
|
|
@@ -18,18 +16,14 @@ def generate_caption(image, prompt):
|
|
| 18 |
|
| 19 |
return caption
|
| 20 |
|
| 21 |
-
|
| 22 |
# Load the demo image
|
| 23 |
demo_image = Image.open("jungle-glass.png")
|
| 24 |
|
| 25 |
# Define the Gradio interface
|
| 26 |
iface = gr.Interface(
|
| 27 |
fn=generate_caption,
|
| 28 |
-
inputs=[
|
| 29 |
-
|
| 30 |
-
gr.inputs.Textbox(label="Prompt"),
|
| 31 |
-
],
|
| 32 |
-
outputs=gr.outputs.Textbox(label="Generated Caption"),
|
| 33 |
)
|
| 34 |
|
| 35 |
# Launch the interface
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from uform import gen_model
|
| 3 |
from PIL import Image
|
|
|
|
| 4 |
|
| 5 |
# Load the model and processor
|
| 6 |
model = gen_model.VLMForCausalLM.from_pretrained("unum-cloud/uform-gen")
|
| 7 |
processor = gen_model.VLMProcessor.from_pretrained("unum-cloud/uform-gen")
|
| 8 |
|
|
|
|
| 9 |
def generate_caption(image, prompt):
|
| 10 |
# Process the image and the prompt
|
| 11 |
inputs = processor(text=prompt, images=image, return_tensors="pt", padding=True)
|
|
|
|
| 16 |
|
| 17 |
return caption
|
| 18 |
|
|
|
|
| 19 |
# Load the demo image
|
| 20 |
demo_image = Image.open("jungle-glass.png")
|
| 21 |
|
| 22 |
# Define the Gradio interface
|
| 23 |
iface = gr.Interface(
|
| 24 |
fn=generate_caption,
|
| 25 |
+
inputs=[gr.Image(type="pil", label="Upload Image", default=demo_image), gr.Textbox(label="Prompt")],
|
| 26 |
+
outputs=gr.Textbox(label="Generated Caption"),
|
|
|
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
# Launch the interface
|