()
| 29 | |
| 30 | |
| 31 | def generate_image(): |
| 32 | # Load models |
| 33 | os.environ["TOKENIZERS_PARALLELISM"] = "True" |
| 34 | download_models(["HunyuanDiT"]) |
| 35 | model_manager = ModelManager(torch_dtype=torch.float16, device="cuda", |
| 36 | file_path_list=[ |
| 37 | "models/HunyuanDiT/t2i/clip_text_encoder/pytorch_model.bin", |
| 38 | "models/HunyuanDiT/t2i/mt5/pytorch_model.bin", |
| 39 | "models/HunyuanDiT/t2i/model/pytorch_model_ema.pt", |
| 40 | "models/HunyuanDiT/t2i/sdxl-vae-fp16-fix/diffusion_pytorch_model.bin", |
| 41 | ]) |
| 42 | pipe = HunyuanDiTImagePipeline.from_model_manager(model_manager) |
| 43 | |
| 44 | # Generate an image |
| 45 | torch.manual_seed(0) |
| 46 | image = pipe( |
| 47 | prompt="bonfire, on the stone", |
| 48 | negative_prompt="错误的眼睛,糟糕的人脸,毁容,糟糕的艺术,变形,多余的肢体,模糊的颜色,模糊,重复,病态,残缺,", |
| 49 | num_inference_steps=50, height=1024, width=1024, |
| 50 | ) |
| 51 | model_manager.to("cpu") |
| 52 | return image |
| 53 | |
| 54 | |
| 55 | def generate_video(image): |
no test coverage detected