Spaces:
Runtime error
Runtime error
Ray Leung
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,15 @@ import gradio as gr
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
playground = gr.Blocks()
|
| 5 |
-
image_pipe = pipeline("image-to-text",
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def create_playground_header():
|
| 9 |
gr.Markdown("""
|
| 10 |
-
|
| 11 |
**Explore different LLM on Hugging Face platform. Just play and enjoy**
|
| 12 |
""")
|
| 13 |
|
|
@@ -16,10 +19,13 @@ def create_playground_footer():
|
|
| 16 |
**To Learn More about 🤗 Hugging Face, [Click Here](https://huggingface.co/docs)**
|
| 17 |
""")
|
| 18 |
|
| 19 |
-
def create_tabs_header(description):
|
| 20 |
with gr.Row():
|
| 21 |
with gr.Column(scale=4):
|
| 22 |
-
gr.Markdown(f"
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Column(scale=1):
|
| 24 |
test_pipeline_button = gr.Button(value="Process")
|
| 25 |
return test_pipeline_button
|
|
@@ -28,7 +34,10 @@ with playground:
|
|
| 28 |
create_playground_header()
|
| 29 |
with gr.Tabs():
|
| 30 |
with gr.TabItem("Image"):
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
gr.Markdown("""
|
| 33 |
> model='Salesforce/blip-image-captioning-base'
|
| 34 |
""")
|
|
@@ -38,7 +47,7 @@ with playground:
|
|
| 38 |
with gr.Column():
|
| 39 |
generated_textbox = gr.Textbox(lines=2, placeholder="", label="Generated Text")
|
| 40 |
|
| 41 |
-
image_pipeline_button.click(
|
| 42 |
inputs=[img],
|
| 43 |
outputs=[generated_textbox])
|
| 44 |
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
playground = gr.Blocks()
|
| 5 |
+
image_pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
| 6 |
+
|
| 7 |
+
def launch_image_pipe(input):
|
| 8 |
+
out = image_pipe(input)
|
| 9 |
+
return out[0]['generated_text']
|
| 10 |
|
| 11 |
def create_playground_header():
|
| 12 |
gr.Markdown("""
|
| 13 |
+
# 🤗 Hugging Face Labs
|
| 14 |
**Explore different LLM on Hugging Face platform. Just play and enjoy**
|
| 15 |
""")
|
| 16 |
|
|
|
|
| 19 |
**To Learn More about 🤗 Hugging Face, [Click Here](https://huggingface.co/docs)**
|
| 20 |
""")
|
| 21 |
|
| 22 |
+
def create_tabs_header(topic, description):
|
| 23 |
with gr.Row():
|
| 24 |
with gr.Column(scale=4):
|
| 25 |
+
gr.Markdown(f"""
|
| 26 |
+
## {topic}
|
| 27 |
+
> {description}
|
| 28 |
+
""")
|
| 29 |
with gr.Column(scale=1):
|
| 30 |
test_pipeline_button = gr.Button(value="Process")
|
| 31 |
return test_pipeline_button
|
|
|
|
| 34 |
create_playground_header()
|
| 35 |
with gr.Tabs():
|
| 36 |
with gr.TabItem("Image"):
|
| 37 |
+
topic = "Image Captioning"
|
| 38 |
+
description = ["model='Salesforce/blip-image-captioning-base'"]
|
| 39 |
+
# image_pipeline_button = create_tabs_header("Image Captioning")
|
| 40 |
+
image_pipeline_button = create_tabs_header(topic, description)
|
| 41 |
gr.Markdown("""
|
| 42 |
> model='Salesforce/blip-image-captioning-base'
|
| 43 |
""")
|
|
|
|
| 47 |
with gr.Column():
|
| 48 |
generated_textbox = gr.Textbox(lines=2, placeholder="", label="Generated Text")
|
| 49 |
|
| 50 |
+
image_pipeline_button.click(launch_image_pipe,
|
| 51 |
inputs=[img],
|
| 52 |
outputs=[generated_textbox])
|
| 53 |
|