Spaces:
Runtime error
Runtime error
File size: 1,147 Bytes
d58ac58 9be4786 bce3703 d58ac58 9be4786 ce05317 9be4786 ce05317 bce3703 9be4786 bce3703 9be4786 bce3703 ce05317 d58ac58 bce3703 |
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 |
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()
|