ksort commited on
Commit
7d71710
·
1 Parent(s): e4e1a80

Update ssh

Browse files
model/models/__init__.py CHANGED
@@ -34,8 +34,8 @@ IMAGE_GENERATION_MODELS = [
34
  'huggingface_Stable-cascade_text2image',
35
  'openai_Dalle-2_text2image',
36
  'openai_Dalle-3_text2image',
37
- # 'other_Midjourney-v6.0_text2image',
38
- # 'other_Midjourney-v5.0_text2image',
39
  ]
40
 
41
 
 
34
  'huggingface_Stable-cascade_text2image',
35
  'openai_Dalle-2_text2image',
36
  'openai_Dalle-3_text2image',
37
+ 'other_Midjourney-v6.0_text2image',
38
+ 'other_Midjourney-v5.0_text2image',
39
  ]
40
 
41
 
model/models/other_api_models.py CHANGED
@@ -9,8 +9,7 @@ class OtherModel():
9
  self.model_name = model_name
10
  self.model_type = model_type
11
  self.url = "https://www.xdai.online/mj/submit/imagine"
12
- # self.key = os.environ.get('MIDJOURNEY_KEY')
13
- self.key = 'sk-yhIAe209CeWmk7ueC5D673A2D6164eE5919656Ea989913Fb'
14
  self.get_url = "https://www.xdai.online/mj/image/"
15
  self.repeat_num = 5
16
 
@@ -47,7 +46,8 @@ class OtherModel():
47
  response_json = json.loads(response.content.decode('utf-8'))
48
  img_id = response_json["result"]
49
  result_url = self.get_url + img_id
50
- self.repeat_num = 120
 
51
  while 1:
52
  time.sleep(1)
53
  img_response = requests.get(result_url)
 
9
  self.model_name = model_name
10
  self.model_type = model_type
11
  self.url = "https://www.xdai.online/mj/submit/imagine"
12
+ self.key = os.environ.get('MIDJOURNEY_KEY')
 
13
  self.get_url = "https://www.xdai.online/mj/image/"
14
  self.repeat_num = 5
15
 
 
46
  response_json = json.loads(response.content.decode('utf-8'))
47
  img_id = response_json["result"]
48
  result_url = self.get_url + img_id
49
+ print(result_url)
50
+ self.repeat_num = 180
51
  while 1:
52
  time.sleep(1)
53
  img_response = requests.get(result_url)
serve/Ksort.py CHANGED
@@ -328,4 +328,10 @@ def add_green_border(image):
328
  border_color = (0, 255, 0) # RGB for green
329
  border_size = 10 # Size of the border
330
  img_with_border = ImageOps.expand(image, border=border_size, fill=border_color)
331
- return img_with_border
 
 
 
 
 
 
 
328
  border_color = (0, 255, 0) # RGB for green
329
  border_size = 10 # Size of the border
330
  img_with_border = ImageOps.expand(image, border=border_size, fill=border_color)
331
+ return img_with_border
332
+
333
+ def check_textbox(textbox):
334
+ if textbox=="":
335
+ return False
336
+ else:
337
+ return True
serve/gradio_web.py CHANGED
@@ -32,6 +32,7 @@ from .Ksort import (
32
  reset_btn_rank,
33
  reset_vote_text,
34
  text_response_rank_igm,
 
35
  )
36
 
37
  from functools import partial
@@ -278,7 +279,7 @@ def build_side_by_side_ui_anony(models):
278
 
279
  textbox.submit(
280
  disable_order_buttons,
281
- inputs=None,
282
  outputs=order_btn_list
283
  ).then(
284
  gen_func,
@@ -288,13 +289,13 @@ def build_side_by_side_ui_anony(models):
288
  api_name="submit_btn_annony"
289
  ).then(
290
  enable_vote_mode_buttons,
291
- inputs=[vote_mode],
292
  outputs=vote_order_list
293
  )
294
 
295
  send_btn.click(
296
  disable_order_buttons,
297
- inputs=None,
298
  outputs=order_btn_list
299
  ).then(
300
  gen_func,
@@ -304,7 +305,7 @@ def build_side_by_side_ui_anony(models):
304
  api_name="send_btn_annony"
305
  ).then(
306
  enable_vote_mode_buttons,
307
- inputs=[vote_mode],
308
  outputs=vote_order_list
309
  )
310
 
 
32
  reset_btn_rank,
33
  reset_vote_text,
34
  text_response_rank_igm,
35
+ check_textbox,
36
  )
