Spaces:
Runtime error
Runtime error
File size: 2,942 Bytes
4389dd9 4f390ee 4389dd9 d0bce20 4389dd9 d0bce20 4f390ee 4389dd9 4f390ee 4389dd9 554191f 4f390ee 8d70f1e 9b8b546 4f390ee 4389dd9 4f390ee c836a14 d0bce20 554191f 8404d2a 554191f c836a14 4f390ee d0bce20 4f390ee 5e96bb9 4f390ee 4389dd9 40667d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
import gradio as gr
from transformers import pipeline
playground = gr.Blocks()
image_pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
def launch_image_pipe(input):
out = image_pipe(input)
return out[0]['generated_text']
def create_playground_header():
gr.Markdown("""
# 🤗 Hugging Face Labs
**Explore different LLM on Hugging Face platform. Just play and enjoy**
""")
def create_playground_footer():
gr.Markdown("""
**To Learn More about 🤗 Hugging Face, [Click Here](https://huggingface.co/docs)**
""")
def create_tabs_header(topic, description, references):
with gr.Row():
with gr.Column(scale=4):
# reference_list = "> " + "\n> ".join(references)
# content = f"## {topic}\n"
# content += f"### {description}\n"
# for ref in references:
# content += f"> {ref}\n"
# gr.Markdown(content)
gr.Markdown("""
## Image Captioning
### Upload a image, check what AI understand and have vision on it.
> category: Image-to-Text
> model: [Salesforce/blip-image-captioning-base](https://huggingface.co/Salesforce/blip-image-captioning-base)
""")
with gr.Column(scale=1):
test_pipeline_button = gr.Button(value="Process")
return test_pipeline_button
with playground:
create_playground_header()
with gr.Tabs():
with gr.TabItem("Image"):
topic = "Image Captioning"
description = "Upload a image, check what AI understand and have vision on it."
references = ["category: Image-to-Text",
"model: [Salesforce/blip-image-captioning-base](https://huggingface.co/Salesforce/blip-image-captioning-base)"]
image_pipeline_button = create_tabs_header(topic, description, references)
with gr.Row(visible=True) as use_pipeline:
with gr.Column():
img = gr.Image(type='pil')
with gr.Column():
generated_textbox = gr.Textbox(lines=2, placeholder="", label="Generated Text")
image_pipeline_button.click(launch_image_pipe,
inputs=[img],
outputs=[generated_textbox])
with gr.TabItem("Text"):
gr.Markdown("""
> Text Summarization and Translation
""")
with gr.TabItem("Name Entity"):
gr.Markdown("""
> Name Entity Recognition
""")
create_playground_footer()
playground.launch(share=True) |