Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -15,30 +15,27 @@ timeout = 100
|
|
15 |
|
16 |
|
17 |
|
18 |
-
|
19 |
-
|
20 |
output_images = []
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
|
27 |
-
for j in range(3): # Iterate columns
|
28 |
-
left = j * box_size
|
29 |
-
upper = i * box_size
|
30 |
-
right = left + box_size
|
31 |
-
lower = upper + box_size
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
return output_images
|
38 |
|
39 |
-
|
40 |
# Function to export split images to GIF
|
41 |
-
def export_to_gif(images, output_path, fps=
|
42 |
# Calculate duration per frame in milliseconds based on fps
|
43 |
duration = int(1000 / fps)
|
44 |
|
@@ -53,7 +50,7 @@ def export_to_gif(images, output_path, fps=9):
|
|
53 |
|
54 |
|
55 |
def predict(prompt, seed=-1, randomize_seed=True, guidance_scale=3.5, num_inference_steps=28, lora_id="black-forest-labs/FLUX.1-dev", progress=gr.Progress(track_tqdm=True)):
|
56 |
-
prompt_template = f"""a
|
57 |
|
58 |
if lora_id.strip() == "" or lora_id == None:
|
59 |
lora_id = "black-forest-labs/FLUX.1-dev"
|
@@ -94,7 +91,7 @@ def predict(prompt, seed=-1, randomize_seed=True, guidance_scale=3.5, num_infere
|
|
94 |
gif_path = "output.gif"
|
95 |
|
96 |
# Export the split images to GIF
|
97 |
-
export_to_gif(split_images, gif_path, fps=
|
98 |
return gif_path, image, seed
|
99 |
except Exception as e:
|
100 |
print(f"Error when trying to open the image: {e}")
|
|
|
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 |
+
# Get image dimensions
|
23 |
+
img_width, img_height = input_image.size
|
24 |
|
25 |
+
# Calculate the width of each split
|
26 |
+
split_width = img_width // num_splits
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
# Split the image into equal sections horizontally
|
29 |
+
for i in range(num_splits):
|
30 |
+
left = i * split_width
|
31 |
+
right = (i + 1) * split_width
|
32 |
+
box = (left, 0, right, img_height)
|
33 |
+
output_images.append(input_image.crop(box))
|
34 |
|
35 |
return output_images
|
36 |
|
|
|
37 |
# Function to export split images to GIF
|
38 |
+
def export_to_gif(images, output_path, fps=4):
|
39 |
# Calculate duration per frame in milliseconds based on fps
|
40 |
duration = int(1000 / fps)
|
41 |
|
|
|
50 |
|
51 |
|
52 |
def predict(prompt, seed=-1, randomize_seed=True, guidance_scale=3.5, num_inference_steps=28, lora_id="black-forest-labs/FLUX.1-dev", progress=gr.Progress(track_tqdm=True)):
|
53 |
+
prompt_template = f"""a 2x2 total 4 grid of frames, showing consecutive stills from a looped gif of {prompt}"""
|
54 |
|
55 |
if lora_id.strip() == "" or lora_id == None:
|
56 |
lora_id = "black-forest-labs/FLUX.1-dev"
|
|
|
91 |
gif_path = "output.gif"
|
92 |
|
93 |
# Export the split images to GIF
|
94 |
+
export_to_gif(split_images, gif_path, fps=4)
|
95 |
return gif_path, image, seed
|
96 |
except Exception as e:
|
97 |
print(f"Error when trying to open the image: {e}")
|