tianleliphoebe commited on
Commit
94bd22c
1 Parent(s): eb421e6

update fal api models

Browse files
model/model_manager.py CHANGED
@@ -28,6 +28,11 @@ class ModelManager:
28
  result = pipe(prompt=prompt)
29
  return result
30
 
 
 
 
 
 
31
  def generate_image_ig_parallel_anony(self, prompt, model_A, model_B):
32
  if model_A == "" and model_B == "":
33
  model_names = random.sample([model for model in self.model_ig_list], 2)
@@ -35,14 +40,16 @@ class ModelManager:
35
  model_names = [model_A, model_B]
36
 
37
  with concurrent.futures.ThreadPoolExecutor() as executor:
38
- futures = [executor.submit(self.generate_image_ig, prompt, model) for model in model_names]
 
39
  results = [future.result() for future in futures]
40
  return results[0], results[1], model_names[0], model_names[1]
41
 
42
  def generate_image_ig_parallel(self, prompt, model_A, model_B):
43
  model_names = [model_A, model_B]
44
  with concurrent.futures.ThreadPoolExecutor() as executor:
45
- futures = [executor.submit(self.generate_image_ig, prompt, model) for model in model_names]
 
46
  results = [future.result() for future in futures]
47
  return results[0], results[1]
48
 
@@ -77,6 +84,11 @@ class ModelManager:
77
  result = pipe(prompt=prompt)
78
  return result
79
 
 
 
 
 
 
80
  def generate_video_vg_parallel_anony(self, prompt, model_A, model_B):
81
  if model_A == "" and model_B == "":
82
  model_names = random.sample([model for model in self.model_vg_list], 2)
@@ -84,13 +96,15 @@ class ModelManager:
84
  model_names = [model_A, model_B]
85
 
86
  with concurrent.futures.ThreadPoolExecutor() as executor:
87
- futures = [executor.submit(self.generate_video_vg, prompt, model) for model in model_names]
 
88
  results = [future.result() for future in futures]
89
  return results[0], results[1], model_names[0], model_names[1]
90
 
91
  def generate_video_vg_parallel(self, prompt, model_A, model_B):
92
  model_names = [model_A, model_B]
93
  with concurrent.futures.ThreadPoolExecutor() as executor:
94
- futures = [executor.submit(self.generate_video_vg, prompt, model) for model in model_names]
 
95
  results = [future.result() for future in futures]
96
  return results[0], results[1]
 
28
  result = pipe(prompt=prompt)
29
  return result
30
 
31
+ def generate_image_ig_api(self, prompt, model_name):
32
+ pipe = self.load_model_pipe(model_name)
33
+ result = pipe(prompt=prompt)
34
+ return result
35
+
36
  def generate_image_ig_parallel_anony(self, prompt, model_A, model_B):
37
  if model_A == "" and model_B == "":
38
  model_names = random.sample([model for model in self.model_ig_list], 2)
 
40
  model_names = [model_A, model_B]
41
 
42
  with concurrent.futures.ThreadPoolExecutor() as executor:
43
+ futures = [executor.submit(self.generate_image_ig, prompt, model) if model.startswith("imagenhub")
44
+ else executor.submit(self.generate_image_ig_api, prompt, model) for model in model_names]
45
  results = [future.result() for future in futures]
46
  return results[0], results[1], model_names[0], model_names[1]
47
 
48
  def generate_image_ig_parallel(self, prompt, model_A, model_B):
49
  model_names = [model_A, model_B]
50
  with concurrent.futures.ThreadPoolExecutor() as executor:
51
+ futures = [executor.submit(self.generate_image_ig, prompt, model) if model.startswith("imagenhub")
52
+ else executor.submit(self.generate_image_ig_api, prompt, model) for model in model_names]
53
  results = [future.result() for future in futures]
54
  return results[0], results[1]
55
 
 
84
  result = pipe(prompt=prompt)
85
  return result
86
 
87
+ def generate_video_vg_api(self, prompt, model_name):
88
+ pipe = self.load_model_pipe(model_name)
89
+ result = pipe(prompt=prompt)
90
+ return result
91
+
92
  def generate_video_vg_parallel_anony(self, prompt, model_A, model_B):
93
  if model_A == "" and model_B == "":
