staghado commited on
Commit
36fabee
·
1 Parent(s): 9af145b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -82,17 +82,16 @@ def fourier_transform_drawing(input_image, frames, coefficients):
82
 
83
  output_animation = "output.mp4"
84
 
 
85
  anim.save(output_animation, fps=15)
86
  plt.close(fig)
87
 
88
  # Convert the mp4 file to a GIF for display in Gradio
89
- os.system(f"ffmpeg -i {output_animation} -vf 'fps=10,scale=320:-1:flags=lanczos' -c:v gif -loop 0 output.gif")
 
90
 
91
- # Read the GIF and convert to PIL Image
92
- with open("output.gif", 'rb') as f:
93
- gif_image = Image.open(io.BytesIO(f.read()))
94
-
95
- return gif_image
96
 
97
  # Gradio interface
98
  interface = gr.Interface(
@@ -102,7 +101,7 @@ interface = gr.Interface(
102
  gr.Slider(minimum=10, maximum=500, value=300, label="Number of Frames"),
103
  gr.Slider(minimum=10, maximum=500, value=300, label="Number of Coefficients")
104
  ],
105
- outputs=gr.Image(),
106
  title="Fourier Transform Drawing",
107
  description="Upload an image and generate a Fourier Transform drawing animation."
108
  )
 
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
  # Convert the mp4 file to a GIF for display in Gradio
90
+ gif_output = "output.gif"
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(
 
101
  gr.Slider(minimum=10, maximum=500, value=300, label="Number of Frames"),
102
  gr.Slider(minimum=10, maximum=500, value=300, label="Number of Coefficients")
103
  ],
104
+ outputs=gr.File(),
105
  title="Fourier Transform Drawing",
106
  description="Upload an image and generate a Fourier Transform drawing animation."
107
  )