我正在考虑创建一个集成了Hotshot的AI视频生成应用程序。然而,直接从GitHub克隆的inference.py可以正常工作,但在我在构建的应用程序中导入修改后的inference.py时,会出现以下错误。ValueError: unet/hotshot_xl.py 如在
model_index.json 中定义的,在 hotshotco/Hotshot-XL 中不存在,也不是 'diffusers/pipelines' 中的模块。
修改后的 inference.py
def main(pretrained_path='hotshotco/Hotshot-XL', xformers=False, spatial_unet_base=None, lora=None, output='output_scuba.gif', steps=30, prompt='Sasquatch scuba diving, anime style', negative_prompt='blurry', seed=455, width=672, height=384, target_width=512, target_height=512, og_width=1920, og_height=1080, video_length=8, video_duration=1000, low_vram_mode=False, scheduler='EulerAncestralDiscreteScheduler', control_type=None, controlnet_conditioning_scale=0.7, control_guidance_start=0.0, control_guidance_end=1.0, gif=None, precision='f16', autocast=None): args = argparse.Namespace( pretrained_path=pretrained_path, xformers=xformers, spatial_unet_base=spatial_unet_base, lora=lora, output=output, steps=steps, prompt=prompt, negative_prompt=negative_prompt, seed=seed, width=width, height=height, target_width=target_width, target_height=target_height, og_width=og_width, og_height=og_height, video_length=video_length, video_duration=video_duration, low_vram_mode=low_vram_mode, scheduler=scheduler, control_type=control_type, controlnet_conditioning_scale=controlnet_conditioning_scale, control_guidance_start=control_guidance_start, control_guidance_end=control_guidance_end, gif=gif, precision=precision, autocast=autocast )# 以下与 inference.py 相同
我的应用程序的一些Python代码
if generate_value == 4: main(pretrained_path='hotshotco/Hotshot-XL', xformers=False, spatial_unet_base=None, lora=None, output=filename_vid, steps=steps, prompt=prompt, negative_prompt=negative_prompt, seed=455, width=width, height=height, target_width=width, target_height=height, og_width=width, og_height=height, video_length=video_length, video_duration=1000, low_vram_mode=False, scheduler='EulerAncestralDiscreteScheduler', control_type=None, controlnet_conditioning_scale=0.7, control_guidance_start=0.0, control_guidance_end=1.0, gif=None, precision=precision, autocast=None )
(这些都是通过DeepL从日文翻译过来的)
我希望在我的应用程序中使用带有提示、负提示、生成视频的长度、精度、宽度和高度作为参数的主函数,然后基于这些参数创建一个gif文件,但出现了错误。
回答:
我找到了这个问题的起因。是运行在py还是python的区别。
# 成功示例:python main.py# 失败示例:py main.py.```