We're trying to calculate/get the progress of a video generation model, so as to show the progress to the user in real-time.
Here's our code:
import torch, random, gc
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
torch.manual_seed(random.randint(0, 2147483647))
pipe = pipeline('text-to-video-synthesis', '/content/drive/MyDrive/BEProject/models')
video_clips = []
for prompt in prompts:
with torch.no_grad(): torch.cuda.empty_cache()
gc.collect()
output_video_path = pipe({'text': prompt})[OutputKeys.OUTPUT_VIDEO]
video_clip = VideoFileClip(output_video_path)
video_clips.append(video_clip)
final = concatenate_videoclips(video_clips)
new_video_path = f'/content/videos/{datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")}.mp4'
final.write_videofile(new_video_path, codec="libx264")
Is there any way we could pass a callback function or calculate the progress of the model and intervals to show it to the user?
We tried going through the definition/implementation of pipeline function and Pipeline object's call magic method to check if there is any direct way provided by the function itself to do so, but it doesn't seem to be there.