我有一个脚本,可以逐帧读取视频并将它们累积在双端队列中。
labeled_frame_dequeue = [numpy.ndarray, numpy.ndarray,numpy.ndarray, numpy.ndarray]
我正在尝试将此列表传递给芹菜任务
generate_clip_from_frames.delay(labeled_video_path, labeled_frame_dequeue, video_width, video_height, fps)
我尝试将双端队列转换为列表和元组,但在将其传递给芹菜时遇到错误Object of type ndarray is not JSON serializable
。
ndarray
列表中的labeled_frame_dequeue
对象无法直接序列化为JSON
,这是将数据传递到 Celery 任务所必需的。
import numpy as np
# Convert the ndarray objects to lists
labeled_frame_dequeue = [frame.tolist() for frame in labeled_frame_dequeue]
# Pass the converted list to the Celery task
generate_clip_from_frames.delay(labeled_video_path, labeled_frame_dequeue, video_width, video_height, fps)