DynamiCrafter
DynamiCrafter copied to clipboard
Optimize some code
During the in-depth usage, I discovered some code that could be optimized to further improve the user experience, including the following aspects:
- In
webvid.py
, when using pandas to read a CSV file, pandas attempts to infer the data types of each column by default. If the data in a column looks like an integer, pandas will parse it into an integer type. This means that if thepage_dir
in the training dataset is named with a purely numerical composition and includes leading zeros, such as00001
, when reading this directory from the CSV, it might remove the leading zeros and parse it as the integer1
. This could lead to errors:
Load video failed! path = /root/test/DynamiCrafter/data/videos/1/1940752_1024_576_512_512.mp4
[15:40:52] /github/workspace/src/video/video_reader.cc:83: ERROR opening: /root/test/DynamiCrafter/data/videos/1/1940752_1024_576_512_512.mp4, No such file or directory
which is an error I have encountered during execution. So, I specified the dtype
parameter as str
, which leads pandas to treat all columns as strings. This parameter can effectively prevent the occurrence of the aforementioned error.
2. In inference.py
, I noticed that when generating results and saving them as a video, the fps
parameter was fixed at 8
. To allow users to freely control this parameter during inference execution, I have made it variable. Additionally, I ensured that if the seed
parameter receives a negative number, it will generate a random seed value.
3. In the Gradio UI, I added width
and height
parameters to control the width and height of the video generation results. At the same time, the seed
has been modified to generate randomly. I believe this will be user-friendly and convenient, similar to how stable-diffusion-webui operates.