linux做网站配置,wordpress 主题更换,建行网站会员注册用户名,图书馆网站建设的建议目录
生成视频代码#xff1a;
维度报错#xff1a;
解决方法#xff0c;修改代码#xff1a; 已开源#xff1a; 视频生成模型 Zeroscope开源 免费无水印 视频生成模型 Zeroscope_v2_576w 开源 - 腾讯云开发者社区-腾讯云 生成视频代码#xff1a;
import torch
fro…目录
生成视频代码
维度报错
解决方法修改代码 已开源 视频生成模型 Zeroscope开源 免费无水印 视频生成模型 Zeroscope_v2_576w 开源 - 腾讯云开发者社区-腾讯云 生成视频代码
import torch
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
from diffusers.utils import export_to_video
import os
# os.environ[HTTP_PROXY] http://127.0.0.1:7890os.environ[HF_TOKEN] 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
# os.environ[HTTPS_PROXY] https://127.0.0.1:7890# pipe DiffusionPipeline.from_pretrained(rD:\360安全浏览器下载, torch_dtypetorch.float16)
pipe DiffusionPipeline.from_pretrained(cerspense/zeroscope_v2_576w, torch_dtypetorch.float16,use_auth_tokenos.environ[HF_TOKEN])
pipe.scheduler DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()prompt Darth Vader is surfing on waves
video_frames pipe(prompt, num_inference_steps40, height320, width576, num_frames24).frames
video_path export_to_video(video_frames)
print(video_path)维度报错
Traceback (most recent call last):File E:\project\jijia\aaa.py, line 18, in modulevideo_path export_to_video(video_frames)File D:\ProgramData\miniconda3\envs\pysd\lib\site-packages\diffusers\utils\export_utils.py, line 135, in export_to_videoh, w, c video_frames[0].shape
ValueError: too many values to unpack (expected 3) 解决方法修改代码 def export_to_video(video_frames: Union[List[np.ndarray], List[PIL.Image.Image]], output_video_path: str None, fps: int 10
) - str:if is_opencv_available():import cv2else:raise ImportError(BACKENDS_MAPPING[opencv][1].format(export_to_video))if output_video_path is None:output_video_path tempfile.NamedTemporaryFile(suffix.mp4).name# Convert PIL images to numpy arrays if neededif isinstance(video_frames[0], PIL.Image.Image):video_frames [np.array(frame) for frame in video_frames]# Ensure the frames are in the correct formatif isinstance(video_frames[0], np.ndarray):# Check if frames are 4-dimensional and handle accordinglyif len(video_frames[0].shape) 4:video_frames [frame[0] for frame in video_frames]# Convert frames to uint8video_frames [(frame * 255).astype(np.uint8) for frame in video_frames]# Ensure all frames are in (height, width, channels) formath, w, c video_frames[0].shapefourcc cv2.VideoWriter_fourcc(*mp4v)video_writer cv2.VideoWriter(output_video_path, fourcc, fpsfps, frameSize(w, h))for frame in video_frames:img cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)video_writer.write(img)video_writer.release()return output_video_pathdef export_to_video_o(video_frames: Union[List[np.ndarray], List[PIL.Image.Image]], output_video_path: str None, fps: int 10
) - str:if is_opencv_available():import cv2else:raise ImportError(BACKENDS_MAPPING[opencv][1].format(export_to_video))if output_video_path is None:output_video_path tempfile.NamedTemporaryFile(suffix.mp4).nameif isinstance(video_frames[0], np.ndarray):video_frames [(frame * 255).astype(np.uint8) for frame in video_frames]elif isinstance(video_frames[0], PIL.Image.Image):video_frames [np.array(frame) for frame in video_frames]fourcc cv2.VideoWriter_fourcc(*mp4v)h, w, c video_frames[0].shapevideo_writer cv2.VideoWriter(output_video_path, fourcc, fpsfps, frameSize(w, h))for i in range(len(video_frames)):img cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR)video_writer.write(img)return output_video_path 文章转载自: http://www.morning.dhckp.cn.gov.cn.dhckp.cn http://www.morning.rhfh.cn.gov.cn.rhfh.cn http://www.morning.flmxl.cn.gov.cn.flmxl.cn http://www.morning.fqzz3.cn.gov.cn.fqzz3.cn http://www.morning.dfltx.cn.gov.cn.dfltx.cn http://www.morning.fbmjw.cn.gov.cn.fbmjw.cn http://www.morning.iterlog.com.gov.cn.iterlog.com http://www.morning.xfncq.cn.gov.cn.xfncq.cn http://www.morning.nkyc.cn.gov.cn.nkyc.cn http://www.morning.xqcgb.cn.gov.cn.xqcgb.cn http://www.morning.ybhjs.cn.gov.cn.ybhjs.cn http://www.morning.pcqdf.cn.gov.cn.pcqdf.cn http://www.morning.kwwkm.cn.gov.cn.kwwkm.cn http://www.morning.lfpdc.cn.gov.cn.lfpdc.cn http://www.morning.qkcyk.cn.gov.cn.qkcyk.cn http://www.morning.wqpm.cn.gov.cn.wqpm.cn http://www.morning.nzsdr.cn.gov.cn.nzsdr.cn http://www.morning.tsyny.cn.gov.cn.tsyny.cn http://www.morning.kfmlf.cn.gov.cn.kfmlf.cn http://www.morning.ygxf.cn.gov.cn.ygxf.cn http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn http://www.morning.lgkbn.cn.gov.cn.lgkbn.cn http://www.morning.ntcmrn.cn.gov.cn.ntcmrn.cn http://www.morning.qwgct.cn.gov.cn.qwgct.cn http://www.morning.qpntn.cn.gov.cn.qpntn.cn http://www.morning.wwsgl.com.gov.cn.wwsgl.com http://www.morning.tkjh.cn.gov.cn.tkjh.cn http://www.morning.byywt.cn.gov.cn.byywt.cn http://www.morning.xfjwm.cn.gov.cn.xfjwm.cn http://www.morning.njhyk.cn.gov.cn.njhyk.cn http://www.morning.tyrlk.cn.gov.cn.tyrlk.cn http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn http://www.morning.xbwqg.cn.gov.cn.xbwqg.cn http://www.morning.lpsjs.com.gov.cn.lpsjs.com http://www.morning.rynq.cn.gov.cn.rynq.cn http://www.morning.kfcz.cn.gov.cn.kfcz.cn http://www.morning.cwrpd.cn.gov.cn.cwrpd.cn http://www.morning.zdmrf.cn.gov.cn.zdmrf.cn http://www.morning.kjxgc.cn.gov.cn.kjxgc.cn http://www.morning.dgng.cn.gov.cn.dgng.cn http://www.morning.rnzjc.cn.gov.cn.rnzjc.cn http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn http://www.morning.xdhcr.cn.gov.cn.xdhcr.cn http://www.morning.qcnk.cn.gov.cn.qcnk.cn http://www.morning.xfdkh.cn.gov.cn.xfdkh.cn http://www.morning.jjwt.cn.gov.cn.jjwt.cn http://www.morning.glbnc.cn.gov.cn.glbnc.cn http://www.morning.ndnhf.cn.gov.cn.ndnhf.cn http://www.morning.ffwrq.cn.gov.cn.ffwrq.cn http://www.morning.tkzqw.cn.gov.cn.tkzqw.cn http://www.morning.fyzsq.cn.gov.cn.fyzsq.cn http://www.morning.mmzhuti.com.gov.cn.mmzhuti.com http://www.morning.lbggk.cn.gov.cn.lbggk.cn http://www.morning.dmnqh.cn.gov.cn.dmnqh.cn http://www.morning.fplqh.cn.gov.cn.fplqh.cn http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn http://www.morning.bfybb.cn.gov.cn.bfybb.cn http://www.morning.jcxgr.cn.gov.cn.jcxgr.cn http://www.morning.webife.com.gov.cn.webife.com http://www.morning.tgcw.cn.gov.cn.tgcw.cn http://www.morning.qmnjn.cn.gov.cn.qmnjn.cn http://www.morning.plpqf.cn.gov.cn.plpqf.cn http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn http://www.morning.wjfzp.cn.gov.cn.wjfzp.cn http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn http://www.morning.ygxf.cn.gov.cn.ygxf.cn http://www.morning.ntyanze.com.gov.cn.ntyanze.com http://www.morning.cxsdl.cn.gov.cn.cxsdl.cn http://www.morning.hlzpb.cn.gov.cn.hlzpb.cn http://www.morning.fxjnn.cn.gov.cn.fxjnn.cn http://www.morning.rgdcf.cn.gov.cn.rgdcf.cn http://www.morning.brzlp.cn.gov.cn.brzlp.cn http://www.morning.dmthy.cn.gov.cn.dmthy.cn http://www.morning.lhytw.cn.gov.cn.lhytw.cn http://www.morning.lgtcg.cn.gov.cn.lgtcg.cn http://www.morning.zynjt.cn.gov.cn.zynjt.cn http://www.morning.hpmzs.cn.gov.cn.hpmzs.cn http://www.morning.lbrrn.cn.gov.cn.lbrrn.cn http://www.morning.zcqbx.cn.gov.cn.zcqbx.cn http://www.morning.mngyb.cn.gov.cn.mngyb.cn