Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,15 +82,16 @@ def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_
|
|
| 82 |
draw_y.append(center[1])
|
| 83 |
drawing.set_data(draw_x[:i+1], draw_y[:i+1])
|
| 84 |
|
| 85 |
-
#
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
| 90 |
last_image = image
|
| 91 |
|
| 92 |
# Yield the current image and a placeholder for the final animation
|
| 93 |
-
yield (
|
| 94 |
|
| 95 |
# Generate and yield images for each frame
|
| 96 |
for frame in range(frames):
|
|
@@ -101,9 +102,6 @@ def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_
|
|
| 101 |
anim = animation.FuncAnimation(fig, animate, frames=frames, interval=5, fargs=(coefs, np.linspace(0, 1, num=frames)))
|
| 102 |
anim.save(temp_file.name, fps=15)
|
| 103 |
|
| 104 |
-
# Remove the temporary file
|
| 105 |
-
# os.remove(temp_file.name)
|
| 106 |
-
|
| 107 |
yield (last_image, temp_file.name)
|
| 108 |
|
| 109 |
# Gradio interface setup
|
|
|
|
| 82 |
draw_y.append(center[1])
|
| 83 |
drawing.set_data(draw_x[:i+1], draw_y[:i+1])
|
| 84 |
|
| 85 |
+
# Convert the Matplotlib figure to a PIL Image
|
| 86 |
+
canvas = fig.canvas
|
| 87 |
+
canvas.draw()
|
| 88 |
+
image = Image.frombytes('RGB',
|
| 89 |
+
canvas.get_width_height(),
|
| 90 |
+
canvas.tostring_rgb())
|
| 91 |
last_image = image
|
| 92 |
|
| 93 |
# Yield the current image and a placeholder for the final animation
|
| 94 |
+
yield (last_image, None)
|
| 95 |
|
| 96 |
# Generate and yield images for each frame
|
| 97 |
for frame in range(frames):
|
|
|
|
| 102 |
anim = animation.FuncAnimation(fig, animate, frames=frames, interval=5, fargs=(coefs, np.linspace(0, 1, num=frames)))
|
| 103 |
anim.save(temp_file.name, fps=15)
|
| 104 |
|
|
|
|
|
|
|
|
|
|
| 105 |
yield (last_image, temp_file.name)
|
| 106 |
|
| 107 |
# Gradio interface setup
|