import gradio as gr import numpy as np from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline model_id = "google/ddpm-cat-256" ddpm = DDPMPipeline.from_pretrained(model_id) def flip_text(text): return text[::-1] def flip_img(img): return np.flipud(img) def show_cat(): return ddpm(num_inference_steps=5).images[0] with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("flip the text or image using this demo") with gr.Tab("Flip Text"): text_input = gr.Textbox(); text_output = gr.Textbox(); text_btn = gr.Button("Flip"); with gr.Tab("Flip Img"): with gr.Row(): image_input = gr.Image(source="webcam"); image_outpt = gr.Image(); image_btn = gr.Button("Flip"); with gr.Tab("Goolg Cat"): img_cat = gr.Image() cat_btn = gr.Button("Show Cat") with gr.Accordion("Open for more"): gr.Markdown("Look at me"); text_btn.click(flip_text, inputs=text_input, outputs=text_output) image_btn.click(flip_img, inputs=image_input, outputs=image_outpt) cat_btn.click(show_cat, outputs=img_cat) demo.launch()