🎥 VidDiffusion
VidDiffusion is a Python library that provides vid2vid pipeline by using Hugging Face's diffusers.
Show some works generated by VidDiffusion:
Openjourney V4
https://user-images.githubusercontent.com/1396267/232981471-33406bff-6b2b-44d8-a294-7b8268c57552.mov
Anime style
https://user-images.githubusercontent.com/1396267/232980819-02f7e15a-af37-4d2d-a66d-f82f4163eb87.mov
Original Video: https://mixkit.co/free-stock-video/girl-dancing-with-her-headphones-while-taking-a-walk-4823/
Sharing Your Work
Although it is not required, we would appreciate if you could share your generated videos and the configurations you used on SNS, etc. Please include the GitHub URL of this library in your post: VidDiffusion
Also, please post config values you used to generate the video by instance.show_config(). I hope we can all find the best value and produce great videos!
Installation
To install the library, run the following commands:
export HUGGING_FACE_HUB_TOKEN=your_hf_auth_token
pip install --upgrade transformers diffusers
pip install viddiffusion
Usage
First, import the library:
from viddiffusion import VidDiffusionPipeline
Next, create a configuration dictionary and initialize the pipeline:
config = {
'pretrained_model_name_or_path': 'your_pretrained_model_name_or_path',
'hf_auth_token': 'your_hf_auth_token', #Optional
'input_video_path': 'your_input_video_path',
'output_video_path': 'your_output_video_path'
}
vid_pipe = VidDiffusionPipeline(config)
Optionally, you can change the path of temp save directory and other parameters:
vid_pipe.set_config({
'init_image_dir': './vid_temp/init',
'output_image_dir': './vid_temp/output',
'fps': 20,
'end_time': 5.0,
'prompt': 'Fantasy, dynamic, cinamatic, cinematic light, hyperrealism',
'negative_prompt': 'deformed, out of focus, blurry, low resolution, low quality',
})
vid_pipe.show_config()
Finally, apply the diffusion model to the video:
vid_pipe.vid2vid()
Configuration:
Required parameters:
pretrained_model_name_or_path: The name or path of the pretrained diffusion model to use. The model must be a Hugging Face model. The model can be a local path or a model name from the Hugging Face model hub. E.g.pretrained_model_name_or_path = 'stabilityai/stable-diffusion-2'input_video_path: The path to the input video file. E.g.input_video_path = 'input_video.mp4'output_video_path: The path to the output video file. E.g.output_video_path = 'output_video.mp4'
Optional parameters:
-
huggingface parameters:
hf_auth_token: Hugging Face auth token. Default: None.
-
Folder parameters:
init_image_dir: Path to images separated from the video directory. Default: None.output_image_dir: Path to regenerated images directory. Default: /tmp/viddiffusion.
-
Video parameters:
fps: FPS of output video. Default: fps of input video.duration: Duration of output video. Default: duration of input video.start_time: Start time of output video. Default: 0.end_time: End time of output video. Default: duration of input video.
-
Diffusion parameters:
custom_pipeline: Custom pipeline. Default: lpw_stable_diffusion.torch_dtype: Torch dtype. Default: torch.float.safety_checker: Safety checker. Callable. Default: None.image_size: Image size. Default: 512 * 512 = 262144.
-
Prompt parameters:
prompt: Prompt. Default: 'Cyberpunk style, intricate details, high-quality'negative_prompt: Negative prompt. Default: 'Low-quality, blurry, pixelated, low-resolution'
-
Scheduler parameters:
scheduler: Scheduler. Default: DPMSolverMultistepScheduler.beta_start: Beta start. Default: 0.00085 * 0.75.beta_end: Beta end. Default: 0.012 * 0.75.num_train_timesteps: Number of train timesteps. Default: int(1000 * 0.75).blend_alph: Blend alph. Default: 0.15.blend_decay_rate: Blend decay rate. Default: 0.997.strength: Strength. Default: 0.65.num_inference_steps: Number of inference steps. Default: 30.guidance_scale: Guidance scale. Default: 7.5.seed: Seed for generator. Default: 2023.
-
Other parameters:
preprocess_image: Preprocess image. Default: lambda image: image.
How to Improve Video Quality
This library's feature is using generated image one frame before and after the current frame to improve video quality. This feature is enabled by default. I guess this feature is good for videos that have a lot of motion.
Parameters to change to improve video quality
-
scheduler: Try various scheduler such as DPMSolverMultistepScheduler, DDIMScheduler, LMSDiscreteScheduler, EulerDiscreteScheduler, PNDMScheduler, DDPMScheduler, EulerAncestralDiscreteScheduler. -
beta_start: 0.00085 * 0.65~0.75 is good, but I don't know the best value. -
beta_end: 0.012 * 0.65~0.75 is good, but I don't know the best value. -
num_train_timesteps: int(1000 * 0.65~0.75) is good, but I don't know the best value. -
strength: 0.4 ~ 0.9 is good, but I don't know the best value. -
guidance_scale: 5.0~14.0 is good, but I don't know the best value. -
blend_alph: 0.03 ~ 0.28 is good, but I don't know the best value. -
blend_decay_rate: 0.992 ~ 1.0 is good, but I don't know the best value. -
prompt: Try various prompt such as 'Cyberpunk style, intricate details, high-quality', 'Fantasy, dynamic, cinamatic, cinematic light, hyperrealism', 'Cyberpunk, cyberpunk style, cyberpunk aesthetic, cyber punk city, cyberpunk cityscape, cyberpunk cityscape aesthetic, cyberpunk cityscape style, cyberpunk cityscape light, cyberpunk cityscape light aesthetic, cyberpunk cityscape light style, cyberpunk cityscape light -
negative_prompt: Try various negative_prompt such as 'Low-quality, blurry, pixelated, low-resolution', 'deformed, out of focus, blurry, low resolution, low quality', 'Low-quality, blurry, pixelated, low-resolution, deformed, out of focus, blurry, low resolution, low quality' -
preprocess_image: Try various preprocess_image function such as torchvision.
License
VidDiffusion is licensed under the Apache License 2.0.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.
Contact
If you have any questions, please feel free to contact me. Twitter DM is best option for me
- Twitter: https://twitter.com/masaishi2001
- LinkedIn: https://www.linkedin.com/in/masamune-ishihara-31b27b232/
- Mastodon: @masaishi@mastodon.social
- Email: masaishi_masa at yahoo.co.jp (Change at to @ and remove spaces)
Citation
@misc{masaishi2023viddiffusion,
title={VidDiffusion: Vid2Vid Diffuser Pipeline for Video Filter},
author={Masamune Ishihara},
year={2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/masaishi/VidDiffusion}}
}
Metadata
Release files for viddiffusion 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| viddiffusion-0.1.2.tar.gz | 13.3 kB | Without provenance | Details for viddiffusion-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| viddiffusion-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for viddiffusion-0.1.2-py3-none-any.whl |
Total release size: 25.2 kB
Release files / viddiffusion-0.1.2.tar.gz
| Download URL | viddiffusion-0.1.2.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3e4e034dd7a38ca0d1d8a261aac8c3988a0b0df299dde0b34c56f0cfdb661e8
|
|
BLAKE2b-256 checksum How to use checksums |
5c366e946438d570b9a79cdc407b4560dada994e69a1fd7e2bf3b930a66350ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|
Release files / viddiffusion-0.1.2-py3-none-any.whl
| Download URL | viddiffusion-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aefca857d14ecf197b192ac18a97c7bf28f01ce63a9fe1ba59b3a8e726ef2146
|
|
BLAKE2b-256 checksum How to use checksums |
5aaf34d6c15fc0bdd5fe87b9af12712a75aa6ece2ca03fde7ba82b712dd2ab7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|
Security for viddiffusion 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.