94
  model_names = random.sample([model for model in self.model_vg_list], 2)
 
96
  model_names = [model_A, model_B]
97
 
98
  with concurrent.futures.ThreadPoolExecutor() as executor:
99
+ futures = [executor.submit(self.generate_video_vg, prompt, model) if model.startswith("videogenhub")
100
+ else executor.submit(self.generate_video_vg_api, prompt, model) for model in model_names]
101
  results = [future.result() for future in futures]
102
  return results[0], results[1], model_names[0], model_names[1]
103
 
104
  def generate_video_vg_parallel(self, prompt, model_A, model_B):
105
  model_names = [model_A, model_B]
106
  with concurrent.futures.ThreadPoolExecutor() as executor:
107
+ futures = [executor.submit(self.generate_video_vg, prompt, model) if model.startswith("videogenhub")
108
+ else executor.submit(self.generate_video_vg_api, prompt, model) for model in model_names]
109
  results = [future.result() for future in futures]
110
  return results[0], results[1]
model/model_registry.py CHANGED
@@ -46,21 +46,21 @@ def get_model_description_md(model_list):
46
  # regist image generation models
47
 
48
  register_model_info(
49
- ["imagenhub_LCM_generation"],
50
  "LCM",
51
  "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7",
52
  "Latent Consistency Models.",
53
  )
54
 
55
  register_model_info(
56
- ["imagenhub_PlayGroundV2_generation"],
57
  "Playground v2",
58
  "https://huggingface.co/playgroundai/playground-v2-1024px-aesthetic",
59
  "Playground v2 – 1024px Aesthetic Model",
60
  )
61
 
