mcuo commited on
Commit
fadea58
·
verified ·
1 Parent(s): 0390b80

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -37,7 +37,7 @@ compel = Compel(
37
  MAX_SEED = np.iinfo(np.int32).max
38
  MAX_IMAGE_SIZE = 1216
39
 
40
- @spaces.GPU(duration=10)
41
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
42
  if not prompt.strip():
43
  raise gr.Error("Prompt cannot be empty.")
@@ -86,7 +86,7 @@ with gr.Blocks(css=css) as demo:
86
 
87
  with gr.Column(elem_id="col-container"):
88
  result = gr.Image(format="png", label="Result", show_label=False)
89
- gr.Markdown("<br>" * 10)
90
 
91
  with gr.Row():
92
  prompt = gr.Text(
@@ -96,30 +96,30 @@ with gr.Blocks(css=css) as demo:
96
  )
97
  # --- 変更点: Lockボタンを削除し、ConsecutiveとStopボタンを追加 ---
98
  run_button = gr.Button("Generate", scale=0, interactive=False)
99
- consecutive_button = gr.Button("Consecutive", scale=0, interactive=True)
100
  stop_button = gr.Button("Stop", scale=0, visible=True, interactive=True)
101
  clear_button = gr.Button("Trash", scale=0, variant="secondary")
102
 
103
  with gr.Accordion("Advanced Settings", open=False):
104
  negative_prompt = gr.Text(
105
  label="Negative prompt", max_lines=1, placeholder="Enter a negative prompt",
106
- value="bad quality, low quality, worst quality, worst detail, bad anatomy, flying body parts, clone, long dick, glans"
107
  )
108
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
109
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
110
  with gr.Row():
111
- width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=832)
112
- height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=MAX_IMAGE_SIZE)
113
  with gr.Row():
114
  guidance_scale = gr.Slider(label="Guidance scale", minimum=0.0, maximum=20.0, step=0.1, value=7)
115
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=28, step=1, value=20)
116
 
117
  # --- 変更点: Consecutive生成用のインターバル設定を追加 ---
118
- interval_seconds = gr.Slider(label="Interval (seconds)", minimum=1, maximum=60, step=1, value=3)
119
-
120
  gr.Examples(
121
  examples=[
122
- ["masterpiece, amazing quality, A little girl with blonde short side tails, red eyes, "],
123
  ],
124
  inputs=[prompt],
125
  label="Examples (Click to copy to prompt)"
@@ -142,8 +142,8 @@ with gr.Blocks(css=css) as demo:
142
  prompt.input(
143
  fn=None,
144
  inputs=[prompt],
145
- outputs=[run_button],
146
- js="(p) => { return { interactive: p.trim().length > 0, '__type__': 'update' } }"
147
  )
148
 
149
  # --- 変更点: clear_buttonの動作を新しいUI構成に合わせて変更 ---
@@ -153,7 +153,7 @@ with gr.Blocks(css=css) as demo:
153
  outputs=[prompt, run_button, consecutive_button],
154
  js="""
155
  function() {
156
- return ["", { "interactive": false, "__type__": "update" }, { "interactive": true, "__type__": "update" }];
157
  }
158
  """
159
  )
 
37
  MAX_SEED = np.iinfo(np.int32).max
38
  MAX_IMAGE_SIZE = 1216
39
 
40
+ @spaces.GPU(duration=15)
41
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
42
  if not prompt.strip():
43
  raise gr.Error("Prompt cannot be empty.")
 
86
 
87
  with gr.Column(elem_id="col-container"):
88
  result = gr.Image(format="png", label="Result", show_label=False)
89
+ gr.Markdown("<br>" * 5)
90
 
91
  with gr.Row():
92
  prompt = gr.Text(
 
96
  )
97
  # --- 変更点: Lockボタンを削除し、ConsecutiveとStopボタンを追加 ---
98
  run_button = gr.Button("Generate", scale=0, interactive=False)
99
+ consecutive_button = gr.Button("Consecutive", scale=0, interactive=False) # Changed to interactive=False
100
  stop_button = gr.Button("Stop", scale=0, visible=True, interactive=True)
101
  clear_button = gr.Button("Trash", scale=0, variant="secondary")
102
 
103
  with gr.Accordion("Advanced Settings", open=False):
104
  negative_prompt = gr.Text(
105
  label="Negative prompt", max_lines=1, placeholder="Enter a negative prompt",
106
+ value="bad quality, low quality, worst quality, worst detail, bad anatomy, clone, long dick, glans"
107
  )
108
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
109
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
110
  with gr.Row():
111
+ width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
112
+ height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
113
  with gr.Row():
114
  guidance_scale = gr.Slider(label="Guidance scale", minimum=0.0, maximum=20.0, step=0.1, value=7)
115
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=28, step=1, value=20)
116
 
117
  # --- 変更点: Consecutive生成用のインターバル設定を追加 ---
118
+ interval_seconds = gr.Slider(label="Interval (seconds)", minimum=1, maximum=60, step=1, value=1)
119
+ gr.Markdown("<br>" * 10)
120
  gr.Examples(
121
  examples=[
122
+ ["masterpiece, solo, A little girl with blonde short side tails, red eyes, "],
123
  ],
124
  inputs=[prompt],
125
  label="Examples (Click to copy to prompt)"
 
142
  prompt.input(
143
  fn=None,
144
  inputs=[prompt],
145
+ outputs=[run_button, consecutive_button], # Added consecutive_button here
146
+ js="(p) => { const interactive = p.trim().length > 0; return [{ interactive: interactive, '__type__': 'update' }, { interactive: interactive, '__type__': 'update' }]; }"
147
  )
148
 
149
  # --- 変更点: clear_buttonの動作を新しいUI構成に合わせて変更 ---
 
153
  outputs=[prompt, run_button, consecutive_button],
154
  js="""
155
  function() {
156
+ return ["", { "interactive": false, "__type__": "update" }, { "interactive": false, "__type__": "update" }];
157
  }
158
  """
159
  )