Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -80,28 +80,23 @@ def fourier_transform_drawing(input_image, frames, coefficients):
|
|
80 |
time = np.linspace(0, drawing_time, num=frames)
|
81 |
anim = animation.FuncAnimation(fig, animate, frames=frames, interval=5, fargs=(coefs, time))
|
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 |
-
#
|
90 |
-
|
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(
|
98 |
fn=fourier_transform_drawing,
|
99 |
inputs=[
|
100 |
gr.Image(label="Input Image", sources=['upload'], type="pil"),
|
101 |
-
gr.Slider(minimum=10, maximum=500, value=
|
102 |
-
gr.Slider(minimum=10, maximum=500, value=
|
103 |
],
|
104 |
-
outputs=gr.
|
105 |
title="Fourier Transform Drawing",
|
106 |
description="Upload an image and generate a Fourier Transform drawing animation."
|
107 |
)
|
|
|
80 |
time = np.linspace(0, drawing_time, num=frames)
|
81 |
anim = animation.FuncAnimation(fig, animate, frames=frames, interval=5, fargs=(coefs, time))
|
82 |
|
|
|
|
|
83 |
# Save the animation as an MP4 file
|
84 |
+
output_animation = "output.mp4"
|
85 |
anim.save(output_animation, fps=15)
|
86 |
plt.close(fig)
|
87 |
|
88 |
+
# Return the path to the MP4 file
|
89 |
+
return output_animation
|
|
|
|
|
|
|
|
|
90 |
|
91 |
# Gradio interface
|
92 |
interface = gr.Interface(
|
93 |
fn=fourier_transform_drawing,
|
94 |
inputs=[
|
95 |
gr.Image(label="Input Image", sources=['upload'], type="pil"),
|
96 |
+
gr.Slider(minimum=10, maximum=500, value=100, label="Number of Frames"),
|
97 |
+
gr.Slider(minimum=10, maximum=500, value=100, label="Number of Coefficients")
|
98 |
],
|
99 |
+
outputs=gr.Video(),
|
100 |
title="Fourier Transform Drawing",
|
101 |
description="Upload an image and generate a Fourier Transform drawing animation."
|
102 |
)
|