anyisalin commited on
Commit
5d8606e
·
1 Parent(s): a0ecbf7

update templates

Browse files

Signed-off-by: AnyISalIn <anyisalin@gmail.com>

Files changed (3) hide show
  1. 00002.jpg +0 -0
  2. 00003.jpg +0 -0
  3. app.py +69 -67
00002.jpg ADDED
00003.jpg ADDED
app.py CHANGED
@@ -150,7 +150,8 @@ def create_ui():
150
  # trained_loras_models = [_.name for _ in get_noviata_client(novita_key).models_v3(refresh=True).filter_by_type("lora").filter_by_visibility("private")]
151
  serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
152
  serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
153
- return gr.update(choices=serving_models_labels), gr.update(value=serving_models)
 
154
 
155
  inference_refresh_button.click(
156
  inputs=[novita_key],
@@ -158,70 +159,76 @@ def create_ui():
158
  fn=inference_refresh_button_fn
159
  )
160
 
161
- templates = [
162
- {
163
- "style_prompt": "(masterpiece), (extremely intricate:1.3), (realistic), portrait of a person, the most handsome in the world, (medieval armor), metal reflections, upper body, outdoors, intense sunlight, far away castle, professional photograph of a stunning person detailed, sharp focus, dramatic, award winning, cinematic lighting, octane render unreal engine, volumetrics dtx, (film grain, blurry background, blurry foreground, bokeh, depth of field, sunset, motion blur:1.3), chainmail",
164
- "style_negative_prompt": "BadDream_53202, UnrealisticDream_53204",
165
- "style_model": "dreamshaper_8_93211.safetensors",
166
- "style_method": "txt2img",
167
- "style_height": 768,
168
- "style_width": 512,
169
- "style_reference_image": "./00001.jpg",
170
- },
171
- # {
172
- # "style_prompt": "upper body, ((masterpiece)), 1990s style , Student, ID photo, Vintage, Retro, School, Nostalgia",
173
- # "style_negative_prompt": "BadDream, UnrealisticDream",
174
- # "style_model": "checkpoint/dreamshaper_8",
175
- # "style_lora_model": "lora/junmoxiao.safetensors",
176
- # "style_lora_scale": 1.0,
177
- # "style_method": "img2img",
178
- # "style_embeddings": [
179
- # "embedding/BadDream.pt",
180
- # "embedding/UnrealisticDream.pt"
181
- # ],
182
- # "style_reference_image": "examples/style-2.png",
183
- # }
184
- ]
185
-
186
  first_stage_request_body = gr.JSON(label="First Stage Request Body, POST /api/v2/txt2img")
187
  second_stage_request_body = gr.JSON(label="Second Stage Request Body, POST /api/v2/adetailer")
188
 
