Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,24 +94,24 @@ def generate_animation(frames, coefs, img_size, desired_range, coefficients):
|
|
| 94 |
print(coefs)
|
| 95 |
coefs_static = [(np.linalg.norm(c), fr) for c, fr in coefs]
|
| 96 |
frame_times = np.linspace(0, 1, num=frames)
|
| 97 |
-
|
| 98 |
draw_x, draw_y = [], []
|
| 99 |
|
| 100 |
-
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,
|
| 101 |
|
| 102 |
-
return anim, frame_times
|
| 103 |
|
| 104 |
def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_kernel_size, desired_range, num_points):
|
| 105 |
xs, ys = process_image(input_image, img_size, blur_kernel_size, desired_range)
|
| 106 |
coefs = calculate_fourier_coefficients(xs, ys, num_points, coefficients)
|
| 107 |
-
anim, frame_times = generate_animation(frames, coefs, img_size, desired_range, coefficients)
|
| 108 |
|
| 109 |
# Saving the animation
|
| 110 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|
| 111 |
anim.save(temp_file.name, fps=15)
|
| 112 |
|
| 113 |
for frame in range(frames):
|
| 114 |
-
yield (animate(frame, coefs, frame_times, fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, coefs_static,
|
| 115 |
|
| 116 |
def setup_gradio_interface():
|
| 117 |
interface = gr.Interface(
|
|
|
|
| 94 |
print(coefs)
|
| 95 |
coefs_static = [(np.linalg.norm(c), fr) for c, fr in coefs]
|
| 96 |
frame_times = np.linspace(0, 1, num=frames)
|
| 97 |
+
thetas = np.linspace(0, tau, num=frames)
|
| 98 |
draw_x, draw_y = [], []
|
| 99 |
|
| 100 |
+
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))
|
| 101 |
|
| 102 |
+
return fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, anim, frame_times, thetas, coefs_static
|
| 103 |
|
| 104 |
def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_kernel_size, desired_range, num_points):
|
| 105 |
xs, ys = process_image(input_image, img_size, blur_kernel_size, desired_range)
|
| 106 |
coefs = calculate_fourier_coefficients(xs, ys, num_points, coefficients)
|
| 107 |
+
fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, anim, frame_times, thetas, coefs_static = generate_animation(frames, coefs, img_size, desired_range, coefficients)
|
| 108 |
|
| 109 |
# Saving the animation
|
| 110 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|
| 111 |
anim.save(temp_file.name, fps=15)
|
| 112 |
|
| 113 |
for frame in range(frames):
|
| 114 |
+
yield (animate(frame, coefs, frame_times, fig, ax, background, circles, circle_lines, drawing, draw_x, draw_y, coefs_static, thetas), temp_file.name)
|
| 115 |
|
| 116 |
def setup_gradio_interface():
|
| 117 |
interface = gr.Interface(
|