Spaces:
Runtime error
Runtime error
Ray Leung
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,49 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
playground = gr.Blocks()
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def create_playground_header():
|
| 6 |
gr.Markdown("""
|
| 7 |
-
|
| 8 |
-
**
|
| 9 |
""")
|
| 10 |
|
| 11 |
def create_playground_footer():
|
| 12 |
gr.Markdown("""
|
| 13 |
-
|
| 14 |
""")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
with playground:
|
| 17 |
create_playground_header()
|
| 18 |
with gr.Tabs():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
with gr.TabItem("Text"):
|
| 20 |
gr.Markdown("""
|
| 21 |
> Text Summarization and Translation
|
| 22 |
""")
|
| 23 |
|
| 24 |
-
with gr.TabItem("Image"):
|
| 25 |
-
gr.Markdown("""
|
| 26 |
-
> Image Captioning
|
| 27 |
-
""")
|
| 28 |
-
|
| 29 |
with gr.TabItem("Name Entity"):
|
| 30 |
gr.Markdown("""
|
| 31 |
> Name Entity Recognition
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
playground = gr.Blocks()
|
| 5 |
+
image_pipe = pipeline("image-to-text",
|
| 6 |
+
model="Salesforce/blip-image-captioning-base")
|
| 7 |
|
| 8 |
def create_playground_header():
|
| 9 |
gr.Markdown("""
|
| 10 |
+
#🤗 Hugging Face Labs
|
| 11 |
+
**Explore different LLM on Hugging Face platform. Just play and enjoy**
|
| 12 |
""")
|
| 13 |
|
| 14 |
def create_playground_footer():
|
| 15 |
gr.Markdown("""
|
| 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"**{description}**")
|
| 23 |
+
with gr.Column(scale=1):
|
| 24 |
+
test_pipeline_button = gr.Button(value="Process")
|
| 25 |
+
return test_pipeline_button
|
| 26 |
+
|
| 27 |
with playground:
|
| 28 |
create_playground_header()
|
| 29 |
with gr.Tabs():
|
| 30 |
+
with gr.TabItem("Image"):
|
| 31 |
+
image_pipeline_button = create_tabs_header("Image Captioning")
|
| 32 |
+
with gr.Row(visible=True) as use_pipeline:
|
| 33 |
+
with gr.Column():
|
| 34 |
+
img = gr.Image(type='pil')
|
| 35 |
+
with gr.Column():
|
| 36 |
+
generated_textbox = gr.Textbox(lines=2, placeholder="", label="Generated Text")
|
| 37 |
+
|
| 38 |
+
image_pipeline_button.click(image_pipe,
|
| 39 |
+
inputs=[img],
|
| 40 |
+
outputs=[generated_textbox]])
|
| 41 |
+
|
| 42 |
with gr.TabItem("Text"):
|
| 43 |
gr.Markdown("""
|
| 44 |
> Text Summarization and Translation
|
| 45 |
""")
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
with gr.TabItem("Name Entity"):
|
| 48 |
gr.Markdown("""
|
| 49 |
> Name Entity Recognition
|