diff --git a/README.md b/README.md index 05049bb..0540499 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,36 @@ python3 gradio_server.py --flow-reverse # SERVER_NAME=0.0.0.0 SERVER_PORT=8081 python3 gradio_server.py --flow-reverse ``` + +### Running on Google Colab +To run the Gradio Server on Google Colab, follow the steps described in the Download Pretrained Models section first, and then use the following commands: + +```bash +# clone +!git clone https://github.com/tencent/HunyuanVideo.git +%cd HunyuanVideo + +# setup +!python -m pip install "huggingface_hub[cli]" +!huggingface-cli download tencent/HunyuanVideo --local-dir ./ckpts +!huggingface-cli download xtuner/llava-llama-3-8b-v1_1-transformers --local-dir ./ckpts/llava-llama-3-8b-v1_1-transformers +!python hyvideo/utils/preprocess_text_encoder_tokenizer_utils.py --input_dir ckpts/llava-llama-3-8b-v1_1-transformers --output_dir ckpts/text_encoder +!huggingface-cli download openai/clip-vit-large-patch14 --local-dir ./ckpts/text_encoder_2 +!pip install -r requirements.txt +!python -m pip install ninja +# Download and install pre-built flash-attention binaries +# For details, see: https://github.com/kun432/flash-attention-prebuild-wheels +!wget https://github.com/kun432/flash-attention-prebuild-wheels/releases/download/v0.0.0-test/flash_attn-2.6.3+cu121torch2.5-cp310-cp310-linux_x86_64.whl +!pip install --no-dependencies --upgrade flash_attn-2.6.3+cu121torch2.5-cp310-cp310-linux_x86_64.whl +!pip install gradio +!pip install loguru + +# start +!python3 gradio_server.py --flow-reverse --share +``` + +This will provide you with a shareable link to the Gradio interface for generating videos from text prompts in the Colab environment. + ### More Configurations We list some more useful configurations for easy usage: diff --git a/gradio_server.py b/gradio_server.py index 3aa5a53..0239da1 100644 --- a/gradio_server.py +++ b/gradio_server.py @@ -5,6 +5,7 @@ from datetime import datetime import gradio as gr import random +import sys from hyvideo.utils.file_utils import save_videos_grid from hyvideo.config import parse_args @@ -135,7 +136,16 @@ def create_demo(model_path, save_path): os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" server_name = os.getenv("SERVER_NAME", "0.0.0.0") server_port = int(os.getenv("SERVER_PORT", "8081")) + + # Check if --share is specified in command line arguments without changing hyvideo/config.py + if "--share" in sys.argv: + sys.argv.remove("--share") + share_flag = True + else: + share_flag = False + args = parse_args() print(args) + demo = create_demo(args.model_base, args.save_path) - demo.launch(server_name=server_name, server_port=server_port) \ No newline at end of file + demo.launch(server_name=server_name, server_port=server_port, share=share_flag)