tianleliphoebe commited on
Commit
a071819
1 Parent(s): 26dad4e

fix order bug

Browse files
Files changed (1) hide show
  1. model/model_manager.py +14 -31
model/model_manager.py CHANGED
@@ -34,22 +34,16 @@ class ModelManager:
34
  else:
35
  model_names = [model_A, model_B]
36
 
37
- results = []
38
  with concurrent.futures.ThreadPoolExecutor() as executor:
39
- future_to_result = {executor.submit(self.generate_image_ig, prompt, model): model for model in model_names}
40
- for future in future_to_result:
41
- result = future.result()
42
- results.append(result)
43
  return results[0], results[1], model_names[0], model_names[1]
44
 
45
  def generate_image_ig_parallel(self, prompt, model_A, model_B):
46
- results = []
47
  model_names = [model_A, model_B]
48
  with concurrent.futures.ThreadPoolExecutor() as executor:
49
- future_to_result = {executor.submit(self.generate_image_ig, prompt, model): model for model in model_names}
50
- for future in future_to_result:
51
- result = future.result()
52
- results.append(result)
53
  return results[0], results[1]
54
 
55
  @spaces.GPU(duration=150)
@@ -59,13 +53,12 @@ class ModelManager:
59
  return result
60
 
61
  def generate_image_ie_parallel(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
62
- results = []
63
  model_names = [model_A, model_B]
64
  with concurrent.futures.ThreadPoolExecutor() as executor:
65
- future_to_result = {executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image, model): model for model in model_names}
66
- for future in future_to_result:
67
- result = future.result()
68
- results.append(result)
69
  return results[0], results[1]
70
 
71
  def generate_image_ie_parallel_anony(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
@@ -73,13 +66,9 @@ class ModelManager:
73
  model_names = random.sample([model for model in self.model_ie_list], 2)
74
  else:
75
  model_names = [model_A, model_B]
76
- results = []
77
- # model_names = [model_A, model_B]
78
  with concurrent.futures.ThreadPoolExecutor() as executor:
79
- future_to_result = {executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image, model): model for model in model_names}
80
- for future in future_to_result:
81
- result = future.result()
82
- results.append(result)
83
  return results[0], results[1], model_names[0], model_names[1]
84
 
85
  @spaces.GPU(duration=150)
@@ -94,20 +83,14 @@ class ModelManager:
94
  else:
95
  model_names = [model_A, model_B]
96
 
97
- results = []
98
  with concurrent.futures.ThreadPoolExecutor() as executor:
99
- future_to_result = {executor.submit(self.generate_video_vg, prompt, model): model for model in model_names}
100
- for future in future_to_result:
101
- result = future.result()
102
- results.append(result)
103
  return results[0], results[1], model_names[0], model_names[1]
104
 
105
  def generate_video_vg_parallel(self, prompt, model_A, model_B):
106
- results = []
107
  model_names = [model_A, model_B]
108
  with concurrent.futures.ThreadPoolExecutor() as executor:
109
- future_to_result = {executor.submit(self.generate_video_vg, prompt, model): model for model in model_names}
110
- for future in future_to_result:
111
- result = future.result()
112
- results.append(result)
113
  return results[0], results[1]
 
34
  else:
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
 
49
  @spaces.GPU(duration=150)
 
53
  return result
54
 
55
  def generate_image_ie_parallel(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
 
56
  model_names = [model_A, model_B]
57
  with concurrent.futures.ThreadPoolExecutor() as executor:
58
+ futures = [
59
+ executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image,
60
+ model) for model in model_names]
61
+ results = [future.result() for future in futures]
62
  return results[0], results[1]
63
 
64
  def generate_image_ie_parallel_anony(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
 
66
  model_names = random.sample([model for model in self.model_ie_list], 2)
67
  else:
68
  model_names = [model_A, model_B]
 
 
69
  with concurrent.futures.ThreadPoolExecutor() as executor:
70
+ futures = [executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image, model) for model in model_names]
71
+ results = [future.result() for future in futures]
 
 
72
  return results[0], results[1], model_names[0], model_names[1]
73
 
74
  @spaces.GPU(duration=150)
 
83
  else:
84
  model_names = [model_A, model_B]
85
 
 
86
  with concurrent.futures.ThreadPoolExecutor() as executor:
87
+ futures = [executor.submit(self.generate_image_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_image_vg, prompt, model) for model in model_names]
95
+ results = [future.result() for future in futures]
 
 
96
  return results[0], results[1]