Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import json
|
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
-
from PIL import Image
|
9 |
import spaces
|
10 |
import torch
|
11 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
@@ -52,9 +51,8 @@ def generate(
|
|
52 |
):
|
53 |
pipe.to(device)
|
54 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
55 |
-
generator = torch.Generator().manual_seed(seed)
|
56 |
-
|
57 |
-
image= pipe(
|
58 |
"prompt":prompt,
|
59 |
"negative_prompt":negative_prompt,
|
60 |
"width":width,
|
@@ -63,12 +61,9 @@ def generate(
|
|
63 |
"num_inference_steps":num_inference_steps,
|
64 |
"generator":generator,
|
65 |
"use_resolution_binning":use_resolution_binning,
|
66 |
-
"output_type":"pil",
|
67 |
).images[0]
|
68 |
-
|
69 |
return image, seed
|
70 |
|
71 |
-
|
72 |
examples = [
|
73 |
"a cat eating a piece of cheese",
|
74 |
"a ROBOT riding a BLUE horse on Mars, photorealistic, 4k",
|
@@ -98,7 +93,7 @@ with gr.Blocks(css=css) as demo:
|
|
98 |
container=False,
|
99 |
)
|
100 |
run_button = gr.Button("生成", scale=0)
|
101 |
-
result = gr.
|
102 |
with gr.Accordion("高级选项", open=False):
|
103 |
with gr.Row():
|
104 |
use_negative_prompt = gr.Checkbox(label="使用反向词条", value=True)
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
|
|
8 |
import spaces
|
9 |
import torch
|
10 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
|
|
51 |
):
|
52 |
pipe.to(device)
|
53 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
54 |
+
generator = torch.Generator().manual_seed(seed)
|
55 |
+
image = pipe(
|
|
|
56 |
"prompt":prompt,
|
57 |
"negative_prompt":negative_prompt,
|
58 |
"width":width,
|
|
|
61 |
"num_inference_steps":num_inference_steps,
|
62 |
"generator":generator,
|
63 |
"use_resolution_binning":use_resolution_binning,
|
|
|
64 |
).images[0]
|
|
|
65 |
return image, seed
|
66 |
|
|
|
67 |
examples = [
|
68 |
"a cat eating a piece of cheese",
|
69 |
"a ROBOT riding a BLUE horse on Mars, photorealistic, 4k",
|
|
|
93 |
container=False,
|
94 |
)
|
95 |
run_button = gr.Button("生成", scale=0)
|
96 |
+
result = gr.Image(label="Result", show_label=False)
|
97 |
with gr.Accordion("高级选项", open=False):
|
98 |
with gr.Row():
|
99 |
use_negative_prompt = gr.Checkbox(label="使用反向词条", value=True)
|