Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
d160b6d
1
Parent(s):
9da4dc3
Testing add on FluxEdit
Browse files- model/model_manager.py +77 -5
- model/model_registry.py +10 -0
- model/models/__init__.py +2 -2
model/model_manager.py
CHANGED
|
@@ -171,8 +171,22 @@ class ModelManager:
|
|
| 171 |
def generate_image_ig_parallel_anony(self, prompt, model_A, model_B):
|
| 172 |
# Using list comprehension to get the difference between two lists
|
| 173 |
picking_list = [item for item in self.model_ig_list if item not in self.excluding_model_list]
|
|
|
|
| 174 |
if model_A == "" and model_B == "":
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
else:
|
| 177 |
model_names = [model_A, model_B]
|
| 178 |
|
|
@@ -185,8 +199,22 @@ class ModelManager:
|
|
| 185 |
def generate_image_ig_museum_parallel_anony(self, model_A, model_B):
|
| 186 |
# Using list comprehension to get the difference between two lists
|
| 187 |
picking_list = [item for item in self.model_ig_list if item not in self.excluding_model_list]
|
|
|
|
| 188 |
if model_A == "" and model_B == "":
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
else:
|
| 191 |
model_names = [model_A, model_B]
|
| 192 |
|
|
@@ -259,10 +287,25 @@ class ModelManager:
|
|
| 259 |
def generate_image_ie_parallel_anony(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
|
| 260 |
# Using list comprehension to get the difference between two lists
|
| 261 |
picking_list = [item for item in self.model_ie_list if item not in self.excluding_model_list]
|
|
|
|
| 262 |
if model_A == "" and model_B == "":
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
else:
|
| 265 |
model_names = [model_A, model_B]
|
|
|
|
| 266 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 267 |
futures = [executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image, model) for model in model_names]
|
| 268 |
results = [future.result() for future in futures]
|
|
@@ -271,10 +314,25 @@ class ModelManager:
|
|
| 271 |
def generate_image_ie_museum_parallel_anony(self, model_A, model_B):
|
| 272 |
# Using list comprehension to get the difference between two lists
|
| 273 |
picking_list = [item for item in self.model_ie_list if item not in self.excluding_model_list]
|
|
|
|
| 274 |
if model_A == "" and model_B == "":
|
| 275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
else:
|
| 277 |
model_names = [model_A, model_B]
|
|
|
|
| 278 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 279 |
model_1 = model_names[0].split('_')[1]
|
| 280 |
model_2 = model_names[1].split('_')[1]
|
|
@@ -313,8 +371,22 @@ class ModelManager:
|
|
| 313 |
def generate_video_vg_parallel_anony(self, prompt, model_A, model_B):
|
| 314 |
# Using list comprehension to get the difference between two lists
|
| 315 |
picking_list = [item for item in self.model_vg_list if item not in self.excluding_model_list]
|
|
|
|
| 316 |
if model_A == "" and model_B == "":
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
else:
|
| 319 |
model_names = [model_A, model_B]
|
| 320 |
|
|
|
|
| 171 |
def generate_image_ig_parallel_anony(self, prompt, model_A, model_B):
|
| 172 |
# Using list comprehension to get the difference between two lists
|
| 173 |
picking_list = [item for item in self.model_ig_list if item not in self.excluding_model_list]
|
| 174 |
+
|
| 175 |
if model_A == "" and model_B == "":
|
| 176 |
+
# Filter desired_model_list to only include models that exist in picking_list
|
| 177 |
+
valid_desired_models = [m for m in self.desired_model_list if m in picking_list]
|
| 178 |
+
|
| 179 |
+
# 50% (or DESIRED_APPEAR_MODEL_CHANCE) chance to include exactly one model from valid desired_model_list
|
| 180 |
+
if valid_desired_models and random.random() < DESIRED_APPEAR_MODEL_CHANCE:
|
| 181 |
+
# Pick one model from valid desired list
|
| 182 |
+
desired_model = random.choice(valid_desired_models)
|
| 183 |
+
# Pick one model from regular list, excluding desired models
|
| 184 |
+
regular_model = random.choice([m for m in picking_list if m not in valid_desired_models])
|
| 185 |
+
# Randomly determine order
|
| 186 |
+
model_names = [desired_model, regular_model] if random.random() < 0.5 else [regular_model, desired_model]
|
| 187 |
+
else:
|
| 188 |
+
# Pick two models from the regular picking list
|
| 189 |
+
model_names = random.sample([model for model in picking_list], 2)
|
| 190 |
else:
|
| 191 |
model_names = [model_A, model_B]
|
| 192 |
|
|
|
|
| 199 |
def generate_image_ig_museum_parallel_anony(self, model_A, model_B):
|
| 200 |
# Using list comprehension to get the difference between two lists
|
| 201 |
picking_list = [item for item in self.model_ig_list if item not in self.excluding_model_list]
|
| 202 |
+
|
| 203 |
if model_A == "" and model_B == "":
|
| 204 |
+
# Filter desired_model_list to only include models that exist in picking_list
|
| 205 |
+
valid_desired_models = [m for m in self.desired_model_list if m in picking_list]
|
| 206 |
+
|
| 207 |
+
# 50% (or DESIRED_APPEAR_MODEL_CHANCE) chance to include exactly one model from valid desired_model_list
|
| 208 |
+
if valid_desired_models and random.random() < DESIRED_APPEAR_MODEL_CHANCE:
|
| 209 |
+
# Pick one model from valid desired list
|
| 210 |
+
desired_model = random.choice(valid_desired_models)
|
| 211 |
+
# Pick one model from regular list, excluding desired models
|
| 212 |
+
regular_model = random.choice([m for m in picking_list if m not in valid_desired_models])
|
| 213 |
+
# Randomly determine order
|
| 214 |
+
model_names = [desired_model, regular_model] if random.random() < 0.5 else [regular_model, desired_model]
|
| 215 |
+
else:
|
| 216 |
+
# Pick two models from the regular picking list
|
| 217 |
+
model_names = random.sample([model for model in picking_list], 2)
|
| 218 |
else:
|
| 219 |
model_names = [model_A, model_B]
|
| 220 |
|
|
|
|
| 287 |
def generate_image_ie_parallel_anony(self, textbox_source, textbox_target, textbox_instruct, source_image, model_A, model_B):
|
| 288 |
# Using list comprehension to get the difference between two lists
|
| 289 |
picking_list = [item for item in self.model_ie_list if item not in self.excluding_model_list]
|
| 290 |
+
|
| 291 |
if model_A == "" and model_B == "":
|
| 292 |
+
# Filter desired_model_list to only include models that exist in picking_list
|
| 293 |
+
valid_desired_models = [m for m in self.desired_model_list if m in picking_list]
|
| 294 |
+
|
| 295 |
+
# 50% (or DESIRED_APPEAR_MODEL_CHANCE) chance to include exactly one model from valid desired_model_list
|
| 296 |
+
if valid_desired_models and random.random() < DESIRED_APPEAR_MODEL_CHANCE:
|
| 297 |
+
# Pick one model from valid desired list
|
| 298 |
+
desired_model = random.choice(valid_desired_models)
|
| 299 |
+
# Pick one model from regular list, excluding desired models
|
| 300 |
+
regular_model = random.choice([m for m in picking_list if m not in valid_desired_models])
|
| 301 |
+
# Randomly determine order
|
| 302 |
+
model_names = [desired_model, regular_model] if random.random() < 0.5 else [regular_model, desired_model]
|
| 303 |
+
else:
|
| 304 |
+
# Pick two models from the regular picking list
|
| 305 |
+
model_names = random.sample([model for model in picking_list], 2)
|
| 306 |
else:
|
| 307 |
model_names = [model_A, model_B]
|
| 308 |
+
|
| 309 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 310 |
futures = [executor.submit(self.generate_image_ie, textbox_source, textbox_target, textbox_instruct, source_image, model) for model in model_names]
|
| 311 |
results = [future.result() for future in futures]
|
|
|
|
| 314 |
def generate_image_ie_museum_parallel_anony(self, model_A, model_B):
|
| 315 |
# Using list comprehension to get the difference between two lists
|
| 316 |
picking_list = [item for item in self.model_ie_list if item not in self.excluding_model_list]
|
| 317 |
+
|
| 318 |
if model_A == "" and model_B == "":
|
| 319 |
+
# Filter desired_model_list to only include models that exist in picking_list
|
| 320 |
+
valid_desired_models = [m for m in self.desired_model_list if m in picking_list]
|
| 321 |
+
|
| 322 |
+
# 50% (or DESIRED_APPEAR_MODEL_CHANCE) chance to include exactly one model from valid desired_model_list
|
| 323 |
+
if valid_desired_models and random.random() < DESIRED_APPEAR_MODEL_CHANCE:
|
| 324 |
+
# Pick one model from valid desired list
|
| 325 |
+
desired_model = random.choice(valid_desired_models)
|
| 326 |
+
# Pick one model from regular list, excluding desired models
|
| 327 |
+
regular_model = random.choice([m for m in picking_list if m not in valid_desired_models])
|
| 328 |
+
# Randomly determine order
|
| 329 |
+
model_names = [desired_model, regular_model] if random.random() < 0.5 else [regular_model, desired_model]
|
| 330 |
+
else:
|
| 331 |
+
# Pick two models from the regular picking list
|
| 332 |
+
model_names = random.sample([model for model in picking_list], 2)
|
| 333 |
else:
|
| 334 |
model_names = [model_A, model_B]
|
| 335 |
+
|
| 336 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 337 |
model_1 = model_names[0].split('_')[1]
|
| 338 |
model_2 = model_names[1].split('_')[1]
|
|
|
|
| 371 |
def generate_video_vg_parallel_anony(self, prompt, model_A, model_B):
|
| 372 |
# Using list comprehension to get the difference between two lists
|
| 373 |
picking_list = [item for item in self.model_vg_list if item not in self.excluding_model_list]
|
| 374 |
+
|
| 375 |
if model_A == "" and model_B == "":
|
| 376 |
+
# Filter desired_model_list to only include models that exist in picking_list
|
| 377 |
+
valid_desired_models = [m for m in self.desired_model_list if m in picking_list]
|
| 378 |
+
|
| 379 |
+
# 50% (or DESIRED_APPEAR_MODEL_CHANCE) chance to include exactly one model from valid desired_model_list
|
| 380 |
+
if valid_desired_models and random.random() < DESIRED_APPEAR_MODEL_CHANCE:
|
| 381 |
+
# Pick one model from valid desired list
|
| 382 |
+
desired_model = random.choice(valid_desired_models)
|
| 383 |
+
# Pick one model from regular list, excluding desired models
|
| 384 |
+
regular_model = random.choice([m for m in picking_list if m not in valid_desired_models])
|
| 385 |
+
# Randomly determine order
|
| 386 |
+
model_names = [desired_model, regular_model] if random.random() < 0.5 else [regular_model, desired_model]
|
| 387 |
+
else:
|
| 388 |
+
# Pick two models from the regular picking list
|
| 389 |
+
model_names = random.sample([model for model in picking_list], 2)
|
| 390 |
else:
|
| 391 |
model_names = [model_A, model_B]
|
| 392 |
|
model/model_registry.py
CHANGED
|
@@ -331,6 +331,16 @@ register_model_info(
|
|
| 331 |
"image_edition"
|
| 332 |
)
|
| 333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
register_model_info(
|
| 335 |
["fal_stable-cascade_text2image"],
|
| 336 |
"StableCascade",
|
|
|
|
| 331 |
"image_edition"
|
| 332 |
)
|
| 333 |
|
| 334 |
+
register_model_info(
|
| 335 |
+
["imagenhub_FluxEdit_edition"],
|
| 336 |
+
"FluxEdit",
|
| 337 |
+
"https://github.com/sayakpaul/flux-image-editing",
|
| 338 |
+
"Flux Control trained on OmniEdit dataset",
|
| 339 |
+
"Apache 2.0",
|
| 340 |
+
"HuggingFace",
|
| 341 |
+
"image_edition"
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
register_model_info(
|
| 345 |
["fal_stable-cascade_text2image"],
|
| 346 |
"StableCascade",
|
model/models/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ IMAGE_GENERATION_MODELS = ['imagenhub_SDXLTurbo_generation','imagenhub_SDXL_gene
|
|
| 15 |
IMAGE_EDITION_MODELS = ['imagenhub_CycleDiffusion_edition', 'imagenhub_Pix2PixZero_edition', 'imagenhub_Prompt2prompt_edition',
|
| 16 |
'imagenhub_SDEdit_edition', 'imagenhub_InstructPix2Pix_edition',
|
| 17 |
'imagenhub_MagicBrush_edition', 'imagenhub_PNP_edition',
|
| 18 |
-
'imagenhub_InfEdit_edition', 'imagenhub_CosXLEdit_edition', 'imagenhub_UltraEdit_edition', 'imagenhub_AURORA_edition']
|
| 19 |
VIDEO_GENERATION_MODELS = ['fal_AnimateDiff_text2video',
|
| 20 |
'fal_AnimateDiffTurbo_text2video',
|
| 21 |
#'videogenhub_LaVie_generation',
|
|
@@ -37,7 +37,7 @@ MAP_NAMES_IMAGENHUB = {}
|
|
| 37 |
MAP_NAMES_VIDEOGENHUB = {"CogVideoX-2B": "CogVideoX", "CogVideoX-5B": "CogVideoX5B"}
|
| 38 |
|
| 39 |
MUSEUM_UNSUPPORTED_MODELS = []
|
| 40 |
-
DESIRED_APPEAR_MODEL = []
|
| 41 |
DESIRED_APPEAR_MODEL_CHANCE = 0.5
|
| 42 |
|
| 43 |
ALL_MODELS = IMAGE_GENERATION_MODELS + IMAGE_EDITION_MODELS + VIDEO_GENERATION_MODELS
|
|
|
|
| 15 |
IMAGE_EDITION_MODELS = ['imagenhub_CycleDiffusion_edition', 'imagenhub_Pix2PixZero_edition', 'imagenhub_Prompt2prompt_edition',
|
| 16 |
'imagenhub_SDEdit_edition', 'imagenhub_InstructPix2Pix_edition',
|
| 17 |
'imagenhub_MagicBrush_edition', 'imagenhub_PNP_edition',
|
| 18 |
+
'imagenhub_InfEdit_edition', 'imagenhub_CosXLEdit_edition', 'imagenhub_UltraEdit_edition', 'imagenhub_AURORA_edition', 'imagenhub_FluxEdit_edition']
|
| 19 |
VIDEO_GENERATION_MODELS = ['fal_AnimateDiff_text2video',
|
| 20 |
'fal_AnimateDiffTurbo_text2video',
|
| 21 |
#'videogenhub_LaVie_generation',
|
|
|
|
| 37 |
MAP_NAMES_VIDEOGENHUB = {"CogVideoX-2B": "CogVideoX", "CogVideoX-5B": "CogVideoX5B"}
|
| 38 |
|
| 39 |
MUSEUM_UNSUPPORTED_MODELS = []
|
| 40 |
+
DESIRED_APPEAR_MODEL = ['imagenhub_FluxEdit_edition', 'imagenhub_AURORA_edition']
|
| 41 |
DESIRED_APPEAR_MODEL_CHANCE = 0.5
|
| 42 |
|
| 43 |
ALL_MODELS = IMAGE_GENERATION_MODELS + IMAGE_EDITION_MODELS + VIDEO_GENERATION_MODELS
|