lvyb commited on
Commit
2c2b997
β€’
1 Parent(s): 4d70d15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,6 +3,9 @@ import os
3
  import gradio as gr
4
  from transformers import pipeline
5
 
 
 
 
6
 
7
  sd_description = "ζ–‡ε­—η”Ÿζˆε›Ύη‰‡"
8
  sd_examples = [["小猫"], ["cat"], ["dog"]]
@@ -14,13 +17,16 @@ examples = [[os.path.join(os.path.dirname(__file__), "lion.jpg")], [os.path.join
14
  app = gr.Interface.from_pipeline(pipe, examples=examples, title='ε›Ύη‰‡θ―†εˆ«')
15
 
16
 
17
- from diffusers import StableDiffusionPipeline
18
- import torch
19
-
20
  model_id = "dreamlike-art/dreamlike-photoreal-2.0"
21
  pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
 
 
 
 
 
 
22
  examples = [["落ζ—₯"], ["ζ²™ζ»©"]]
23
- app_v1 = gr.Interface.from_pipeline(pipe, examples=examples, title='ε›Ύη‰‡η”Ÿζˆ')
24
 
25
 
26
  demo = gr.TabbedInterface([sd_demo, app, app_v1], ["ζ–‡ε­—η”Ÿζˆε›Ύη‰‡", "ε›Ύη‰‡θ―†εˆ«", "ζ–‡ε­—η”Ÿζˆε›Ύη‰‡v1"])
 
3
  import gradio as gr
4
  from transformers import pipeline
5
 
6
+ from diffusers import StableDiffusionPipeline
7
+ import torch
8
+
9
 
10
  sd_description = "ζ–‡ε­—η”Ÿζˆε›Ύη‰‡"
11
  sd_examples = [["小猫"], ["cat"], ["dog"]]
 
17
  app = gr.Interface.from_pipeline(pipe, examples=examples, title='ε›Ύη‰‡θ―†εˆ«')
18
 
19
 
 
 
 
20
  model_id = "dreamlike-art/dreamlike-photoreal-2.0"
21
  pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
22
+ pipe_v1 = pipe.to("cpu")
23
+
24
+
25
+ def generate_image_v1(prompt):
26
+ return pipe_v1(prompt).images[0]
27
+
28
  examples = [["落ζ—₯"], ["ζ²™ζ»©"]]
29
+ app_v1 = gr.Interface(fn=generate_image_v1, inputs="text", outputs="image", examples=examples)
30
 
31
 
32
  demo = gr.TabbedInterface([sd_demo, app, app_v1], ["ζ–‡ε­—η”Ÿζˆε›Ύη‰‡", "ε›Ύη‰‡θ―†εˆ«", "ζ–‡ε­—η”Ÿζˆε›Ύη‰‡v1"])