Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,19 +96,14 @@ def fourier_transform_drawing(input_image, frames, coefficients, img_size, blur_
|
|
| 96 |
for frame in range(frames):
|
| 97 |
yield from animate(frame, coefs, np.linspace(0, 1, num=frames))
|
| 98 |
|
| 99 |
-
# Generate final animation
|
| 100 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix='.
|
| 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 |
-
# # Read the final GIF
|
| 105 |
-
# with open(temp_file.name, 'rb') as gif_file:
|
| 106 |
-
# final_gif = np.array(Image.open(io.BytesIO(gif_file.read())))
|
| 107 |
-
|
| 108 |
# Remove the temporary file
|
| 109 |
# os.remove(temp_file.name)
|
| 110 |
|
| 111 |
-
# Yield the final GIF in place of the last frame
|
| 112 |
yield (last_image, temp_file.name)
|
| 113 |
|
| 114 |
# Gradio interface setup
|
|
@@ -130,4 +125,6 @@ interface = gr.Interface(
|
|
| 130 |
)
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 133 |
interface.launch()
|
|
|
|
| 96 |
for frame in range(frames):
|
| 97 |
yield from animate(frame, coefs, np.linspace(0, 1, num=frames))
|
| 98 |
|
| 99 |
+
# Generate final animation
|
| 100 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
|
| 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
|
|
|
|
| 125 |
)
|
| 126 |
|
| 127 |
if __name__ == "__main__":
|
| 128 |
+
# define queue - required for generators
|
| 129 |
+
demo.queue()
|
| 130 |
interface.launch()
|