multimodalart HF staff commited on
Commit
5b09dff
1 Parent(s): 100cb38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -6,6 +6,7 @@ from safetensors.torch import load_file
6
  from share_btn import community_icon_html, loading_icon_html, share_js
7
  from uuid import uuid4
8
  from pathlib import Path
 
9
  import torch
10
  import json
11
  import random
@@ -127,7 +128,7 @@ def shuffle_images():
127
  def save_preferences(lora_1_id, lora_1_scale, lora_2_id, lora_2_scale, prompt, generated_image, thumbs_direction, seed):
128
  image_path = IMAGE_DATASET_DIR / f"{uuid4()}.png"
129
  with scheduler.lock:
130
- generated_image.save(image_path)
131
  with IMAGE_JSONL_PATH.open("a") as f:
132
  json.dump({"prompt": prompt, "file_name":image_path.name, "lora_1_id": lora_2_id, "lora_1_scale": lora_1_scale, "lora_2_id": lora_2_id, "lora_2_scale": lora_2_scale, "thumbs_direction": thumbs_direction, "seed": seed}, f)
133
  f.write("\n")
@@ -144,13 +145,13 @@ with gr.Blocks(css=css) as demo:
144
  with gr.Column():
145
  with gr.Column(min_width=10, scale=16, elem_classes="plus_column"):
146
  with gr.Row():
147
- with gr.Column(min_width=10, scale=3, elem_classes="random_column"):
148
  lora_1 = gr.Image(interactive=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_1", show_share_button=False, show_download_button=False)
149
  lora_1_id = gr.Textbox(visible=False, elem_id="random_lora_1_id")
150
  lora_1_prompt = gr.Markdown(visible=False)
151
  with gr.Column(min_width=10, scale=1, elem_classes="plus_column"):
152
  plus = gr.HTML("+", elem_classes="plus_button")
153
- with gr.Column(min_width=10, scale=3, elem_classes="random_column"):
154
  lora_2 = gr.Image(interactive=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_2", show_share_button=False, show_download_button=False)
155
  lora_2_id = gr.Textbox(visible=False, elem_id="random_lora_2_id")
156
  lora_2_prompt = gr.Markdown(visible=False)
 
6
  from share_btn import community_icon_html, loading_icon_html, share_js
7
  from uuid import uuid4
8
  from pathlib import Path
9
+ from PIL import Image
10
  import torch
11
  import json
12
  import random
 
128
  def save_preferences(lora_1_id, lora_1_scale, lora_2_id, lora_2_scale, prompt, generated_image, thumbs_direction, seed):
129
  image_path = IMAGE_DATASET_DIR / f"{uuid4()}.png"
130
  with scheduler.lock:
131
+ Image.fromarray(image_array).save(image_path)
132
  with IMAGE_JSONL_PATH.open("a") as f:
133
  json.dump({"prompt": prompt, "file_name":image_path.name, "lora_1_id": lora_2_id, "lora_1_scale": lora_1_scale, "lora_2_id": lora_2_id, "lora_2_scale": lora_2_scale, "thumbs_direction": thumbs_direction, "seed": seed}, f)
134
  f.write("\n")
 
145
  with gr.Column():
146
  with gr.Column(min_width=10, scale=16, elem_classes="plus_column"):
147
  with gr.Row():
148
+ with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
149
  lora_1 = gr.Image(interactive=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_1", show_share_button=False, show_download_button=False)
150
  lora_1_id = gr.Textbox(visible=False, elem_id="random_lora_1_id")
151
  lora_1_prompt = gr.Markdown(visible=False)
152
  with gr.Column(min_width=10, scale=1, elem_classes="plus_column"):
153
  plus = gr.HTML("+", elem_classes="plus_button")
154
+ with gr.Column(min_width=10, scale=4, elem_classes="random_column"):
155
  lora_2 = gr.Image(interactive=False, height=150, elem_classes="selected_random", elem_id="randomLoRA_2", show_share_button=False, show_download_button=False)
156
  lora_2_id = gr.Textbox(visible=False, elem_id="random_lora_2_id")
157
  lora_2_prompt = gr.Markdown(visible=False)