gokaygokay commited on
Commit
b4eede5
·
verified ·
1 Parent(s): 96093bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -3,15 +3,20 @@ from stitching import Stitcher
3
  import cv2
4
  import numpy as np
5
 
6
- def stitch_images(image_mode, image1, image2, images, detector, matcher, estimator, blender_type, crop, wave_correct):
7
  if image_mode == "Two Images":
8
  if image1 is None or image2 is None:
9
  return None, "Please upload both images."
10
  cv_images = [cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) for img in [image1, image2]]
11
  else: # Multiple Images
12
- if len(images) < 2:
13
  return None, "Please upload at least 2 images."
14
- cv_images = [cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) for img in images]
 
 
 
 
 
15
 
16
  try:
17
  stitcher = Stitcher(
@@ -64,7 +69,6 @@ with gr.Blocks() as iface:
64
 
65
  with gr.Row():
66
  output_image = gr.Image(type="numpy", label="Stitched Panorama")
67
- status = gr.Textbox(label="Status")
68
 
69
  stitch_button.click(
70
  stitch_images,
 
3
  import cv2
4
  import numpy as np
5
 
6
+ def stitch_images(image_mode, image1, image2, images, detector, matcher, estimator, blender_type, crop, wave_correct, progress=gr.Progress(track_tqdm=True)):
7
  if image_mode == "Two Images":
8
  if image1 is None or image2 is None:
9
  return None, "Please upload both images."
10
  cv_images = [cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) for img in [image1, image2]]
11
  else: # Multiple Images
12
+ if not images or len(images) < 2:
13
  return None, "Please upload at least 2 images."
14
+ cv_images = []
15
+ for img_path in images:
16
+ img = cv2.imread(img_path.name)
17
+ if img is None:
18
+ return None, f"Failed to read image: {img_path.name}"
19
+ cv_images.append(img)
20
 
21
  try:
22
  stitcher = Stitcher(
 
69
 
70
  with gr.Row():
71
  output_image = gr.Image(type="numpy", label="Stitched Panorama")
 
72
 
73
  stitch_button.click(
74
  stitch_images,