import gradio as gr from .audio_palette import AudioPalette article = """ ### Usage - Since this space is running on a CPU, it is not possible to generate music in a reasonable time. - To address this, we have provided a python notebook (check Files) that handles the music generation part which can be run locally (if you have GPU) or elsewhere. - This uses fastAPI to accept api requests and ngrok to expose the server. The same ngrok link needs to be pasted in the input box. (Make sure to include the trailing `/`). """ 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="ngrok 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", # article=article ) 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="ngrok 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", # article=article ) return demo