Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,20 +14,24 @@ headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
14 |
timeout = 100
|
15 |
|
16 |
|
17 |
-
|
18 |
def split_image(input_image, num_splits=4):
|
19 |
-
# Create a list to store the output images
|
20 |
output_images = []
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
output_images.append(input_image.crop(box))
|
28 |
|
29 |
return output_images
|
30 |
|
|
|
|
|
31 |
# Function to export split images to GIF
|
32 |
def export_to_gif(images, output_path, fps=4):
|
33 |
# Calculate duration per frame in milliseconds based on fps
|
|
|
14 |
timeout = 100
|
15 |
|
16 |
|
|
|
17 |
def split_image(input_image, num_splits=4):
|
|
|
18 |
output_images = []
|
19 |
+
box_size = 512 # Each split image will be 512x512
|
20 |
+
coordinates = [
|
21 |
+
(0, 0, box_size, box_size), # Top-left
|
22 |
+
(box_size, 0, 1024, box_size), # Top-right
|
23 |
+
(0, box_size, box_size, 1024), # Bottom-left
|
24 |
+
(box_size, box_size, 1024, 1024) # Bottom-right
|
25 |
+
]
|
26 |
+
|
27 |
+
# Crop each region using predefined coordinates
|
28 |
+
for box in coordinates:
|
29 |
output_images.append(input_image.crop(box))
|
30 |
|
31 |
return output_images
|
32 |
|
33 |
+
|
34 |
+
|
35 |
# Function to export split images to GIF
|
36 |
def export_to_gif(images, output_path, fps=4):
|
37 |
# Calculate duration per frame in milliseconds based on fps
|