37
 
38
  from functools import partial
 
279
 
280
  textbox.submit(
281
  disable_order_buttons,
282
+ inputs=[textbox],
283
  outputs=order_btn_list
284
  ).then(
285
  gen_func,
 
289
  api_name="submit_btn_annony"
290
  ).then(
291
  enable_vote_mode_buttons,
292
+ inputs=[vote_mode, textbox],
293
  outputs=vote_order_list
294
  )
295
 
296
  send_btn.click(
297
  disable_order_buttons,
298
+ inputs=[textbox],
299
  outputs=order_btn_list
300
  ).then(
301
  gen_func,
 
305
  api_name="send_btn_annony"
306
  ).then(
307
  enable_vote_mode_buttons,
308
+ inputs=[vote_mode, textbox],
309
  outputs=vote_order_list
310
  )
311
 
serve/utils.py CHANGED
@@ -177,25 +177,31 @@ def disable_vote_buttons():
177
  return tuple(gr.update(visible=False, interactive=False) for i in range(6))
178
  def disable_vote():
179
  return tuple(gr.update(interactive=False) for i in range(18))
180
- def enable_vote_mode_buttons(mode):
181
  print(mode)
182
- if mode == "Best":
183
- return (gr.update(visible=True, interactive=True),) * 5 + \
184
- (gr.update(visible=False, interactive=False),) * 16 + \
185
- (gr.update(visible=True, interactive=False),) * 2 + \
186
- (gr.update(visible=True, interactive=True),)
187
- elif mode == "Rank":
188
- return (gr.update(visible=False, interactive=False),) * 5 + \
189
- (gr.update(visible=True, interactive=True),) * 16 + \
190
- (gr.update(visible=True, interactive=True),) * 3
 
 
 
191
  def disable_vote_mode_buttons():
192
  return tuple(gr.update(visible=False, interactive=False) for _ in range(24))
193
 
194
 
195
  def enable_order_buttons():
196
  return tuple(gr.update(interactive=True) for _ in range(4))
197
- def disable_order_buttons():
198
- return (gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=True))
 
 
 
199
 
200
  def clear_history():
201
  return None, "", None
 
177
  return tuple(gr.update(visible=False, interactive=False) for i in range(6))
178
  def disable_vote():
179
  return tuple(gr.update(interactive=False) for i in range(18))
180
+ def enable_vote_mode_buttons(mode, textbox):
181
  print(mode)
182
+ if not textbox.strip():
183
+ return tuple(gr.update(visible=False, interactive=False) for _ in range(24))
184
+ else:
185
+ if mode == "Best":
186
+ return (gr.update(visible=True, interactive=True),) * 5 + \
187
+ (gr.update(visible=False, interactive=False),) * 16 + \
188
+ (gr.update(visible=True, interactive=False),) * 2 + \
189
+ (gr.update(visible=True, interactive=True),)
190
+ elif mode == "Rank":
191
+ return (gr.update(visible=False, interactive=False),) * 5 + \
192
+ (gr.update(visible=True, interactive=True),) * 16 + \
193
+ (gr.update(visible=True, interactive=True),) * 3
194
  def disable_vote_mode_buttons():
195
  return tuple(gr.update(visible=False, interactive=False) for _ in range(24))
196
 
197
 
198
  def enable_order_buttons():
199
  return tuple(gr.update(interactive=True) for _ in range(4))
200
+ def disable_order_buttons(textbox):
201
+ if not textbox.strip():
202
+ return (gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True))
203
+ else:
204
+ return (gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=True))
205
 
206
  def clear_history():
207
  return None, "", None
serve/vote_utils.py CHANGED
@@ -769,8 +769,8 @@ def generate_igm_museum(gen_func, state0, state1, model_name0, model_name1, requ
769
 
770
 
771
  def generate_igm_annoy(gen_func, state0, state1, state2, state3, text, model_name0, model_name1, model_name2, model_name3, request: gr.Request):
772
- if not text:
773
- raise gr.Warning("Prompt cannot be empty.")
774
  if state0 is None:
775
  state0 = ImageStateIG(model_name0)
776
  if state1 is None:
 
769
 
770
 
771
  def generate_igm_annoy(gen_func, state0, state1, state2, state3, text, model_name0, model_name1, model_name2, model_name3, request: gr.Request):
772
+ if not text.strip():
773
+ return (gr.update(visible=False),) * 16
774
  if state0 is None:
775
  state0 = ImageStateIG(model_name0)
776
  if state1 is None: