Spaces:
Sleeping
Sleeping
Commit ·
2e80d4c
1
Parent(s): 0fafc69
Fix 3-band TIFF channel sorting bug caused by Gradio tmp dir paths
Browse files
app.py
CHANGED
|
@@ -536,12 +536,16 @@ def run_super_resolution(image_path, model_choice, progress=gr.Progress()):
|
|
| 536 |
if not all(p.lower().endswith(('.tif', '.tiff')) for p in paths):
|
| 537 |
raise gr.Error("When uploading multiple files, all must be TIFF files.")
|
| 538 |
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
|
|
|
|
|
|
|
|
|
| 542 |
|
| 543 |
if not (red_path and green_path and blue_path):
|
| 544 |
-
|
|
|
|
| 545 |
blue_path, green_path, red_path = paths[0], paths[1], paths[2]
|
| 546 |
|
| 547 |
try:
|
|
|
|
| 536 |
if not all(p.lower().endswith(('.tif', '.tiff')) for p in paths):
|
| 537 |
raise gr.Error("When uploading multiple files, all must be TIFF files.")
|
| 538 |
|
| 539 |
+
def get_basename(p):
|
| 540 |
+
return Path(p).name.upper()
|
| 541 |
+
|
| 542 |
+
red_path = next((p for p in paths if "B04" in get_basename(p) or "B4" in get_basename(p)), None)
|
| 543 |
+
green_path = next((p for p in paths if "B03" in get_basename(p) or "B3" in get_basename(p)), None)
|
| 544 |
+
blue_path = next((p for p in paths if "B02" in get_basename(p) or "B2" in get_basename(p)), None)
|
| 545 |
|
| 546 |
if not (red_path and green_path and blue_path):
|
| 547 |
+
# Sort by filename (not full path, to avoid Gradio temp dir randomness)
|
| 548 |
+
paths = sorted(paths, key=lambda p: Path(p).name)
|
| 549 |
blue_path, green_path, red_path = paths[0], paths[1], paths[2]
|
| 550 |
|
| 551 |
try:
|