mkrzyzan commited on
Commit
bce3703
β€’
1 Parent(s): 0fffcf9

google cat

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,5 +1,9 @@
1
  import gradio as gr
2
  import numpy as np
 
 
 
 
3
 
4
  def flip_text(text):
5
  return text[::-1]
@@ -7,7 +11,10 @@ def flip_text(text):
7
  def flip_img(img):
8
  return np.flipud(img)
9
 
10
- with gr.Blocks() as demo:
 
 
 
11
  gr.Markdown("flip the text or image using this demo")
12
  with gr.Tab("Flip Text"):
13
  text_input = gr.Textbox();
@@ -18,11 +25,15 @@ with gr.Blocks() as demo:
18
  image_input = gr.Image(source="webcam");
19
  image_outpt = gr.Image();
20
  image_btn = gr.Button("Flip");
 
 
 
21
  with gr.Accordion("Open for more"):
22
  gr.Markdown("Look at me");
23
 
24
  text_btn.click(flip_text, inputs=text_input, outputs=text_output)
25
  image_btn.click(flip_img, inputs=image_input, outputs=image_outpt)
 
26
 
27
 
28
- demo.launch()
 
1
  import gradio as gr
2
  import numpy as np
3
+ from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
4
+
5
+ model_id = "google/ddpm-cat-256"
6
+ ddpm = DDPMPipeline.from_pretrained(model_id)
7
 
8
  def flip_text(text):
9
  return text[::-1]
 
11
  def flip_img(img):
12
  return np.flipud(img)
13
 
14
+ def show_cat():
15
+ return ddpm(num_inference_steps=5).images[0]
16
+
17
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
18
  gr.Markdown("flip the text or image using this demo")
19
  with gr.Tab("Flip Text"):
20
  text_input = gr.Textbox();
 
25
  image_input = gr.Image(source="webcam");
26
  image_outpt = gr.Image();
27
  image_btn = gr.Button("Flip");
28
+ with gr.Tab("Goolg Cat"):
29
+ img_cat = gr.Image()
30
+ cat_btn = gr.Button("Show Cat")
31
  with gr.Accordion("Open for more"):
32
  gr.Markdown("Look at me");
33
 
34
  text_btn.click(flip_text, inputs=text_input, outputs=text_output)
35
  image_btn.click(flip_img, inputs=image_input, outputs=image_outpt)
36
+ cat_btn.click(show_cat, outputs=img_cat)
37
 
38
 
39
+ demo.launch()