Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -82,17 +82,16 @@ def fourier_transform_drawing(input_image, frames, coefficients):
|
|
82 |
|
83 |
output_animation = "output.mp4"
|
84 |
|
|
|
85 |
anim.save(output_animation, fps=15)
|
86 |
plt.close(fig)
|
87 |
|
88 |
# Convert the mp4 file to a GIF for display in Gradio
|
89 |
-
|
|
|
90 |
|
91 |
-
#
|
92 |
-
|
93 |
-
gif_image = Image.open(io.BytesIO(f.read()))
|
94 |
-
|
95 |
-
return gif_image
|
96 |
|
97 |
# Gradio interface
|
98 |
interface = gr.Interface(
|
@@ -102,7 +101,7 @@ interface = gr.Interface(
|
|
102 |
gr.Slider(minimum=10, maximum=500, value=300, label="Number of Frames"),
|
103 |
gr.Slider(minimum=10, maximum=500, value=300, label="Number of Coefficients")
|
104 |
],
|
105 |
-
outputs=gr.
|
106 |
title="Fourier Transform Drawing",
|
107 |
description="Upload an image and generate a Fourier Transform drawing animation."
|
108 |
)
|
|
|
82 |
|
83 |
output_animation = "output.mp4"
|
84 |
|
85 |
+
# Save the animation as an MP4 file
|
86 |
anim.save(output_animation, fps=15)
|
87 |
plt.close(fig)
|
88 |
|
89 |
# Convert the mp4 file to a GIF for display in Gradio
|
90 |
+
gif_output = "output.gif"
|
91 |
+
os.system(f"ffmpeg -i {output_animation} -vf 'fps=10,scale=320:-1:flags=lanczos' -c:v gif -loop 0 {gif_output}")
|
92 |
|
93 |
+
# Instead of reading the GIF into a PIL Image, return the path to the GIF file
|
94 |
+
return gif_output
|
|
|
|
|
|
|
95 |
|
96 |
# Gradio interface
|
97 |
interface = gr.Interface(
|
|
|
101 |
gr.Slider(minimum=10, maximum=500, value=300, label="Number of Frames"),
|
102 |
gr.Slider(minimum=10, maximum=500, value=300, label="Number of Coefficients")
|
103 |
],
|
104 |
+
outputs=gr.File(),
|
105 |
title="Fourier Transform Drawing",
|
106 |
description="Upload an image and generate a Fourier Transform drawing animation."
|
107 |
)
|