DongfuJiang commited on
Commit
125d947
1 Parent(s): b1657de

fix bugs that operations in a single session having the same conv_id, which causes the saved data overlapped

Browse files
Files changed (1) hide show
  1. serve/vote_utils.py +30 -60
serve/vote_utils.py CHANGED
@@ -503,8 +503,7 @@ def generate_ig(gen_func, state, text, model_name, request: gr.Request):
503
  raise gr.Warning("Prompt cannot be empty.")
504
  if not model_name:
505
  raise gr.Warning("Model name cannot be empty.")
506
- if state is None:
507
- state = ImageStateIG(model_name)
508
  ip = get_ip(request)
509
  ig_logger.info(f"generate. ip: {ip}")
510
  start_tstamp = time.time()
@@ -541,8 +540,7 @@ def generate_ig(gen_func, state, text, model_name, request: gr.Request):
541
  def generate_ig_museum(gen_func, state, model_name, request: gr.Request):
542
  if not model_name:
543
  raise gr.Warning("Model name cannot be empty.")
544
- if state is None:
545
- state = ImageStateIG(model_name)
546
  ip = get_ip(request)
547
  ig_logger.info(f"generate. ip: {ip}")
548
  start_tstamp = time.time()
@@ -583,10 +581,8 @@ def generate_igm(gen_func, state0, state1, text, model_name0, model_name1, reque
583
  raise gr.Warning("Model name A cannot be empty.")
584
  if not model_name1:
585
  raise gr.Warning("Model name B cannot be empty.")
586
- if state0 is None:
587
- state0 = ImageStateIG(model_name0)
588
- if state1 is None:
589
- state1 = ImageStateIG(model_name1)
590
  ip = get_ip(request)
591
  igm_logger.info(f"generate. ip: {ip}")
592
  start_tstamp = time.time()
@@ -644,10 +640,8 @@ def generate_igm_museum(gen_func, state0, state1, model_name0, model_name1, requ
644
  raise gr.Warning("Model name A cannot be empty.")
645
  if not model_name1:
646
  raise gr.Warning("Model name B cannot be empty.")
647
- if state0 is None:
648
- state0 = ImageStateIG(model_name0)
649
- if state1 is None:
650
- state1 = ImageStateIG(model_name1)
651
  ip = get_ip(request)
652
  igm_logger.info(f"generate. ip: {ip}")
653
  start_tstamp = time.time()
@@ -704,10 +698,8 @@ def generate_igm_museum(gen_func, state0, state1, model_name0, model_name1, requ
704
  def generate_igm_annoy(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
705
  if not text:
706
  raise gr.Warning("Prompt cannot be empty.")
707
- if state0 is None:
708
- state0 = ImageStateIG(model_name0)
709
- if state1 is None:
710
- state1 = ImageStateIG(model_name1)
711
  ip = get_ip(request)
712
  igm_logger.info(f"generate. ip: {ip}")
713
  start_tstamp = time.time()
@@ -761,10 +753,8 @@ def generate_igm_annoy(gen_func, state0, state1, text, model_name0, model_name1,
761
  save_image_file_on_log_server(output_file)
762
 
763
  def generate_igm_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
764
- if state0 is None:
765
- state0 = ImageStateIG(model_name0)
766
- if state1 is None:
767
- state1 = ImageStateIG(model_name1)
768
  ip = get_ip(request)
769
  igm_logger.info(f"generate. ip: {ip}")
770
  start_tstamp = time.time()
@@ -828,8 +818,7 @@ def generate_ie(gen_func, state, source_text, target_text, instruct_text, source
828
  raise gr.Warning("Source image cannot be empty.")
829
  if not model_name:
830
  raise gr.Warning("Model name cannot be empty.")
831
- if state is None:
832
- state = ImageStateIE(model_name)
833
  ip = get_ip(request)
834
  ig_logger.info(f"generate. ip: {ip}")
835
  start_tstamp = time.time()
@@ -873,8 +862,7 @@ def generate_ie(gen_func, state, source_text, target_text, instruct_text, source
873
  def generate_ie_museum(gen_func, state, model_name, request: gr.Request):
874
  if not model_name:
875
  raise gr.Warning("Model name cannot be empty.")
876
- if state is None:
877
- state = ImageStateIE(model_name)
878
  ip = get_ip(request)
879
  ig_logger.info(f"generate. ip: {ip}")
880
  start_tstamp = time.time()
@@ -929,10 +917,8 @@ def generate_iem(gen_func, state0, state1, source_text, target_text, instruct_te
929
  raise gr.Warning("Model name A cannot be empty.")
930
  if not model_name1:
931
  raise gr.Warning("Model name B cannot be empty.")
932
- if state0 is None:
933
- state0 = ImageStateIE(model_name0)
934
- if state1 is None:
935
- state1 = ImageStateIE(model_name1)
936
  ip = get_ip(request)
937
  igm_logger.info(f"generate. ip: {ip}")
938
  start_tstamp = time.time()
@@ -999,10 +985,8 @@ def generate_iem_museum(gen_func, state0, state1, model_name0, model_name1, requ
999
  raise gr.Warning("Model name A cannot be empty.")
1000
  if not model_name1:
1001
  raise gr.Warning("Model name B cannot be empty.")
1002
- if state0 is None:
1003
- state0 = ImageStateIE(model_name0)
1004
- if state1 is None:
1005
- state1 = ImageStateIE(model_name1)
1006
  ip = get_ip(request)
1007
  igm_logger.info(f"generate. ip: {ip}")
1008
  start_tstamp = time.time()
@@ -1074,10 +1058,8 @@ def generate_iem_annoy(gen_func, state0, state1, source_text, target_text, instr
1074
  raise gr.Warning("Instruction prompt cannot be empty.")
1075
  if not source_image:
1076
  raise gr.Warning("Source image cannot be empty.")
1077
- if state0 is None:
1078
- state0 = ImageStateIE(model_name0)
1079
- if state1 is None:
1080
- state1 = ImageStateIE(model_name1)
1081
  ip = get_ip(request)
1082
  igm_logger.info(f"generate. ip: {ip}")
1083
  start_tstamp = time.time()
@@ -1141,10 +1123,8 @@ def generate_iem_annoy(gen_func, state0, state1, source_text, target_text, instr
1141
  save_image_file_on_log_server(output_file)
1142
 
1143
  def generate_iem_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1144
- if state0 is None:
1145
- state0 = ImageStateIE(model_name0)
1146
- if state1 is None:
1147
- state1 = ImageStateIE(model_name1)
1148
  ip = get_ip(request)
1149
  igm_logger.info(f"generate. ip: {ip}")
1150
  start_tstamp = time.time()
@@ -1212,8 +1192,7 @@ def generate_vg(gen_func, state, text, model_name, request: gr.Request):
1212
  raise gr.Warning("Prompt cannot be empty.")
1213
  if not model_name:
1214
  raise gr.Warning("Model name cannot be empty.")
1215
- if state is None:
1216
- state = VideoStateVG(model_name)
1217
  ip = get_ip(request)
1218
  vg_logger.info(f"generate. ip: {ip}")
1219
  start_tstamp = time.time()
@@ -1255,8 +1234,7 @@ def generate_vg(gen_func, state, text, model_name, request: gr.Request):
1255
  yield state, output_file
1256
 
1257
  def generate_vg_museum(gen_func, state, model_name, request: gr.Request):
1258
- if state is None:
1259
- state = VideoStateVG(model_name)
1260
  ip = get_ip(request)
1261
  vg_logger.info(f"generate. ip: {ip}")
1262
  start_tstamp = time.time()
@@ -1301,10 +1279,8 @@ def generate_vgm(gen_func, state0, state1, text, model_name0, model_name1, reque
1301
  raise gr.Warning("Model name A cannot be empty.")
1302
  if not model_name1:
1303
  raise gr.Warning("Model name B cannot be empty.")
1304
- if state0 is None:
1305
- state0 = VideoStateVG(model_name0)
1306
- if state1 is None:
1307
- state1 = VideoStateVG(model_name1)
1308
  ip = get_ip(request)
1309
  igm_logger.info(f"generate. ip: {ip}")
1310
  start_tstamp = time.time()
@@ -1372,10 +1348,8 @@ def generate_vgm(gen_func, state0, state1, text, model_name0, model_name1, reque
1372
  yield state0, state1, f'{VIDEO_DIR}/generation/{state0.conv_id}.mp4', f'{VIDEO_DIR}/generation/{state1.conv_id}.mp4'
1373
 
1374
  def generate_vgm_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1375
- if state0 is None:
1376
- state0 = VideoStateVG(model_name0)
1377
- if state1 is None:
1378
- state1 = VideoStateVG(model_name1)
1379
  ip = get_ip(request)
1380
  igm_logger.info(f"generate. ip: {ip}")
1381
  start_tstamp = time.time()
@@ -1441,10 +1415,8 @@ def generate_vgm_museum(gen_func, state0, state1, model_name0, model_name1, requ
1441
  def generate_vgm_annoy(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
1442
  if not text:
1443
  raise gr.Warning("Prompt cannot be empty.")
1444
- if state0 is None:
1445
- state0 = VideoStateVG(model_name0)
1446
- if state1 is None:
1447
- state1 = VideoStateVG(model_name1)
1448
  ip = get_ip(request)
1449
  vgm_logger.info(f"generate. ip: {ip}")
1450
  start_tstamp = time.time()
@@ -1507,10 +1479,8 @@ def generate_vgm_annoy(gen_func, state0, state1, text, model_name0, model_name1,
1507
  gr.Markdown(f"### Model A: {model_name0}", visible=False), gr.Markdown(f"### Model B: {model_name1}", visible=False)
1508
 
1509
  def generate_vgm_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1510
- if state0 is None:
1511
- state0 = VideoStateVG(model_name0)
1512
- if state1 is None:
1513
- state1 = VideoStateVG(model_name1)
1514
  ip = get_ip(request)
1515
  vgm_logger.info(f"generate. ip: {ip}")
1516
  start_tstamp = time.time()
 
503
  raise gr.Warning("Prompt cannot be empty.")
504
  if not model_name:
505
  raise gr.Warning("Model name cannot be empty.")
506
+ state = ImageStateIG(model_name)
 
507
  ip = get_ip(request)
508
  ig_logger.info(f"generate. ip: {ip}")
509
  start_tstamp = time.time()
 
540
  def generate_ig_museum(gen_func, state, model_name, request: gr.Request):
541
  if not model_name:
542
  raise gr.Warning("Model name cannot be empty.")
543
+ state = ImageStateIG(model_name)
 
544
  ip = get_ip(request)
545
  ig_logger.info(f"generate. ip: {ip}")
546
  start_tstamp = time.time()
 
581
  raise gr.Warning("Model name A cannot be empty.")
582
  if not model_name1:
583
  raise gr.Warning("Model name B cannot be empty.")
584
+ state0 = ImageStateIG(model_name0)
585
+ state1 = ImageStateIG(model_name1)
 
 
586
  ip = get_ip(request)
587
  igm_logger.info(f"generate. ip: {ip}")
588
  start_tstamp = time.time()
 
640
  raise gr.Warning("Model name A cannot be empty.")
641
  if not model_name1:
642
  raise gr.Warning("Model name B cannot be empty.")
643
+ state0 = ImageStateIG(model_name0)
644
+ state1 = ImageStateIG(model_name1)
 
 
645
  ip = get_ip(request)
646
  igm_logger.info(f"generate. ip: {ip}")
647
  start_tstamp = time.time()
 
698
  def generate_igm_annoy(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
699
  if not text:
700
  raise gr.Warning("Prompt cannot be empty.")
701
+ state0 = ImageStateIG(model_name0)
702
+ state1 = ImageStateIG(model_name1)
 
 
703
  ip = get_ip(request)
704
  igm_logger.info(f"generate. ip: {ip}")
705
  start_tstamp = time.time()
 
753
  save_image_file_on_log_server(output_file)
754
 
755
  def generate_igm_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
756
+ state0 = ImageStateIG(model_name0)
757
+ state1 = ImageStateIG(model_name1)
 
 
758
  ip = get_ip(request)
759
  igm_logger.info(f"generate. ip: {ip}")
760
  start_tstamp = time.time()
 
818
  raise gr.Warning("Source image cannot be empty.")
819
  if not model_name:
820
  raise gr.Warning("Model name cannot be empty.")
821
+ state = ImageStateIE(model_name)
 
822
  ip = get_ip(request)
823
  ig_logger.info(f"generate. ip: {ip}")
824
  start_tstamp = time.time()
 
862
  def generate_ie_museum(gen_func, state, model_name, request: gr.Request):
863
  if not model_name:
864
  raise gr.Warning("Model name cannot be empty.")
865
+ state = ImageStateIE(model_name)
 
866
  ip = get_ip(request)
867
  ig_logger.info(f"generate. ip: {ip}")
868
  start_tstamp = time.time()
 
917
  raise gr.Warning("Model name A cannot be empty.")
918
  if not model_name1:
919
  raise gr.Warning("Model name B cannot be empty.")
920
+ state0 = ImageStateIE(model_name0)
921
+ state1 = ImageStateIE(model_name1)
 
 
922
  ip = get_ip(request)
923
  igm_logger.info(f"generate. ip: {ip}")
924
  start_tstamp = time.time()
 
985
  raise gr.Warning("Model name A cannot be empty.")
986
  if not model_name1:
987
  raise gr.Warning("Model name B cannot be empty.")
988
+ state0 = ImageStateIE(model_name0)
989
+ state1 = ImageStateIE(model_name1)
 
 
990
  ip = get_ip(request)
991
  igm_logger.info(f"generate. ip: {ip}")
992
  start_tstamp = time.time()
 
1058
  raise gr.Warning("Instruction prompt cannot be empty.")
1059
  if not source_image:
1060
  raise gr.Warning("Source image cannot be empty.")
1061
+ state0 = ImageStateIE(model_name0)
1062
+ state1 = ImageStateIE(model_name1)
 
 
1063
  ip = get_ip(request)
1064
  igm_logger.info(f"generate. ip: {ip}")
1065
  start_tstamp = time.time()
 
1123
  save_image_file_on_log_server(output_file)
1124
 
1125
  def generate_iem_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1126
+ state0 = ImageStateIE(model_name0)
1127
+ state1 = ImageStateIE(model_name1)
 
 
1128
  ip = get_ip(request)
1129
  igm_logger.info(f"generate. ip: {ip}")
1130
  start_tstamp = time.time()
 
1192
  raise gr.Warning("Prompt cannot be empty.")
1193
  if not model_name:
1194
  raise gr.Warning("Model name cannot be empty.")
1195
+ state = VideoStateVG(model_name)
 
1196
  ip = get_ip(request)
1197
  vg_logger.info(f"generate. ip: {ip}")
1198
  start_tstamp = time.time()
 
1234
  yield state, output_file
1235
 
1236
  def generate_vg_museum(gen_func, state, model_name, request: gr.Request):
1237
+ state = VideoStateVG(model_name)
 
1238
  ip = get_ip(request)
1239
  vg_logger.info(f"generate. ip: {ip}")
1240
  start_tstamp = time.time()
 
1279
  raise gr.Warning("Model name A cannot be empty.")
1280
  if not model_name1:
1281
  raise gr.Warning("Model name B cannot be empty.")
1282
+ state0 = VideoStateVG(model_name0)
1283
+ state1 = VideoStateVG(model_name1)
 
 
1284
  ip = get_ip(request)
1285
  igm_logger.info(f"generate. ip: {ip}")
1286
  start_tstamp = time.time()
 
1348
  yield state0, state1, f'{VIDEO_DIR}/generation/{state0.conv_id}.mp4', f'{VIDEO_DIR}/generation/{state1.conv_id}.mp4'
1349
 
1350
  def generate_vgm_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1351
+ state0 = VideoStateVG(model_name0)
1352
+ state1 = VideoStateVG(model_name1)
 
 
1353
  ip = get_ip(request)
1354
  igm_logger.info(f"generate. ip: {ip}")
1355
  start_tstamp = time.time()
 
1415
  def generate_vgm_annoy(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
1416
  if not text:
1417
  raise gr.Warning("Prompt cannot be empty.")
1418
+ state0 = VideoStateVG(model_name0)
1419
+ state1 = VideoStateVG(model_name1)
 
 
1420
  ip = get_ip(request)
1421
  vgm_logger.info(f"generate. ip: {ip}")
1422
  start_tstamp = time.time()
 
1479
  gr.Markdown(f"### Model A: {model_name0}", visible=False), gr.Markdown(f"### Model B: {model_name1}", visible=False)
1480
 
1481
  def generate_vgm_annoy_museum(gen_func, state0, state1, model_name0, model_name1, request: gr.Request):
1482
+ state0 = VideoStateVG(model_name0)
1483
+ state1 = VideoStateVG(model_name1)
 
 
1484
  ip = get_ip(request)
1485
  vgm_logger.info(f"generate. ip: {ip}")
1486
  start_tstamp = time.time()