Example code does not work

#1
by Softology - opened

Using your example code

from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
pipe = pipeline("image-to-video", 'damo/Image-to-Video')
output_video_path = pipe('MonaLisaColor.jpg', output_video='./output.mp4')[OutputKeys.OUTPUT_VIDEO]
print(output_video_path)

fails with this error

Traceback (most recent call last):
File "D:\MS-Image2Video\image2video.py", line 3, in
pipe = pipeline("image-to-video", 'damo/Image-to-Video')
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\pipelines\builder.py", line 100, in pipeline
model = normalize_model_input(model, model_revision)
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\pipelines\builder.py", line 29, in normalize_model_input
model = snapshot_download(
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\hub\snapshot_download.py", line 94, in snapshot_download
revision = _api.get_valid_revision(
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\hub\api.py", line 446, in get_valid_revision
raise NoValidRevisionError(
modelscope.hub.errors.NoValidRevisionError: The model: damo/Image-to-Video has no valid revision!

Any ideas on what I need to change to fix it?

Also, you need to add tensorflow to the requirements packages list.

Hi, please try the following code:

from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys

pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')

# IMG_PATH: your image path (url or local file)
output_video_path = pipe(IMG_PATH, output_video='./output.mp4')[OutputKeys.OUTPUT_VIDEO]
print(output_video_path)

Moreover, we will update the latest introduction as soon as possible, and you can also refer to the introduction on our ModelScope. (https://modelscope.cn/models/damo/Image-to-Video/summary)

Got past the first error, all the model downloads finish, but now...

2023-08-26 15:04:57,396 - modelscope - INFO - PyTorch version 2.0.0+cu118 Found.
2023-08-26 15:04:57,399 - modelscope - INFO - TensorFlow version 2.13.0 Found.
2023-08-26 15:04:57,399 - modelscope - INFO - Loading ast index from C:\Users\Jason.cache\modelscope\ast_indexer
2023-08-26 15:04:57,459 - modelscope - INFO - Loading done! Current index file version is 1.4.2, with md5 f35527cadca2e72caec4f646bd8d2127 and a total number of 842 components indexed
2023-08-26 15:05:02,721 - modelscope - INFO - Use user-specified model revision: v1.1.0
2023-08-26 15:05:06,181 - modelscope - WARNING - ('PIPELINES', 'image-to-video', 'image-to-video-task-pipeline') not found in ast index file
Traceback (most recent call last):
File "D:\MS-Image2Video\image2video.py", line 3, in
pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0')
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\pipelines\builder.py", line 140, in pipeline
return build_pipeline(cfg, task_name=task)
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\pipelines\builder.py", line 56, in build_pipeline
return build_from_cfg(
File "D:\MS-Image2Video\voc_msimage2video\lib\site-packages\modelscope\utils\registry.py", line 198, in build_from_cfg
raise KeyError(
KeyError: 'image-to-video-task-pipeline is not in the pipelines registry group image-to-video. Please make sure the correct version of ModelScope library is used.'

Modelscope is v 1.4.2. Is there a way to stop it needing online access once all the initial model files are downloaded? It also seems to download the models from modelscope rather than this hugging face repostiory. Hugging face would have better performance for users.

I also deleted the C:\Users\Jason.cache\modelscope\ directory and let it download all the models again and recreate the ast_indexer.
Same error.

KeyError: 'image-to-video-task-pipeline is not in the pipelines registry group image-to-video. Please make sure the correct version of ModelScope library is used.'

Any ideas?

No description provided.
Softology changed discussion status to closed

Sign up or log in to comment