audio_palette / utils /gradio_helper.py
manasch's picture
fix: typo
f2d4c46 verified
raw
history blame
3.48 kB
import gradio as gr
from .audio_palette import AudioPalette
def single_image_interface(model: AudioPalette):
demo = gr.Interface(
fn=model.generate_single,
inputs=[
gr.Image(
type="pil",
label="Upload an image",
show_label=True,
container=True
),
gr.Radio(
choices=["Piano", "Drums", "Guitar", "Violin", "Flute"],
label="Instrument",
show_label=True,
container=True
),
gr.Textbox(
lines=1,
placeholder="ngrok endpoint",
label="colab endpoint",
show_label=True,
container=True,
type="text",
visible=True
)
],
outputs=[
gr.Textbox(
lines=1,
placeholder="Prompt",
label="Generated Prompt",
show_label=True,
container=True,
type="text",
visible=False
),
gr.Textbox(
lines=1,
placeholder="Pace of the image",
label="Pace",
show_label=True,
container=True,
type="text",
visible=False
),
gr.Textbox(
lines=1,
placeholder="Caption for the image",
label="Caption",
show_label=True,
container=True,
type="text",
visible=False
),
gr.Audio(
label="Generated Audio",
show_label=True,
container=True,
visible=True,
format="wav",
autoplay=False,
show_download_button=True,
)
],
cache_examples=False,
live=False,
description="Provide an image to generate an appropriate background soundtrack",
)
return demo
def multi_image_interface(model: AudioPalette):
demo = gr.Interface(
fn=model.generate_multiple,
inputs=[
gr.File(
file_count="multiple",
file_types=["image"],
type="filepath",
label="Upload images",
show_label=True,
container=True,
visible=True
),
gr.Radio(
choices=["Piano", "Drums", "Guitar", "Violin", "Flute"],
label="Instrument",
show_label=True,
container=True
),
gr.Textbox(
lines=1,
placeholder="ngrok endpoint",
label="colab endpoint",
show_label=True,
container=True,
type="text",
visible=True
)
],
outputs=[
gr.Video(
format="mp4",
label="Generated Video",
show_label=True,
container=True,
visible=True,
autoplay=False,
)
],
cache_examples=False,
live=False,
description="Provide images to generate a slideshow of the images with appropriate music as background",
)
return demo