multimodalart HF Staff commited on
Commit
52a0034
·
verified ·
1 Parent(s): 8979d0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -34
app.py CHANGED
@@ -156,39 +156,16 @@ def create_video_between_images(input_image, output_image, prompt: str, request:
156
  raise gr.Error("Both input and output images are required to create a video.")
157
 
158
  try:
159
- # Convert input image to file path
160
- if isinstance(input_image, np.ndarray):
161
- # Convert numpy array to PIL Image
162
- input_pil = Image.fromarray(input_image.astype('uint8'))
163
- with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
164
- input_pil.save(tmp.name)
165
- input_image_path = tmp.name
166
- elif isinstance(input_image, Image.Image):
167
- with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
168
- input_image.save(tmp.name)
169
- input_image_path = tmp.name
170
- elif isinstance(input_image, str):
171
- input_image_path = input_image
172
- else:
173
- raise gr.Error(f"Unsupported input image type: {type(input_image)}")
174
 
175
- # Convert output image to file path
176
- if isinstance(output_image, np.ndarray):
177
- # Convert numpy array to PIL Image
178
- output_pil = Image.fromarray(output_image.astype('uint8'))
179
- with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
180
- output_pil.save(tmp.name)
181
- output_image_path = tmp.name
182
- elif isinstance(output_image, Image.Image):
183
- with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
184
- output_image.save(tmp.name)
185
- output_image_path = tmp.name
186
- elif isinstance(output_image, str):
187
- output_image_path = output_image
188
- else:
189
- raise gr.Error(f"Unsupported output image type: {type(output_image)}")
190
 
191
- # Generate the video
 
 
 
 
192
  video_path = _generate_video_segment(
193
  input_image_path,
194
  output_image_path,
@@ -265,9 +242,6 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
265
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024)
266
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024)
267
 
268
-
269
-
270
-
271
  with gr.Column():
272
  result = gr.Image(label="Output Image", interactive=False)
273
  prompt_preview = gr.Textbox(label="Processed Prompt", interactive=False)
 
156
  raise gr.Error("Both input and output images are required to create a video.")
157
 
158
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
161
+ input_image.save(tmp.name)
162
+ input_image_path = tmp.name
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
+ output_pil = Image.fromarray(output_image.astype('uint8'))
165
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
166
+ output_pil.save(tmp.name)
167
+ output_image_path = tmp.name
168
+
169
  video_path = _generate_video_segment(
170
  input_image_path,
171
  output_image_path,
 
242
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024)
243
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024)
244
 
 
 
 
245
  with gr.Column():
246
  result = gr.Image(label="Output Image", interactive=False)
247
  prompt_preview = gr.Textbox(label="Processed Prompt", interactive=False)