189
- def mirror(*args):
190
- return args
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
- examples = gr.Examples(
193
- [
194
- [
195
- _.get("style_prompt", ""),
196
- _.get("style_negative_prompt", ""),
197
- _.get("style_model", ""),
198
- _.get("style_height", 512),
199
- _.get("style_width", 512),
200
- _.get("style_method", "txt2img"),
201
- _.get("style_reference_image", ""),
202
- ] for _ in templates
203
- ],
204
- [
205
- style_prompt,
206
- style_negative_prompt,
207
- style_model,
208
- style_height,
209
- style_width,
210
- style_method,
211
- style_reference_image,
212
- ],
213
  [
214
- style_prompt,
215
- style_negative_prompt,
216
- style_model,
217
- style_height,
218
- style_width,
219
- style_method,
220
- style_reference_image,
221
- ],
222
- mirror,
223
- cache_examples=False,
224
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  def generate(novita_key, gender, style_prompt, style_negative_prompt, style_model, style_lora, _hide_lora_training_response, style_hegiht, style_width, style_method, style_reference_image, num_images):
227
 
@@ -356,7 +363,8 @@ def create_ui():
356
  except Exception as e:
357
  logging.error(e)
358
  return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
359
- return novita_key, gr.update(choices=serving_models_labels), gr.update(value=serving_models), f"$ {user_info_json.credit_balance / 100 / 100:.2f}"
 
360
 
361
  novita_key.change(onload, inputs=novita_key, outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
362
 
@@ -369,12 +377,6 @@ def create_ui():
369
 
370
  return demo
371
 
372
- # style_method.change(
373
- # inputs=[style_method],
374
- # outputs=[style_reference_image],
375
- # fn=lambda method: gr.update(visible=method in ["controlnet", "img2img", "ip-adapater"])
376
- # )
377
-
378
 
379
  if __name__ == '__main__':
380
  demo = create_ui()
 
150
  # trained_loras_models = [_.name for _ in get_noviata_client(novita_key).models_v3(refresh=True).filter_by_type("lora").filter_by_visibility("private")]
151
  serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
152
  serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
153
+ default_serving_model = serving_models_labels[0] if len(serving_models_labels) > 0 else None
154
+ return gr.update(choices=serving_models_labels, value=default_serving_model), gr.update(value=serving_models)
155
 
156
  inference_refresh_button.click(
157
  inputs=[novita_key],
 
159
  fn=inference_refresh_button_fn
160
  )
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  first_stage_request_body = gr.JSON(label="First Stage Request Body, POST /api/v2/txt2img")
163
  second_stage_request_body = gr.JSON(label="Second Stage Request Body, POST /api/v2/adetailer")
164
 
165
+ templates = [
166
+ {
167
+ "style_prompt": "(masterpiece), (extremely intricate:1.3), (realistic), portrait of a person, the most handsome in the world, (medieval armor), metal reflections, upper body, outdoors, intense sunlight, far away castle, professional photograph of a stunning person detailed, sharp focus, dramatic, award winning, cinematic lighting, octane render unreal engine, volumetrics dtx, (film grain, blurry background, blurry foreground, bokeh, depth of field, sunset, motion blur:1.3), chainmail",
168
+ "style_negative_prompt": "BadDream_53202, UnrealisticDream_53204",
169
+ "style_model": "dreamshaper_8_93211.safetensors",
170
+ "style_method": "txt2img",
171
+ "style_height": 768,
172
+ "style_width": 512,
173
+ "style_reference_image": "./00001.jpg",
174
+ },
175
+ {
176
+ "style_prompt": "photo of beautiful age 18 girl, pastel hair, freckles sexy, beautiful, close up, young, dslr, 8k, 4k, ultrarealistic, realistic, natural skin, textured skin",
177
+ "style_negative_prompt": "BadDream_53202, UnrealisticDream_53204",
178
+ "style_model": "dreamshaper_8_93211.safetensors",
179
+ "style_method": "controlnet-depth",
180
+ "style_height": 768,
181
+ "style_width": 512,
182
+ "style_reference_image": "./00002.jpg",
183
+ },
184
+ {
185
+ "style_prompt": "majesty, holy, saintly, godly, 1girl, an angel descending from heaven, upper body, beautiful asian goddess, looking at viewer, detail face and eyes, symmetrical eyes, glowing white eye, warm attitude, long hair, blonde hair, floating hair, royal clothes, gold armor, feathered wings, glowing wings, nice hands",
186
+ "style_negative_prompt": "BadDream_53202, UnrealisticDream_53204",
187
+ "style_model": "dreamshaper_8_93211.safetensors",
188
+ "style_method": "controlnet-canny",
189
+ "style_height": 768,
190
+ "style_width": 512,
191
+ "style_reference_image": "./00003.jpg",
192
+ }
193
+ ]
194
+
195
+ def mirror(*args):
196
+ return args
197
 
198
+ with gr.Row():
199
+ examples = gr.Examples(
200
+ [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  [
202
+ _.get("style_prompt", ""),
203
+ _.get("style_negative_prompt", ""),
204
+ _.get("style_model", ""),
205
+ _.get("style_height", 512),
206
+ _.get("style_width", 512),
207
+ _.get("style_method", "txt2img"),
208
+ _.get("style_reference_image", ""),
209
+ ] for _ in templates
210
+ ],
211
+ [
212
+ style_prompt,
213
+ style_negative_prompt,
214
+ style_model,
215
+ style_height,
216
+ style_width,
217
+ style_method,
218
+ style_reference_image,
219
+ ],
220
+ [
221
+ style_prompt,
222
+ style_negative_prompt,
223
+ style_model,
224
+ style_height,
225
+ style_width,
226
+ style_method,
227
+ style_reference_image,
228
+ ],
229
+ mirror,
230
+ cache_examples=False,
231
+ )
232
 
233
  def generate(novita_key, gender, style_prompt, style_negative_prompt, style_model, style_lora, _hide_lora_training_response, style_hegiht, style_width, style_method, style_reference_image, num_images):
234
 
 
363
  except Exception as e:
364
  logging.error(e)
365
  return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
366
+ default_serving_model = serving_models_labels[0] if len(serving_models_labels) > 0 else None
367
+ return novita_key, gr.update(choices=serving_models_labels, value=default_serving_model), gr.update(value=serving_models), f"$ {user_info_json.credit_balance / 100 / 100:.2f}"
368
 
369
  novita_key.change(onload, inputs=novita_key, outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
370
 
 
377
 
378
  return demo
379
 
 
 
 
 
 
 
380
 
381
  if __name__ == '__main__':
382
  demo = create_ui()