I have a list as all_frames. I want to write this as a video with imageio but I got the error that you can find in below. How can I change all_frame from list to np.array?
You can find imageio code in below:
all_frames = []
for j, image in enumerate(image_batch):
image_index = (i * batch_size) j
if not self.use_tf:
image = (image.permute(1, 2, 0) * 127.5 128).clamp(0, 255).to(torch.uint8).squeeze(0)
array = np.array(image)
for effect in self.custom_effects:
array = effect.apply_effect(array = array,
index = image_index)
final_image = Image.fromarray(array, 'RGB')
if resolution:
final_image = final_image.resize((resolution, resolution))
all_frames.append(final_image)
imageio.mimwrite('tmp.mp4', all_frames, quality=8, fps=self.sr/self.frame_duration)
CodePudding user response:
Try this edit:
all_frames.append(np.array(final_image,np.uint8))
That must converts images to numpy arrays.