Spaces:
orrinin
/
Runtime error

orrinin commited on
Commit
5244cb4
·
verified ·
1 Parent(s): 657a746

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -20
app.py CHANGED
@@ -20,7 +20,7 @@ translator = Translator()
20
 
21
 
22
 
23
- def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
24
  if randomize_seed:
25
  seed = random.randint(0, MAX_SEED)
26
  return seed
@@ -82,11 +82,9 @@ def apply_style(style_name: str, positive: str) -> Tuple[str]:
82
 
83
  def generate(
84
  prompt: str,
85
- seed: int = 0,
86
- width: int = 1024,
87
- height: int = 1024,
88
  style: str = DEFAULT_STYLE_NAME,
89
- num_images: int = 2,
90
  randomize_seed: bool = False,
91
  progress=gr.Progress(track_tqdm=True),
92
  ):
@@ -96,15 +94,14 @@ def generate(
96
  # print(client.view_api())
97
 
98
  prompt = apply_style(style, prompt)
99
-
100
  result = client.predict(
101
- prompt=prompt,
102
- seed=seed,
103
- height=height,
104
- width=width,
105
- num_images=num_images,
106
- fast_vae_decode=True,
107
- api_name="/inference"
108
  )
109
  images = result[0]
110
  print(images)
@@ -147,12 +144,12 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
147
  result = gr.Gallery(label="作品", columns=1, preview=True)
148
  with gr.Accordion("高级选项", open=False):
149
  with gr.Row():
150
- num_images = gr.Slider(
151
- label="数量",
152
  minimum=1,
153
- maximum=6,
154
  step=1,
155
- value=2,
156
  )
157
  seed = gr.Slider(
158
  label="种子",
@@ -163,6 +160,7 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
163
  visible=True
164
  )
165
  randomize_seed = gr.Checkbox(label="随机种子", value=True)
 
166
  with gr.Row(visible=True):
167
  width = gr.Slider(
168
  label="宽",
@@ -178,6 +176,7 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
178
  step=8,
179
  value=1024,
180
  )
 
181
  with gr.Row(visible=True):
182
  style_selection = gr.Radio(
183
  show_label=True,
@@ -209,10 +208,8 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
209
  inputs=[
210
  prompt,
211
  seed,
212
- width,
213
- height,
214
  style_selection,
215
- num_images,
216
  randomize_seed,
217
  ],
218
  outputs=[result, seed],
 
20
 
21
 
22
 
23
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> float:
24
  if randomize_seed:
25
  seed = random.randint(0, MAX_SEED)
26
  return seed
 
82
 
83
  def generate(
84
  prompt: str,
85
+ seed: float = 0,
86
+ steps: float = 1,
 
87
  style: str = DEFAULT_STYLE_NAME,
 
88
  randomize_seed: bool = False,
89
  progress=gr.Progress(track_tqdm=True),
90
  ):
 
94
  # print(client.view_api())
95
 
96
  prompt = apply_style(style, prompt)
97
+ strength = 0.0
98
  result = client.predict(
99
+ None,
100
+ prompt,
101
+ seed,
102
+ strength,
103
+ steps,
104
+ api_name="/predict"
 
105
  )
106
  images = result[0]
107
  print(images)
 
144
  result = gr.Gallery(label="作品", columns=1, preview=True)
145
  with gr.Accordion("高级选项", open=False):
146
  with gr.Row():
147
+ steps = gr.Slider(
148
+ label="步数",
149
  minimum=1,
150
+ maximum=10,
151
  step=1,
152
+ value=1,
153
  )
154
  seed = gr.Slider(
155
  label="种子",
 
160
  visible=True
161
  )
162
  randomize_seed = gr.Checkbox(label="随机种子", value=True)
163
+ '''
164
  with gr.Row(visible=True):
165
  width = gr.Slider(
166
  label="宽",
 
176
  step=8,
177
  value=1024,
178
  )
179
+ '''
180
  with gr.Row(visible=True):
181
  style_selection = gr.Radio(
182
  show_label=True,
 
208
  inputs=[
209
  prompt,
210
  seed,
211
+ steps,
 
212
  style_selection,
 
213
  randomize_seed,
214
  ],
215
  outputs=[result, seed],