Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -89,23 +89,16 @@ def animate(frame, coefs, frame_times, fig, ax, background, circles, circle_line
|
|
89 |
|
90 |
return (pil_image, None)
|
91 |
|
92 |
-
def generate_animation(frames, coefs, img_size, desired_range, coefficients):
|
93 |
-
fig, ax, background, circles, circle_lines, drawing = setup_animation_env(img_size, desired_range, coefficients)
|
94 |
-
coefs_static = [(np.linalg.norm(c), fr) for c, fr in coefs]
|
95 |
-
frame_times = np.linspace(0, 1, num=frames)
|
96 |
-
thetas = np.linspace(0, tau, num=frames)
|
97 |
-
draw_x, draw_y = [], []
|
98 |
-
|
99 |
-
anim = animation.FuncAnimation(fig, animate, frames=frames, interval=5, fargs=(coefs, frame_times, fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, coefs_static, thetas))
|
100 |
-
|
101 |
-
return fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, anim, frame_times, thetas, coefs_static
|
102 |
-
|
103 |
def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_kernel_size, desired_range, num_points):
|
104 |
xs, ys = process_image(input_image, img_size, blur_kernel_size, desired_range)
|
105 |
coefs = calculate_fourier_coefficients(xs, ys, num_points, coefficients)
|
106 |
|
107 |
# Setup animation environment
|
108 |
-
fig, ax, background, circles, circle_lines, drawing
|
|
|
|
|
|
|
|
|
109 |
|
110 |
# Create a temporary file for the video
|
111 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|
|
|
89 |
|
90 |
return (pil_image, None)
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_kernel_size, desired_range, num_points):
|
93 |
xs, ys = process_image(input_image, img_size, blur_kernel_size, desired_range)
|
94 |
coefs = calculate_fourier_coefficients(xs, ys, num_points, coefficients)
|
95 |
|
96 |
# Setup animation environment
|
97 |
+
fig, ax, background, circles, circle_lines, drawing = setup_animation_env(img_size, desired_range, coefficients)
|
98 |
+
coefs_static = [(np.linalg.norm(c), fr) for c, fr in coefs]
|
99 |
+
frame_times = np.linspace(0, 1, num=frames)
|
100 |
+
thetas = np.linspace(0, tau, num=frames)
|
101 |
+
draw_x, draw_y = [], []
|
102 |
|
103 |
# Create a temporary file for the video
|
104 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|