Spaces:
Paused
Paused
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import cv2
|
| 3 |
-
import numpy as np
|
| 4 |
-
from stitching import Stitcher
|
| 5 |
-
from PIL import Image
|
| 6 |
-
|
| 7 |
-
# Function to stitch uploaded images
|
| 8 |
-
def stitch_images(images):
|
| 9 |
-
stitcher = Stitcher()
|
| 10 |
-
panorama = stitcher.stitch(images) # Stitch the images
|
| 11 |
-
|
| 12 |
-
# Convert the result to a PIL image
|
| 13 |
-
pil_image = Image.fromarray(cv2.cvtColor(panorama, cv2.COLOR_BGR2RGB))
|
| 14 |
-
|
| 15 |
-
# Save the image in JPG format
|
| 16 |
-
pil_image.save("stitched_image.jpg", "JPEG")
|
| 17 |
-
|
| 18 |
-
# Return the stitched image
|
| 19 |
-
return pil_image, "stitched_image.jpg" # Return the image and the file path
|
| 20 |
-
|
| 21 |
-
# Create Gradio interface with button
|
| 22 |
-
with gr.Blocks() as interface:
|
| 23 |
-
gr.Markdown("<h1 style='color: #2196F3; text-align: center;'>Image Stitcher 🧵</h1>") # Heading with a new color
|
| 24 |
-
gr.Markdown("<h3 style='color: #2196F3; text-align: center;'>=== Upload the images you want to stitch ===</h3>") # Subheading
|
| 25 |
-
|
| 26 |
-
image_upload = gr.Files(type="filepath", label="Upload Images") # File input for images
|
| 27 |
-
stitch_button = gr.Button("Stitch", variant="primary") # Button with color
|
| 28 |
-
stitched_image = gr.Image(type="pil", label="Stitched Image") # Display stitched image
|
| 29 |
-
download_button = gr.File(label="Download Stitched Image") # Button to download the image
|
| 30 |
-
|
| 31 |
-
# Define button interaction
|
| 32 |
-
stitch_button.click(stitch_images, inputs=image_upload, outputs=[stitched_image, download_button])
|
| 33 |
-
|
| 34 |
-
# Launch the interface
|
| 35 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|