62
  register_model_info(
63
- ["imagenhub_PlayGroundV2.5_generation"],
64
  "Playground v2.5",
65
  "https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic",
66
  "Playground v2.5 is the state-of-the-art open-source model in aesthetic quality",
@@ -74,14 +74,14 @@ register_model_info(
74
  )
75
 
76
  register_model_info(
77
- ["imagenhub_SDXLTurbo_generation"],
78
  "SDXLTurbo",
79
  "https://huggingface.co/stabilityai/sdxl-turbo",
80
  "SDXL-Turbo is a fast generative text-to-image model.",
81
  )
82
 
83
  register_model_info(
84
- ["imagenhub_SDXL_generation"],
85
  "SDXL",
86
  "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0",
87
  "SDXL is a Latent Diffusion Model that uses two fixed, pretrained text encoders.",
@@ -95,21 +95,21 @@ register_model_info(
95
  )
96
 
97
  register_model_info(
98
- ["imagenhub_PixArtSigma_generation"],
99
  "PixArtSigma",
100
  "https://github.com/PixArt-alpha/PixArt-sigma",
101
  "Improved version of Pixart-α.",
102
  )
103
 
104
  register_model_info(
105
- ["imagenhub_SDXLLightning_generation"],
106
  "SDXL-Lightning",
107
  "https://huggingface.co/ByteDance/SDXL-Lightning",
108
  "SDXL-Lightning is a lightning-fast text-to-image generation model.",
109
  )
110
 
111
  register_model_info(
112
- ["imagenhub_StableCascade_generation"],
113
  "StableCascade",
114
  "https://huggingface.co/stabilityai/stable-cascade",
115
  "StableCascade is built upon the Würstchen architecture and working at a much smaller latent space.",
@@ -137,12 +137,6 @@ register_model_info(
137
  "Image Editing with Cross-Attention Control.",
138
  )
139
 
140
- # register_model_info(
141
- # ["imagenhub_SDEdit_edition"],
142
- # "SDEdit",
143
- # "",
144
- # "xxx",
145
- # )
146
 
147
  register_model_info(
148
  ["imagenhub_InstructPix2Pix_edition"],
@@ -221,13 +215,6 @@ register_model_info(
221
  "ModelScope is a a T2V synthesis model that evolves from a T2I synthesis model.",
222
  )
223
 
224
- #register_model_info(
225
- # ["videogenhub_CogVideo_generation"],
226
- # "CogVideo",
227
- # "https://arxiv.org/abs/2205.15868",
228
- # "Text-to-Video Generation via Transformers",
229
- #)
230
-
231
  register_model_info(
232
  ["videogenhub_OpenSora_generation"],
233
  "OpenSora",
 
46
  # regist image generation models
47
 
48
  register_model_info(
49
+ ["imagenhub_LCM_generation", "fal_LCM_text2image"],
50
  "LCM",
51
  "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7",
52
  "Latent Consistency Models.",
53
  )
54
 
55
  register_model_info(
56
+ ["imagenhub_PlayGroundV2_generation", 'playground_PlayGroundV2_generation'],
57
  "Playground v2",
58
  "https://huggingface.co/playgroundai/playground-v2-1024px-aesthetic",
59
  "Playground v2 – 1024px Aesthetic Model",
60
  )
61
 
62
  register_model_info(
63
+ ["imagenhub_PlayGroundV2.5_generation", 'playground_PlayGroundV2.5_generation'],
64
  "Playground v2.5",
65
  "https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic",
66
  "Playground v2.5 is the state-of-the-art open-source model in aesthetic quality",
 
74
  )
75
 
76
  register_model_info(
77
+ ["imagenhub_SDXLTurbo_generation", "fal_SDXLTurbo_text2image"],
78
  "SDXLTurbo",
79
  "https://huggingface.co/stabilityai/sdxl-turbo",
80
  "SDXL-Turbo is a fast generative text-to-image model.",
81
  )
82
 
83
  register_model_info(
84
+ ["imagenhub_SDXL_generation", "fal_SDXL_text2image"],
85
  "SDXL",
86
  "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0",
87
  "SDXL is a Latent Diffusion Model that uses two fixed, pretrained text encoders.",
 
95
  )
96
 
97
  register_model_info(
98
+ ["imagenhub_PixArtSigma_generation", "fal_PixArtSigma_text2image"],
99
  "PixArtSigma",
100
  "https://github.com/PixArt-alpha/PixArt-sigma",
101
  "Improved version of Pixart-α.",
102
  )
103
 
104
  register_model_info(
105
+ ["imagenhub_SDXLLightning_generation", "fal_SDXLLightning_text2image"],
106
  "SDXL-Lightning",
107
  "https://huggingface.co/ByteDance/SDXL-Lightning",
108
  "SDXL-Lightning is a lightning-fast text-to-image generation model.",
109
  )
110
 
111
  register_model_info(
112
+ ["imagenhub_StableCascade_generation", "fal_StableCascade_text2image"],
113
  "StableCascade",
114
  "https://huggingface.co/stabilityai/stable-cascade",
115
  "StableCascade is built upon the Würstchen architecture and working at a much smaller latent space.",
 
137
  "Image Editing with Cross-Attention Control.",
138
  )
139
 
 
 
 
 
 
 
140
 
141
  register_model_info(
142
  ["imagenhub_InstructPix2Pix_edition"],
 
215
  "ModelScope is a a T2V synthesis model that evolves from a T2I synthesis model.",
216
  )
217
 
 
 
 
 
 
 
 
218
  register_model_info(
219
  ["videogenhub_OpenSora_generation"],
220
  "OpenSora",
model/models/__init__.py CHANGED
@@ -3,8 +3,9 @@ from .playground_api import load_playground_model
3
  from .fal_api_models import load_fal_model
4
  from .videogenhub_models import load_videogenhub_model
5
 
6
- IMAGE_GENERATION_MODELS = ['imagenhub_LCM_generation','imagenhub_SDXLTurbo_generation','imagenhub_SDXL_generation', 'imagenhub_PixArtAlpha_generation', 'imagenhub_PixArtSigma_generation',
7
- 'imagenhub_OpenJourney_generation','imagenhub_SDXLLightning_generation', 'imagenhub_StableCascade_generation',
 
8
  'playground_PlayGroundV2_generation', 'playground_PlayGroundV2.5_generation']
9
  IMAGE_EDITION_MODELS = ['imagenhub_CycleDiffusion_edition', 'imagenhub_Pix2PixZero_edition', 'imagenhub_Prompt2prompt_edition',
10
  'imagenhub_SDEdit_edition', 'imagenhub_InstructPix2Pix_edition',
 
3
  from .fal_api_models import load_fal_model
4
  from .videogenhub_models import load_videogenhub_model
5
 
6
+
7
+ IMAGE_GENERATION_MODELS = ['fal_LCM_text2image','fal_SDXLTurbo_text2image','fal_SDXL_text2image', 'imagenhub_PixArtAlpha_generation', 'fal_PixArtSigma_text2image',
8
+ 'imagenhub_OpenJourney_generation','fal_SDXLLightning_text2image', 'fal_StableCascade_text2image',
9
  'playground_PlayGroundV2_generation', 'playground_PlayGroundV2.5_generation']
10
  IMAGE_EDITION_MODELS = ['imagenhub_CycleDiffusion_edition', 'imagenhub_Pix2PixZero_edition', 'imagenhub_Prompt2prompt_edition',
11
  'imagenhub_SDEdit_edition', 'imagenhub_InstructPix2Pix_edition',
model/models/fal_api_models.py CHANGED
@@ -3,7 +3,10 @@ from PIL import Image
3
  import requests
4
  import io
5
  import os
 
6
 
 
 
7
 
8
  class FalModel():
9
  def __init__(self, model_name, model_type):
@@ -12,10 +15,24 @@ class FalModel():
12
  os.environ['FAL_KEY'] = os.environ['FalAPI']
13
 
14
  def __call__(self, *args, **kwargs):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  if self.model_type == "text2image":
16
  assert "prompt" in kwargs, "prompt is required for text2image model"
17
  handler = fal_client.submit(
18
- f"fal-ai/{self.model_name}",
19
  arguments={
20
  "prompt": kwargs["prompt"]
21
  },
@@ -25,9 +42,14 @@ class FalModel():
25
  print('Request in progress')
26
  print(event.logs)
27
  result = handler.get()
 
28
  result_url = result['images'][0]['url']
29
- response = requests.get(result_url)
30
- result = Image.open(io.BytesIO(response.content))
 
 
 
 
31
  return result
32
  elif self.model_type == "image2image":
33
  raise NotImplementedError("image2image model is not implemented yet")
 
3
  import requests
4
  import io
5
  import os
6
+ import base64
7
 
8
+ FAL_MODEl_NAME_MAP = {"SDXL": "fast-sdxl", "SDXLTurbo": "fast-turbo-diffusion", "SDXLLightning": "fast-lightning-sdxl",
9
+ "LCM": "fast-lcm-diffusion", "PixArtSigma": "pixart-sigma", "StableCascade": "stable-cascade"}
10
 
11
  class FalModel():
12
  def __init__(self, model_name, model_type):
 
15
  os.environ['FAL_KEY'] = os.environ['FalAPI']
16
 
17
  def __call__(self, *args, **kwargs):
18
+ def decode_data_url(data_url):
19
+ # Find the start of the Base64 encoded data
20
+ base64_start = data_url.find(",") + 1
21
+ if base64_start == 0:
22
+ raise ValueError("Invalid data URL provided")
23
+
24
+ # Extract the Base64 encoded data
25
+ base64_string = data_url[base64_start:]
26
+
27
+ # Decode the Base64 string
28
+ decoded_bytes = base64.b64decode(base64_string)
29
+
30
+ return decoded_bytes
31
+
32
  if self.model_type == "text2image":
33
  assert "prompt" in kwargs, "prompt is required for text2image model"
34
  handler = fal_client.submit(
35
+ f"fal-ai/{FAL_MODEl_NAME_MAP[self.model_name]}",
36
  arguments={
37
  "prompt": kwargs["prompt"]
38
  },
 
42
  print('Request in progress')
43
  print(event.logs)
44
  result = handler.get()
45
+ print(result)
46
  result_url = result['images'][0]['url']
47
+ if self.model_name in ["SDXLTurbo", "LCM"]:
48
+ result_url = io.BytesIO(decode_data_url(result_url))
49
+ result = Image.open(result_url)
50
+ else:
51
+ response = requests.get(result_url)
52
+ result = Image.open(io.BytesIO(response.content))
53
  return result
54
  elif self.model_type == "image2image":
55
  raise NotImplementedError("image2image model is not implemented yet")
serve/gradio_web.py CHANGED
@@ -36,6 +36,7 @@ Find out who is the 🥇conditional image generation models! More models are goi
36
 
37
  state0 = gr.State()
38
  state1 = gr.State()
 
39
  gen_func = partial(generate_igm_annoy, models.generate_image_ig_parallel_anony)
40
 
41
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
@@ -187,6 +188,7 @@ def build_side_by_side_ui_named(models):
187
 
188
  state0 = gr.State()
189
  state1 = gr.State()
 
190
  gen_func = partial(generate_igm, models.generate_image_ig_parallel)
191
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
192
 
@@ -199,6 +201,7 @@ def build_side_by_side_ui_named(models):
199
  interactive=True,
200
  show_label=False,
201
  container=False,
 
202
  )
203
  with gr.Column():
204
  model_selector_right = gr.Dropdown(
@@ -207,6 +210,7 @@ def build_side_by_side_ui_named(models):
207
  interactive=True,
208
  show_label=False,
209
  container=False,
 
210
  )
211
  with gr.Row():
212
  with gr.Accordion("🔍 Expand to see all model descriptions", open=False):
@@ -253,8 +257,8 @@ def build_side_by_side_ui_named(models):
253
  ["A futuristic hopeful busy city, purple and green color scheme", os.path.join("./examples", "city.jpg")]],
254
  inputs = [textbox, dummy_img_output])
255
 
256
- model_selector_left.change(clear_history_side_by_side, inputs=None, outputs=[state0, state1, textbox, chatbot_left, chatbot_right], api_name="model_selector_left_side_by_side")
257
- model_selector_right.change(clear_history_side_by_side, inputs=None, outputs=[state0, state1, textbox, chatbot_left, chatbot_right], api_name="model_selector_right_side_by_side")
258
 
259
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
260
 
 
36
 
37
  state0 = gr.State()
38
  state1 = gr.State()
39
+ anony = True
40
  gen_func = partial(generate_igm_annoy, models.generate_image_ig_parallel_anony)
41
 
42
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
 
188
 
189
  state0 = gr.State()
190
  state1 = gr.State()
191
+ anony = False
192
  gen_func = partial(generate_igm, models.generate_image_ig_parallel)
193
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
194
 
 
201
  interactive=True,
202
  show_label=False,
203
  container=False,
204
+ allow_custom_value=True
205
  )
206
  with gr.Column():
207
  model_selector_right = gr.Dropdown(
 
210
  interactive=True,
211
  show_label=False,
212
  container=False,
213
+ allow_custom_value=True
214
  )
215
  with gr.Row():
216
  with gr.Accordion("🔍 Expand to see all model descriptions", open=False):
 
257
  ["A futuristic hopeful busy city, purple and green color scheme", os.path.join("./examples", "city.jpg")]],
258
  inputs = [textbox, dummy_img_output])
259
 
260
+ # model_selector_left.change(clear_history_side_by_side, inputs=None, outputs=[state0, state1, textbox, chatbot_left, chatbot_right], api_name="model_selector_left_side_by_side")
261
+ # model_selector_right.change(clear_history_side_by_side, inputs=None, outputs=[state0, state1, textbox, chatbot_left, chatbot_right], api_name="model_selector_right_side_by_side")
262
 
263
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
264
 
serve/gradio_web_image_editing.py CHANGED
@@ -27,7 +27,7 @@ def build_side_by_side_ui_anony_ie(models):
27
  - Wait to see the results after edition.
28
  - Click "New Round" to start a new round.
29
  - Vote won't be counted if model identity is revealed during generation.
30
- - The model could output a totally black image or noise. It's not a bug but the failure case of the model.
31
 
32
  ## 🏆 Arena Elo
33
  Find out who is the 🥇conditional image edition models!
@@ -303,14 +303,14 @@ def build_side_by_side_ui_named_ie(models):
303
  inputs=[textbox_source, textbox_target, textbox_instruct, source_image])
304
 
305
 
306
- model_selector_left.change(
307
- clear_history_side_by_side_ie,
308
- inputs=None,
309
- outputs=[state0, state1, textbox_source, textbox_target, textbox_instruct,
310
- source_image, chatbot_left, chatbot_right
311
- ],
312
- api_name="model_selector_left_side_by_side")
313
- model_selector_right.change(clear_history_side_by_side_ie, inputs=None, outputs=[state0, state1, textbox_source, textbox_target, textbox_instruct, source_image, chatbot_left, chatbot_right], api_name="model_selector_right_side_by_side")
314
 
315
 
316
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
 
27
  - Wait to see the results after edition.
28
  - Click "New Round" to start a new round.
29
  - Vote won't be counted if model identity is revealed during generation.
30
+ - The model coulmodel_selector_left.changed output a totally black image or noise. It's not a bug but the failure case of the model.
31
 
32
  ## 🏆 Arena Elo
33
  Find out who is the 🥇conditional image edition models!
 
303
  inputs=[textbox_source, textbox_target, textbox_instruct, source_image])
304
 
305
 
306
+ # model_selector_left.change(
307
+ # clear_history_side_by_side_ie,
308
+ # inputs=None,
309
+ # outputs=[state0, state1, textbox_source, textbox_target, textbox_instruct,
310
+ # source_image, chatbot_left, chatbot_right
311
+ # ],
312
+ # api_name="model_selector_left_side_by_side")
313
+ # model_selector_right.change(clear_history_side_by_side_ie, inputs=None, outputs=[state0, state1, textbox_source, textbox_target, textbox_instruct, source_image, chatbot_left, chatbot_right], api_name="model_selector_right_side_by_side")
314
 
315
 
316
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
serve/gradio_web_video_generation.py CHANGED
@@ -259,12 +259,12 @@ def build_side_by_side_ui_named_vg(models):
259
  'https://fal-cdn.batuhan-941.workers.dev/files/monkey/5-vUtY4_bHAhTtevZx16K.mp4']],
