Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -435,6 +435,20 @@ def create_demo():
|
|
| 435 |
file_paths.append(f[0])
|
| 436 |
else:
|
| 437 |
file_paths.append(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
|
| 439 |
# Update configuration
|
| 440 |
basic_stitcher.config['feature_extractor'] = feature_type
|
|
@@ -444,10 +458,11 @@ def create_demo():
|
|
| 444 |
basic_stitcher.config['ransac_threshold'] = ransac_thresh
|
| 445 |
|
| 446 |
# Load images
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
|
|
|
| 451 |
|
| 452 |
def process_zip_with_metadata(zip_file, feature_type, matcher_type, use_clahe, detect_labels, ransac_thresh):
|
| 453 |
"""Process ZIP file containing images and metadata"""
|
|
|
|
| 435 |
file_paths.append(f[0])
|
| 436 |
else:
|
| 437 |
file_paths.append(f)
|
| 438 |
+
|
| 439 |
+
valid_paths = []
|
| 440 |
+
for path in file_paths:
|
| 441 |
+
try:
|
| 442 |
+
img = cv2.imread(path)
|
| 443 |
+
if img is not None:
|
| 444 |
+
valid_paths.append(path)
|
| 445 |
+
except:
|
| 446 |
+
pass
|
| 447 |
+
|
| 448 |
+
if len(valid_paths) < 2:
|
| 449 |
+
return None, f"❌ Only {len(valid_paths)} valid images found", None
|
| 450 |
+
|
| 451 |
+
file_paths = valid_paths
|
| 452 |
|
| 453 |
# Update configuration
|
| 454 |
basic_stitcher.config['feature_extractor'] = feature_type
|
|
|
|
| 458 |
basic_stitcher.config['ransac_threshold'] = ransac_thresh
|
| 459 |
|
| 460 |
# Load images
|
| 461 |
+
try:
|
| 462 |
+
images = [Image.open(f) for f in file_paths]
|
| 463 |
+
return basic_stitcher.stitch_images(images)
|
| 464 |
+
except Exception as e:
|
| 465 |
+
return None, f"❌ Error: {str(e)}", None
|
| 466 |
|
| 467 |
def process_zip_with_metadata(zip_file, feature_type, matcher_type, use_clahe, detect_labels, ransac_thresh):
|
| 468 |
"""Process ZIP file containing images and metadata"""
|