Spaces:
Sleeping
Sleeping
$P@D$3RV£R commited on
Commit ·
8d4ba5d
1
Parent(s): 5eacbd3
Fix all indentation errors in try block - complete fix
Browse files
app.py
CHANGED
|
@@ -310,44 +310,44 @@ def tagger():
|
|
| 310 |
if not isinstance(current_folder_set, dict) or 'image_sets' not in current_folder_set:
|
| 311 |
raise ValueError(f"Invalid folder set structure at index {app.config['HEAD']}")
|
| 312 |
|
| 313 |
-
|
| 314 |
-
|
| 315 |
if image_set_index < 0:
|
| 316 |
image_set_index = 0
|
| 317 |
app.config["IMAGE_SET_INDEX"] = 0
|
| 318 |
|
| 319 |
-
|
| 320 |
-
|
| 321 |
if not isinstance(image_sets, list) or len(image_sets) == 0:
|
| 322 |
raise ValueError(f"No image sets found in folder {current_folder_set.get('folder', 'unknown')}")
|
| 323 |
|
| 324 |
-
|
| 325 |
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
if not isinstance(current_set, dict):
|
| 336 |
raise ValueError(f"Invalid image set structure at index {image_set_index}")
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
|
| 352 |
except (IndexError, KeyError, ValueError) as e:
|
| 353 |
print(f"Error accessing folder/image data: {e}")
|
|
|
|
| 310 |
if not isinstance(current_folder_set, dict) or 'image_sets' not in current_folder_set:
|
| 311 |
raise ValueError(f"Invalid folder set structure at index {app.config['HEAD']}")
|
| 312 |
|
| 313 |
+
# Get current image set index (default to 0 if not set)
|
| 314 |
+
image_set_index = app.config.get("IMAGE_SET_INDEX", 0)
|
| 315 |
if image_set_index < 0:
|
| 316 |
image_set_index = 0
|
| 317 |
app.config["IMAGE_SET_INDEX"] = 0
|
| 318 |
|
| 319 |
+
# Get image sets for current folder
|
| 320 |
+
image_sets = current_folder_set['image_sets']
|
| 321 |
if not isinstance(image_sets, list) or len(image_sets) == 0:
|
| 322 |
raise ValueError(f"No image sets found in folder {current_folder_set.get('folder', 'unknown')}")
|
| 323 |
|
| 324 |
+
max_sets = len(image_sets)
|
| 325 |
|
| 326 |
+
# Ensure image_set_index is within bounds
|
| 327 |
+
if image_set_index >= max_sets:
|
| 328 |
+
image_set_index = 0
|
| 329 |
+
app.config["IMAGE_SET_INDEX"] = 0
|
| 330 |
|
| 331 |
+
# Get current set of 3 images (all with same file ID prefix)
|
| 332 |
+
current_images = []
|
| 333 |
+
if image_set_index < max_sets:
|
| 334 |
+
current_set = image_sets[image_set_index]
|
| 335 |
if not isinstance(current_set, dict):
|
| 336 |
raise ValueError(f"Invalid image set structure at index {image_set_index}")
|
| 337 |
|
| 338 |
+
# Validate required keys exist
|
| 339 |
+
required_keys = ['sr_int_full', 'tr_line', 'tr_int_full']
|
| 340 |
+
for key in required_keys:
|
| 341 |
+
if key not in current_set:
|
| 342 |
+
raise ValueError(f"Missing required image key '{key}' in image set {image_set_index}")
|
| 343 |
|
| 344 |
+
current_images = [
|
| 345 |
+
current_set['sr_int_full'],
|
| 346 |
+
current_set['tr_line'],
|
| 347 |
+
current_set['tr_int_full']
|
| 348 |
+
]
|
| 349 |
+
else:
|
| 350 |
+
raise ValueError(f"Image set index {image_set_index} out of bounds (max: {max_sets})")
|
| 351 |
|
| 352 |
except (IndexError, KeyError, ValueError) as e:
|
| 353 |
print(f"Error accessing folder/image data: {e}")
|