Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,3 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Complete Industrial Warehouse Image Stitching Application
|
| 3 |
-
Ready for Hugging Face Space Deployment with ZIP Upload
|
| 4 |
-
|
| 5 |
-
Author: Your Name
|
| 6 |
-
Date: November 2024
|
| 7 |
-
License: MIT
|
| 8 |
-
"""
|
| 9 |
|
| 10 |
import gradio as gr
|
| 11 |
import cv2
|
|
@@ -242,7 +234,8 @@ class WarehouseStitcher:
|
|
| 242 |
buf.seek(0)
|
| 243 |
|
| 244 |
# Return (image preview, logs, downloadable file)
|
| 245 |
-
return result_pil, "\n".join(logs), ("stitched_result.png", buf.getvalue())
|
|
|
|
| 246 |
|
| 247 |
|
| 248 |
class PoseGuidedWarehouseStitcher(WarehouseStitcher):
|
|
@@ -412,7 +405,8 @@ class PoseGuidedWarehouseStitcher(WarehouseStitcher):
|
|
| 412 |
result_pil.save(buf, format='PNG', optimize=True)
|
| 413 |
buf.seek(0)
|
| 414 |
|
| 415 |
-
return result_pil, "\n".join(logs), buf
|
|
|
|
| 416 |
|
| 417 |
|
| 418 |
def create_demo():
|
|
@@ -435,20 +429,21 @@ def create_demo():
|
|
| 435 |
file_paths.append(f[0])
|
| 436 |
else:
|
| 437 |
file_paths.append(f)
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
|
|
|
| 452 |
|
| 453 |
# Update configuration
|
| 454 |
basic_stitcher.config['feature_extractor'] = feature_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
|
|
|
| 234 |
buf.seek(0)
|
| 235 |
|
| 236 |
# Return (image preview, logs, downloadable file)
|
| 237 |
+
# return result_pil, "\n".join(logs), ("stitched_result.png", buf.getvalue())
|
| 238 |
+
return result_pil, "\n".join(logs), buf.getvalue()
|
| 239 |
|
| 240 |
|
| 241 |
class PoseGuidedWarehouseStitcher(WarehouseStitcher):
|
|
|
|
| 405 |
result_pil.save(buf, format='PNG', optimize=True)
|
| 406 |
buf.seek(0)
|
| 407 |
|
| 408 |
+
# return result_pil, "\n".join(logs), buf
|
| 409 |
+
return result_pil, "\n".join(logs), buf.getvalue()
|
| 410 |
|
| 411 |
|
| 412 |
def create_demo():
|
|
|
|
| 429 |
file_paths.append(f[0])
|
| 430 |
else:
|
| 431 |
file_paths.append(f)
|
| 432 |
+
|
| 433 |
+
# Validate images
|
| 434 |
+
valid_paths = []
|
| 435 |
+
for path in file_paths:
|
| 436 |
+
try:
|
| 437 |
+
img = cv2.imread(path)
|
| 438 |
+
if img is not None:
|
| 439 |
+
valid_paths.append(path)
|
| 440 |
+
except:
|
| 441 |
+
pass
|
| 442 |
+
|
| 443 |
+
if len(valid_paths) < 2:
|
| 444 |
+
return None, f"❌ Only {len(valid_paths)} valid images found", None
|
| 445 |
+
|
| 446 |
+
file_paths = valid_paths
|
| 447 |
|
| 448 |
# Update configuration
|
| 449 |
basic_stitcher.config['feature_extractor'] = feature_type
|