Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
| 1 |
-
model
|
| 2 |
|
| 3 |
-
converted to use it with animatediff with diffusers on hugging face
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
model based on https://civitai.com/models/108124/realisticmechv1
|
| 2 |
|
| 3 |
+
converted to use it with animatediff with diffusers on hugging face
|
| 4 |
+
|
| 5 |
+
A code sample :
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
from diffusers import AnimateDiffPipeline, DDIMScheduler, MotionAdapter
|
| 9 |
+
from diffusers.utils import export_to_gif
|
| 10 |
+
|
| 11 |
+
# Load the motion adapter
|
| 12 |
+
adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2", torch_dtype=torch.float16)
|
| 13 |
+
# load SD 1.5 based finetuned model
|
| 14 |
+
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 15 |
+
pipe = AnimateDiffPipeline.from_pretrained(model_id, motion_adapter=adapter, torch_dtype=torch.float16)
|
| 16 |
+
scheduler = DDIMScheduler.from_pretrained(
|
| 17 |
+
model_id,
|
| 18 |
+
subfolder="scheduler",
|
| 19 |
+
clip_sample=False,
|
| 20 |
+
timestep_spacing="linspace",
|
| 21 |
+
beta_schedule="linear",
|
| 22 |
+
steps_offset=1,
|
| 23 |
+
)
|
| 24 |
+
pipe.scheduler = scheduler
|
| 25 |
+
|
| 26 |
+
# enable memory savings
|
| 27 |
+
pipe.enable_vae_slicing()
|
| 28 |
+
pipe.enable_model_cpu_offload()
|
| 29 |
+
|
| 30 |
+
output = pipe(
|
| 31 |
+
prompt=(
|
| 32 |
+
"half body portrait of man smiling with a mysterious gaze, mecha, science_fiction, city, realistic,mecha, a futuristic eiffel tower in the background "
|
| 33 |
+
),
|
| 34 |
+
negative_prompt="(worst quality, low quality:1.4), (bad_prompt_version2:0.8), EasyNegative, badhandv4, text, name, letters, watermark, two tower",
|
| 35 |
+
num_frames=16,
|
| 36 |
+
guidance_scale=7.0,
|
| 37 |
+
num_inference_steps=32,
|
| 38 |
+
generator=torch.Generator("cpu").manual_seed(42),
|
| 39 |
+
)
|
| 40 |
+
frames = output.frames[0]
|
| 41 |
+
export_to_gif(frames, "animation.gif")
|