Lilbenzie commited on
Commit
0b8368f
·
verified ·
1 Parent(s): 2374829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -117
app.py CHANGED
@@ -25,122 +25,7 @@ def infer(
25
  num_inference_steps,
26
  progress=gr.Progress(track_tqdm=True),
27
  ):
28
- if randomize_seed:
29
- seed = random.randint(0, MAX_SEED)
30
 
31
- generator = torch.Generator().manual_seed(seed)
32
-
33
- image = pipe(
34
- prompt=prompt,
35
- negative_prompt=negative_prompt,
36
- guidance_scale=guidance_scale,
37
- num_inference_steps=num_inference_steps,
38
- width=width,
39
- height=height,
40
- generator=generator,
41
- ).images[0]
42
-
43
- return image, seed
44
-
45
-
46
- examples = [
47
- "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
48
- "An astronaut riding a green horse",
49
- "A delicious ceviche cheesecake slice",
50
- ]
51
-
52
- css = """
53
- #col-container {
54
- margin: 0 auto;
55
- max-width: 640px;
56
- }
57
- """
58
-
59
- with gr.Blocks(css=css) as demo:
60
- with gr.Column(elem_id="col-container"):
61
- gr.Markdown(" # Text-to-Image Gradio Template")
62
-
63
- with gr.Row():
64
- prompt = gr.Text(
65
- label="Prompt",
66
- show_label=False,
67
- max_lines=1,
68
- placeholder="Enter your prompt",
69
- container=False,
70
- )
71
-
72
- run_button = gr.Button("Run", scale=0, variant="primary")
73
-
74
- result = gr.Image(label="Result", show_label=False)
75
-
76
- with gr.Accordion("Advanced Settings", open=False):
77
- negative_prompt = gr.Text(
78
- label="Negative prompt",
79
- max_lines=1,
80
- placeholder="Enter a negative prompt",
81
- visible=False,
82
- )
83
-
84
- seed = gr.Slider(
85
- label="Seed",
86
- minimum=0,
87
- maximum=MAX_SEED,
88
- step=1,
89
- value=0,
90
- )
91
-
92
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
93
-
94
- with gr.Row():
95
- width = gr.Slider(
96
- label="Width",
97
- minimum=256,
98
- maximum=MAX_IMAGE_SIZE,
99
- step=32,
100
- value=1024, # Replace with defaults that work for your model
101
- )
102
-
103
- height = gr.Slider(
104
- label="Height",
105
- minimum=256,
106
- maximum=MAX_IMAGE_SIZE,
107
- step=32,
108
- value=1024, # Replace with defaults that work for your model
109
- )
110
-
111
- with gr.Row():
112
- guidance_scale = gr.Slider(
113
- label="Guidance scale",
114
- minimum=0.0,
115
- maximum=10.0,
116
- step=0.1,
117
- value=0.0, # Replace with defaults that work for your model
118
- )
119
-
120
- num_inference_steps = gr.Slider(
121
- label="Number of inference steps",
122
- minimum=1,
123
- maximum=50,
124
- step=1,
125
- value=2, # Replace with defaults that work for your model
126
- )
127
-
128
- gr.Examples(examples=examples, inputs=[prompt])
129
- gr.on(
130
- triggers=[run_button.click, prompt.submit],
131
- fn=infer,
132
- inputs=[
133
- prompt,
134
- negative_prompt,
135
- seed,
136
- randomize_seed,
137
- width,
138
- height,
139
- guidance_scale,
140
- num_inference_steps,
141
- ],
142
- outputs=[result, seed],
143
- )
144
-
145
- if __name__ == "__main__":
146
  demo.launch()
 
25
  num_inference_steps,
26
  progress=gr.Progress(track_tqdm=True),
27
  ):
28
+
 
29
 
30
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  demo.launch()