-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c713162
commit 17a35c3
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import argparse | ||
import torch | ||
from diffusers import StableDiffusionPipeline | ||
|
||
import torch_migraphx | ||
|
||
torch._dynamo.reset() | ||
|
||
parser = argparse.ArgumentParser(description='Conversion parameters') | ||
|
||
parser.add_argument('--fp16', | ||
action='store_true', | ||
help='Load fp16 version of the pipeline') | ||
|
||
|
||
def run(args): | ||
from diffusers import FlowMatchEulerDiscreteScheduler, UniPCMultistepScheduler, WanPipeline | ||
from diffusers.utils import export_to_video | ||
# pip install git+https://github.com/huggingface/diffusers.git | ||
# pip install ftfy | ||
|
||
#scheduler_a = FlowMatchEulerDiscreteScheduler(shift=5.0) | ||
#scheduler_b = UniPCMultistepScheduler(prediction_type="flow_prediction", use_flow_sigmas=True, flow_shift=4.0) | ||
|
||
pipe = WanPipeline.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers") | ||
|
||
pipe = pipe.to("cuda") | ||
|
||
pipe.text_encoder = torch.compile(pipe.text_encoder, backend='migraphx') | ||
pipe.transformer = torch.compile(pipe.transformer, backend='migraphx') | ||
pipe.vae.decoder = torch.compile(pipe.vae.decoder, backend='migraphx') | ||
|
||
prompt = "A cat walks on the grass, realistic" | ||
negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" | ||
|
||
output = pipe( | ||
prompt=prompt, | ||
negative_prompt=negative_prompt, | ||
height=480, | ||
width=832, | ||
num_frames=81, | ||
guidance_scale=5.0, | ||
).frames[0] | ||
export_to_video(output, "output.mp4", fps=15) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = parser.parse_args() | ||
|
||
run(args) |