Surn commited on
Commit
16e4012
·
1 Parent(s): 48ec05f

Fix Template Image selection mismatch

Browse files
Files changed (2) hide show
  1. utils/constants.py +27 -0
  2. utils/image_utils.py +22 -9
utils/constants.py CHANGED
@@ -240,6 +240,9 @@ LORA_DETAILS = {
240
  "parameters" :{
241
  "num_inference_steps": "30"
242
  }
 
 
 
243
  }
244
  ],
245
  "XLabs-AI/flux-lora-collection/anime_lora.safetensors":[
@@ -257,6 +260,9 @@ LORA_DETAILS = {
257
  "parameters" :{
258
  "num_inference_steps": "30"
259
  }
 
 
 
260
  }
261
  ],
262
  "XLabs-AI/flux-lora-collection/scenery_lora.safetensors":[
@@ -274,6 +280,9 @@ LORA_DETAILS = {
274
  "parameters" :{
275
  "num_inference_steps": "30"
276
  }
 
 
 
277
  }
278
  ],
279
  "XLabs-AI/flux-lora-collection/disney_lora.safetensors":[
@@ -291,6 +300,9 @@ LORA_DETAILS = {
291
  "parameters" :{
292
  "num_inference_steps": "30"
293
  }
 
 
 
294
  }
295
  ],
296
  "XLabs-AI/flux-RealismLora":[
@@ -303,6 +315,9 @@ LORA_DETAILS = {
303
  "num_inference_steps": "34",
304
  "scale": "0.85"
305
  }
 
 
 
306
  }
307
  ],
308
  "Cossale/Frames2-Flex.1": [
@@ -320,6 +335,9 @@ LORA_DETAILS = {
320
  "parameters" :{
321
  "num_inference_steps": "50"
322
  }
 
 
 
323
  }
324
  ],
325
  "Yuanshi/OminiControl": [
@@ -339,6 +357,9 @@ LORA_DETAILS = {
339
  },
340
  {
341
  "notes": "Select an Image as a guide."
 
 
 
342
  }
343
  ],
344
  "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design": [
@@ -357,6 +378,9 @@ LORA_DETAILS = {
357
  "parameters" :{
358
  "num_inference_steps": "38"
359
  }
 
 
 
360
  }
361
  ],
362
  "Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1": [
@@ -372,6 +396,9 @@ LORA_DETAILS = {
372
  "guidance_scale": "3.5",
373
  "num_inference_steps": "38"
374
  }
 
 
 
375
  }
376
  ]
377
  }
 
240
  "parameters" :{
241
  "num_inference_steps": "30"
242
  }
243
+ },
244
+ {
245
+ "thumbnail": ""
246
  }
247
  ],
248
  "XLabs-AI/flux-lora-collection/anime_lora.safetensors":[
 
260
  "parameters" :{
261
  "num_inference_steps": "30"
262
  }
263
+ },
264
+ {
265
+ "thumbnail": ""
266
  }
267
  ],
268
  "XLabs-AI/flux-lora-collection/scenery_lora.safetensors":[
 
280
  "parameters" :{
281
  "num_inference_steps": "30"
282
  }
283
+ },
284
+ {
285
+ "thumbnail": ""
286
  }
287
  ],
288
  "XLabs-AI/flux-lora-collection/disney_lora.safetensors":[
 
300
  "parameters" :{
301
  "num_inference_steps": "30"
302
  }
303
+ },
304
+ {
305
+ "thumbnail": ""
306
  }
307
  ],
308
  "XLabs-AI/flux-RealismLora":[
 
315
  "num_inference_steps": "34",
316
  "scale": "0.85"
317
  }
318
+ },
319
+ {
320
+ "thumbnail": ""
321
  }
322
  ],
323
  "Cossale/Frames2-Flex.1": [
 
335
  "parameters" :{
336
  "num_inference_steps": "50"
337
  }
338
+ },
339
+ {
340
+ "thumbnail": ""
341
  }
342
  ],
343
  "Yuanshi/OminiControl": [
 
357
  },
358
  {
359
  "notes": "Select an Image as a guide."
360
+ },
361
+ {
362
+ "thumbnail": ""
363
  }
364
  ],
365
  "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design": [
 
378
  "parameters" :{
379
  "num_inference_steps": "38"
380
  }
381
+ },
382
+ {
383
+ "thumbnail": ""
384
  }
385
  ],
386
  "Borcherding/FLUX.1-dev-LoRA-FractalLand-v0.1": [
 
396
  "guidance_scale": "3.5",
397
  "num_inference_steps": "38"
398
  }
399
+ },
400
+ {
401
+ "thumbnail": ""
402
  }
403
  ]
404
  }
utils/image_utils.py CHANGED
@@ -100,21 +100,34 @@ def build_prerendered_images(images_list):
100
  # Example usage
101
  # filtered_maps = get_maps_with_quality_less_than(3)
102
  # print(filtered_maps)
103
- def build_prerendered_images_by_quality(quality_limit,key='file'):
104
  """
105
- Retrieve all file paths from PRE_RENDERED_MAPS_JSON_LEVELS where quality is less than the given limit.
106
-
 
107
  Args:
108
- limit (int): The quality threshold.
109
-
 
110
  Returns:
111
- list: A list of file paths meeting the quality criteria.
112
- """
 
 
 
 
 
 
 
 
 
 
113
  images_list = [
114
- map_info[key]
115
- for map_info in PRE_RENDERED_MAPS_JSON_LEVELS.values()
116
  if map_info['quality'] <= quality_limit
117
  ]
 
118
  return build_prerendered_images(images_list)
119
 
120
 
 
100
  # Example usage
101
  # filtered_maps = get_maps_with_quality_less_than(3)
102
  # print(filtered_maps)
103
+ def build_prerendered_images_by_quality(quality_limit, key='file'):
104
  """
105
+ Retrieve and sort file paths from PRE_RENDERED_MAPS_JSON_LEVELS where quality is less than or equal to the given limit.
106
+ The sorting order matches pre_rendered_maps_paths based on quality and a case-insensitive alphanumeric key.
107
+
108
  Args:
109
+ quality_limit (int): The quality threshold.
110
+ key (str): The key to extract the file path from each map info (default is 'file').
111
+
112
  Returns:
113
+ list: A list of sorted file paths meeting the quality criteria.
114
+ """
115
+ # Sort the PRE_RENDERED_MAPS_JSON_LEVELS items by quality and alphanumeric key
116
+ sorted_maps = sorted(
117
+ PRE_RENDERED_MAPS_JSON_LEVELS.items(),
118
+ key=lambda x: (
119
+ x[1]['quality'],
120
+ ''.join(char.lower() for char in x[0] if char.isalnum())
121
+ )
122
+ )
123
+
124
+ # Filter and extract the file paths that meet the quality limit
125
  images_list = [
126
+ map_info[key].replace("\\", "/")
127
+ for _, map_info in sorted_maps
128
  if map_info['quality'] <= quality_limit
129
  ]
130
+
131
  return build_prerendered_images(images_list)
132
 
133