260
  inputs=[textbox, dummy_video_output])
261
 
262
- model_selector_left.change(clear_history_side_by_side, inputs=None,
263
- outputs=[state0, state1, textbox, chatbot_left, chatbot_right],
264
- api_name="model_selector_left_side_by_side")
265
- model_selector_right.change(clear_history_side_by_side, inputs=None,
266
- outputs=[state0, state1, textbox, chatbot_left, chatbot_right],
267
- api_name="model_selector_right_side_by_side")
268
 
269
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
270
 
 
259
  'https://fal-cdn.batuhan-941.workers.dev/files/monkey/5-vUtY4_bHAhTtevZx16K.mp4']],
260
  inputs=[textbox, dummy_video_output])
261
 
262
+ # model_selector_left.change(clear_history_side_by_side, inputs=None,
263
+ # outputs=[state0, state1, textbox, chatbot_left, chatbot_right],
264
+ # api_name="model_selector_left_side_by_side")
265
+ # model_selector_right.change(clear_history_side_by_side, inputs=None,
266
+ # outputs=[state0, state1, textbox, chatbot_left, chatbot_right],
267
+ # api_name="model_selector_right_side_by_side")
268
 
269
  btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, regenerate_btn, clear_btn]
270
 
serve/vote_utils.py CHANGED
@@ -172,8 +172,12 @@ def leftvote_last_response_igm(
172
  vote_last_response_igm(
173
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
174
  )
175
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
176
-
 
 
 
 
177
 
178
  def rightvote_last_response_igm(
179
  state0, state1, model_selector0, model_selector1, request: gr.Request
@@ -182,7 +186,10 @@ def rightvote_last_response_igm(
182
  vote_last_response_igm(
183
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
184
  )
185
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
 
 
 
186
 
187
 
188
  def tievote_last_response_igm(
@@ -192,7 +199,12 @@ def tievote_last_response_igm(
192
  vote_last_response_igm(
193
  [state0, state1], "tievote", [model_selector0, model_selector1], request
194
  )
195
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
 
 
 
 
 
196
 
197
 
198
  def bothbad_vote_last_response_igm(
@@ -202,7 +214,12 @@ def bothbad_vote_last_response_igm(
202
  vote_last_response_igm(
203
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
204
  )
205
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
 
 
 
 
 
206
 
207
  ## Image Editing (IE) Single Model Direct Chat
208
 
@@ -237,7 +254,7 @@ def leftvote_last_response_iem(
237
  # "### Model B: " + state1.model_name,
238
  # )
239
  # names = (state0.model_name, state1.model_name)
240
- names = (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
241
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
242
 
243
  def rightvote_last_response_iem(
@@ -251,7 +268,7 @@ def rightvote_last_response_iem(
251
  # "### Model A: " + state0.model_name,
252
  # "### Model B: " + state1.model_name,
253
  # )
254
- names = (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
255
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
256
 
257
  def tievote_last_response_iem(
@@ -261,7 +278,7 @@ def tievote_last_response_iem(
261
  vote_last_response_iem(
262
  [state0, state1], "tievote", [model_selector0, model_selector1], request
263
  )
264
- names = (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
265
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
266
 
267
  def bothbad_vote_last_response_iem(
@@ -271,7 +288,7 @@ def bothbad_vote_last_response_iem(
271
  vote_last_response_iem(
272
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
273
  )
274
- names = (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
275
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
276
 
277
 
@@ -304,7 +321,7 @@ def leftvote_last_response_vgm(
304
  vote_last_response_vgm(
305
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
306
  )
307
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
308
 
309
 
310
  def rightvote_last_response_vgm(
@@ -314,7 +331,7 @@ def rightvote_last_response_vgm(
314
  vote_last_response_vgm(
315
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
316
  )
317
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
318
 
319
 
320
  def tievote_last_response_vgm(
@@ -324,7 +341,7 @@ def tievote_last_response_vgm(
324
  vote_last_response_vgm(
325
  [state0, state1], "tievote", [model_selector0, model_selector1], request
326
  )
327
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
328
 
329
 
330
  def bothbad_vote_last_response_vgm(
@@ -334,7 +351,7 @@ def bothbad_vote_last_response_vgm(
334
  vote_last_response_vgm(
335
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
336
  )
337
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name}", visible=True), gr.Markdown(f"### Model B: {state1.model_name}", visible=True))
338
 
339
  share_js = """
340
  function (a, b, c, d) {
 
172
  vote_last_response_igm(
173
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
174
  )
175
+ if model_selector0 == gr.State(""):
176
+ return ("",) + (disable_btn,) * 4 + (
177
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
178
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
179
+ else:
180
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
181
 
182
  def rightvote_last_response_igm(
183
  state0, state1, model_selector0, model_selector1, request: gr.Request
 
186
  vote_last_response_igm(
187
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
188
  )
189
+ if model_selector0 == gr.State(""):
190
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
191
+ else:
192
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
193
 
194
 
195
  def tievote_last_response_igm(
 
199
  vote_last_response_igm(
200
  [state0, state1], "tievote", [model_selector0, model_selector1], request
201
  )
202
+ if model_selector0 == gr.State(""):
203
+ return ("",) + (disable_btn,) * 4 + (
204
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
205
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
206
+ else:
207
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
208
 
209
 
210
  def bothbad_vote_last_response_igm(
 
214
  vote_last_response_igm(
215
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
216
  )
217
+ if model_selector0 == gr.State(""):
218
+ return ("",) + (disable_btn,) * 4 + (
219
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
220
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
221
+ else:
222
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
223
 
224
  ## Image Editing (IE) Single Model Direct Chat
225
 
 
254
  # "### Model B: " + state1.model_name,
255
  # )
256
  # names = (state0.model_name, state1.model_name)
257
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
258
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
259
 
260
  def rightvote_last_response_iem(
 
268
  # "### Model A: " + state0.model_name,
269
  # "### Model B: " + state1.model_name,
270
  # )
271
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
272
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
273
 
274
  def tievote_last_response_iem(
 
278
  vote_last_response_iem(
279
  [state0, state1], "tievote", [model_selector0, model_selector1], request
280
  )
281
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
282
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
283
 
284
  def bothbad_vote_last_response_iem(
 
288
  vote_last_response_iem(
289
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
290
  )
291
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
292
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
293
 
294
 
 
321
  vote_last_response_vgm(
322
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
323
  )
324
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
325
 
326
 
327
  def rightvote_last_response_vgm(
 
331
  vote_last_response_vgm(
332
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
333
  )
334
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
335
 
336
 
337
  def tievote_last_response_vgm(
 
341
  vote_last_response_vgm(
342
  [state0, state1], "tievote", [model_selector0, model_selector1], request
343
  )
344
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
345
 
346
 
347
  def bothbad_vote_last_response_vgm(
 
351
  vote_last_response_vgm(
352
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
353
  )
354
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
355
 
356
  share_js = """
357
  function (a, b, c, d) {