AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
fzhou223 opened this issue · comments
資源下載完後出現這個錯誤如何解決呢
## combining video: 1 => ./storage/tasks/5204c4ec-921d-47e3-bab4-848802ab230c/combined-1.mp4
2024-03-29 01:52:34 | INFO | "./app/services/video.py:39": combine_videos - max duration of audio: 16.39 seconds
2024-03-29 01:52:34 | INFO | "./app/services/video.py:43": combine_videos - each clip will be maximum 3 seconds long
2024-03-29 01:52:34 | INFO | "./app/services/video.py:83": combine_videos - resizing video to 1080 x 1920
2024-03-29 01:52:34.477 Uncaught app exception
Traceback (most recent call last):
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 542, in _run_script
exec(code, module.__dict__)
File "/Users/zaufong/MoneyPrinterTurbo/webui/Main.py", line 264, in <module>
tm.start(task_id=task_id, params=cfg)
File "/Users/zaufong/MoneyPrinterTurbo/app/services/task.py", line 139, in start
video.combine_videos(combined_video_path=combined_video_path,
File "/Users/zaufong/MoneyPrinterTurbo/app/services/video.py", line 84, in combine_videos
clip = clip.resize((video_width, video_height))
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/fx/resize.py", line 165, in resize
newclip = clip.fl_image(fl)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 576, in fl_image
return self.fl(lambda gf, t: image_func(gf(t)), apply_to)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/Clip.py", line 141, in fl
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
File "<decorator-gen-68>", line 2, in set_make_frame
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/decorators.py", line 15, in outplace
f(newclip, *a, **k)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 740, in set_make_frame
self.size = self.get_frame(0).shape[:2][::-1]
File "<decorator-gen-11>", line 2, in get_frame
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/Clip.py", line 98, in get_frame
return self.make_frame(t)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/Clip.py", line 141, in <lambda>
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 576, in <lambda>
return self.fl(lambda gf, t: image_func(gf(t)), apply_to)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/fx/resize.py", line 163, in fl
return resizer(pic.astype("uint8"), newsize)
File "/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/fx/resize.py", line 37, in resizer
resized_pil = pilim.resize(newsize[::-1], Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
把/opt/miniconda3/envs/MoneyPrinterTurbo/lib/python3.10/site-packages/moviepy/video/fx/resize.py
第37行的 resized_pil = pilim.resize(newsize[::-1], Image.ANTIALIAS)
Image.ANTIALIAS 替换为 Image.LANCZOS 或 Image.Resampling.LANCZOS
再试试
pip list |grep Pillow
先看下当前的 Pillow 版本是多少,如果是 10.x 的版本,可以尝试下降级看看
有用户反馈降级后正常
pip uninstall Pillow
pip install Pillow==9.5.0