mlbench123 commited on
Commit
de54ec0
·
verified ·
1 Parent(s): 9ba35be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -427,6 +427,15 @@ def create_demo():
427
  if not files or len(files) < 2:
428
  return None, "❌ Please upload at least 2 images for stitching", None
429
 
 
 
 
 
 
 
 
 
 
430
  # Update configuration
431
  basic_stitcher.config['feature_extractor'] = feature_type
432
  basic_stitcher.config['matcher'] = matcher_type
@@ -435,23 +444,28 @@ def create_demo():
435
  basic_stitcher.config['ransac_threshold'] = ransac_thresh
436
 
437
  # Load images
438
- images = [Image.open(f) for f in files]
439
-
440
 
441
  # Process
442
  return basic_stitcher.stitch_images(images)
443
-
444
  def process_zip_with_metadata(zip_file, feature_type, matcher_type, use_clahe, detect_labels, ransac_thresh):
445
  """Process ZIP file containing images and metadata"""
446
  if not zip_file:
447
  return None, "❌ Please upload a ZIP file", None
448
 
 
 
 
 
 
 
449
  try:
450
  with tempfile.TemporaryDirectory() as tmpdir:
451
  tmpdir_path = Path(tmpdir)
452
 
453
  # Extract ZIP
454
- with zipfile.ZipFile(zip_file, 'r') as zip_ref:
455
  zip_ref.extractall(tmpdir_path)
456
 
457
  # Find images and metadata
 
427
  if not files or len(files) < 2:
428
  return None, "❌ Please upload at least 2 images for stitching", None
429
 
430
+ # FIX: Extract file paths from tuples
431
+ file_paths = []
432
+ for f in files:
433
+ if isinstance(f, tuple):
434
+ # Gradio returns (file_path,)
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
441
  basic_stitcher.config['matcher'] = matcher_type
 
444
  basic_stitcher.config['ransac_threshold'] = ransac_thresh
445
 
446
  # Load images
447
+ images = [Image.open(f) for f in file_paths]
 
448
 
449
  # Process
450
  return basic_stitcher.stitch_images(images)
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"""
454
  if not zip_file:
455
  return None, "❌ Please upload a ZIP file", None
456
 
457
+ # FIX: Extract file path from tuple
458
+ if isinstance(zip_file, tuple):
459
+ zip_path = zip_file[0]
460
+ else:
461
+ zip_path = zip_file
462
+
463
  try:
464
  with tempfile.TemporaryDirectory() as tmpdir:
465
  tmpdir_path = Path(tmpdir)
466
 
467
  # Extract ZIP
468
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
469
  zip_ref.extractall(tmpdir_path)
470
 
471
  # Find images and metadata