Skip to content

Instantly share code, notes, and snippets.

@SqrtRyan
Created October 13, 2025 12:44
Show Gist options
  • Save SqrtRyan/a33548764db668a61a4f214d064e62d0 to your computer and use it in GitHub Desktop.
Save SqrtRyan/a33548764db668a61a4f214d064e62d0 to your computer and use it in GitHub Desktop.
command = r'''
#!/bin/bash
!
cd /root/CleanCode/Github/DiffSynth-Studio
# Copy Model To This Machine (Super Fast the Second Time)
HUG_DIR=/huggingface_models
mkdir -p $HUG_DIR
rclone copy --progress --transfers 128 /root/CleanCode/Github/DiffSynth-Studio/huggingface_models $HUG_DIR
# Icecream equivalent for bash
ic() { for v in "$@"; do echo -e "\033[1;32m[ic] $v=${!v}\033[0m"; done; }
# Video parameters
NUM_FRAMES=49
HEIGHT=480
WIDTH=832
CFG_SCALE=5
NUM_INFERENCE_STEPS=15
SEED=51
# Define LoRA checkpoints from rp call download_to_cache
#STEP=2000
#STEP=1250
#STEP=500
#CKPT_NAME="Debug2" ; STEP=2000
CKPT_NAME="<LR=1e-5>" ; STEP=6500
CKPT_NAME="Deepspeed_<T=81>" ; STEP=7750 ; NUM_FRAMES=81
LORA_DIT_PATH="models/train/Wan2.2-I2V-A14B_high_noise_lora_GWTF_Dev_$CKPT_NAME/step-$STEP.safetensors"
LORA_DIT2_PATH="models/train/Wan2.2-I2V-A14B_low_noise_lora_GWTF_Dev_$CKPT_NAME/step-$STEP.safetensors"
LORA_DIT=$( rp call download_to_cache --- "$LORA_DIT_PATH" --show_progress True)
LORA_DIT2=$(rp call download_to_cache --- "$LORA_DIT2_PATH" --show_progress True)
# Extract checkpoint numbers from both LoRA paths
CHECKPOINT_HIGH=$(echo "$LORA_DIT_PATH" | grep -o 'step-[0-9]*' | sed 's/step-//')
CHECKPOINT_LOW=$(echo "$LORA_DIT2_PATH" | grep -o 'step-[0-9]*' | sed 's/step-//')
# Choose the content
#CAT CLIMBS DOWN TREE
#PROMPT="A graceful tabby cat with distinctive striped markings carefully climbs down from a tall tree, moving with feline agility and precision. The cat grips the rough bark with its claws, methodically placing each paw as it descends through the dappled sunlight filtering through green leaves. Its alert eyes scan the ground below while its fluffy tail sways for balance in this natural outdoor woodland setting"
#NAME="cat_off_tree_input_video_480x832"
# #DOG WATCHES BUTTERFLY
#PROMPT="A puppy looks at a butterfly curiously, its head moving from left to right as the butterfly flutters in the wind"
#NAME='doggy_butterfly'
#CORGI BARKS
#PROMPT="A happy Corgi sits indoors, looking directly at the camera with bright, eager eyes. It opens and closes its mouth twice, letting out two slow-motion cheerful barks. The dog’s expression stays joyful, radiating playful energy"
#NAME="corgi_cutanddrag_81f_480p"
#DUCK IN WHITE BATHTUB
#PROMPT="A bright yellow rubber duck with an expressive face and a red beak bobs and sways from side to side in a white bathtub filled with light blue water and bubbles. As it moves, it pushes the bubbles around, causing small splashes of soapy water to spill over the tub's edge. The scene is set in a modern bathroom, highlighted by a sleek chrome faucet and a minimalist design, creating a playful and clean atmosphere. The duck's playful movement adds a whimsical touch to the setting."
#NAME='duck_splash_vid'
#DUCK IN WHITE BATHTUB UP AND DOWN
#PROMPT="A bright yellow rubber duck with an expressive face and a red beak bounces energetically in a white bathtub filled with light blue water and bubbles, repeatedly lifting up and splashing down with playful force. Each impact sends soapy water splashing over the tub's edge. The scene is set in a modern bathroom, highlighted by a sleek chrome faucet and a minimalist design, creating a playful and clean atmosphere. The duck's lively up-and-down motion transforms the serene setting into a dynamic splash zone."
#NAME='duck-in-a-bath'
#PROMPT='A smooth, slow camera movement through a static normal map visualization of an office room. The view gently glides forward, almost as if zooming in slightly, revealing surfaces colored in vibrant RGB tones representing surface normals — reds, greens, and blues. The motion feels calm and steady, highlighting the 3D structure and orientation of every surface in this stylized, color-coded environment.'
#NAME='camera_normals_vis2'
#PROMPT='A smooth, slow camera movement through a static albedo map visualization of an office room. The view gently glides forward, almost as if zooming in slightly.'
#NAME='olats_albedo_vis'
DEGRADATION_ALPHA=0 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.01 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.3 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.4 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.5 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.6 # 0 = pure custom noise, 1 = pure random, unset = random alpha
DEGRADATION_ALPHA=.65 # 0 = pure custom noise, 1 = pure random, unset = random alpha
#DEGRADATION_ALPHA=.70 # 0 = pure custom noise, 1 = pure random, unset = random alpha
#DEGRADATION_ALPHA=.80 # 0 = pure custom noise, 1 = pure random, unset = random alpha
#DEGRADATION_ALPHA=1 # 0 = pure custom noise, 1 = pure random, unset = random alpha
#Calculate warped noise if we haven't already
NOISEWARPS_ROOT="test_noise_warpings"
INPUT_VIDEO_PATH="$NOISEWARPS_ROOT/$NAME.mp4"
NOISEWARP_FOLDER="${NOISEWARPS_ROOT}/${NAME}_480x832"
INPUT_IMAGE_PATH="$NOISEWARP_FOLDER/first_frame.png"
WARPED_NOISE="$NOISEWARP_FOLDER/noises.npy"
python test_noise_warpings/noise_warper.py "$INPUT_VIDEO_PATH" "$NOISEWARP_FOLDER"
# Generate output filename with parameters
OUTPUT="${NAME}_<${HEIGHT}×${WIDTH}×${NUM_FRAMES},CFG=${CFG_SCALE},N=${NUM_INFERENCE_STEPS},S=${SEED},D=${DEGRADATION_ALPHA},HI=${CHECKPOINT_HIGH},LO=${CHECKPOINT_LOW},CP=${CKPT_NAME}>.mp4"
OUTPUT=$(rp call get_unique_copy_path --- "$OUTPUT")
INPUT_IMAGE_PATH=$(rp call download_to_cache --- "$INPUT_IMAGE_PATH")
# Run inference with custom noise
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
#export CUDA_VISIBLE_DEVICES=0
NUM_PROCESSES=$(rp exec 'len(x.split(","))' ---x $CUDA_VISIBLE_DEVICES)
if (( NUM_PROCESSES == 1 )); then
export RANK=0 WORLD_SIZE=1 LOCAL_RANK=0
export MASTER_ADDR=127.0.0.1
export MASTER_PORT=${MASTER_PORT:-29500}
fi
ic NUM_FRAMES HEIGHT WIDTH CFG_SCALE NUM_INFERENCE_STEPS SEED LORA_DIT LORA_DIT2 HUG_DIR PROMPT OUTPUT INPUT_IMAGE_PATH WARPED_NOISE DEGRADATION_ALPHA CUDA_VISIBLE_DEVICES NUM_PROCESSES
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True accelerate launch --num_processes $NUM_PROCESSES $([ "$NUM_PROCESSES" -gt 1 ] && echo --multi_gpu) ryan_wan_multigpu_infer_test.py \
--root "$HUG_DIR/Wan2.2-I2V-A14B" \
--lora_dit "$LORA_DIT" \
--lora_dit2 "$LORA_DIT2" \
--prompt "$PROMPT" \
--output "$OUTPUT" \
--input_image_path "$INPUT_IMAGE_PATH" \
--seed "$SEED" \
--height "$HEIGHT" \
--width "$WIDTH" \
--num_frames "$NUM_FRAMES" \
--cfg_scale "$CFG_SCALE" \
--num_inference_steps "$NUM_INFERENCE_STEPS" \
--warped_noise "$WARPED_NOISE" \
--degradation_alpha "$DEGRADATION_ALPHA"
rp call fansi_print --- "OUTPUT = $OUTPUT" "green green bold italic on dark dark blue"
rp call web_copy_path --- "$OUTPUT"
rp call ntfy_send --- "WAN Inference Done! See $OUTPUT"
'''
command=unindent(command)
pairs = [
("first_frame_then_tracks---[Seed 9995] Bichon + Corgi _ Corgi Stay Behind", "A bichon frise and a corgi run on the sidewalk, chasing a bone. the bichon breaks to the left."),
("first_frame_then_tracks---[Seed 9651] Reverse Windmills", "two spinning windmills. A serene peaceful landscape with spinning windmills"),
("first_frame_then_tracks---[Seed 9567] City Biker", "An aerial view of a bicyclist in a blue shirt a rides the bike viewed from above. "),
("first_frame_then_tracks---[Seed 9471] Shakycam", "a muddy puddle river next to a bunch of trees"),
("first_frame_then_tracks---[Seed 8917] Move the car faster forward", "A minivan with a bunch of colorful baloons is driving through a dusty desert highway with power pylons in the top right of the screen"),
("first_frame_then_tracks---[Seed 875] Hot Air Baloons_ Slow camera, make baloons rise", "Several hot air baloons rise through a beautiful grassy serene valley"),
("first_frame_then_tracks---[Seed 8464] Blacks Freeze Camera", "A black swan swims through a river"),
("first_frame_then_tracks---[Seed 8184] Judge_ Walk Out", "A black judge woman in black robes walks into the room from the right and sits on a table, crossing her arms"),
("first_frame_then_tracks---[Seed 7945] Bichon + Corgi _ Bichon Stay Behind_copy1", "A bichon frise and a corgi run on the sidewalk, chasing a bone. the bichon breaks to the left."),
("first_frame_then_tracks---[Seed 6303] Sora Basketball_ The ball goes into the hoop_copy6", "A sleek basketball arcs gracefully through the air, its orange surface gleaming under the gymnasium lights, as it approaches the hoop with precision. The ball makes a perfect swish, slicing through the net with a satisfying sound, the net fluttering gently in its wake. The moment is captured in slow motion, highlighting the ball's trajectory and the seamless integration of its path into the hoop, emphasizing the skill and finesse of the throw. The scene shows a vibrant outdoor playground under a clear blue sky. At the center of the image is a basketball hoop viewed from below, giving a dynamic perspective. In the background, there's a playground structure with an orange slide and climbing frame, all enclosed in a fenced area. "),
("first_frame_then_tracks---[Seed 6227] Boat_ Move Test", "A ferry boat glides gracefully in the water as the camera pans up"),
("first_frame_then_tracks---[Seed 5819] Cheerleader", "a cheerleader raises up a red pompom happily with energy in a gym"),
("first_frame_then_tracks---[Seed 5176] Judge_ Walk In From Right + Zoom_copy1", "A black judge woman in black robes walks into the room from the right and sits on a table, crossing her arms"),
("first_frame_then_tracks---[Seed 5072] Truck Before Cab_copy1", "A yellow SUV taxi cab SUV drives in front of a green truck and a hotdog stand move around in times square, NYC"),
("first_frame_then_tracks---[Seed 4764] Candle Grab StopCam", "an arm reaches out and grabs a jar yankee candle jar on a couch with two candles on it in jars"),
("first_frame_then_tracks---[Seed 4370] [Failure] Stop Sign Lady_copy", 'a woman holds a megaphone in one hand to the left a megaphone a sign saying "STOP!" and holds up a megaphone'),
("first_frame_then_tracks---[Seed 2154] Candle Grab", "an arm reaches out and grabs a jar yankee candle jar on a couch with two candles on it in jars"),
("first_frame_then_tracks---[Seed 1579] Motorcycle Chase_ The motorcycle chases the car_copy", "A sleek black motorcycle, engine roaring, weaves through dense traffic on a bustling highway, hot on the heels of a vibrant red sports car. The camera, mounted on a trailing vehicle, pans backward, capturing the intense chase. Surrounding cars, a mix of sedans and trucks in various colors, blur past, emphasizing the high speed. The rider, clad in a dark leather jacket and helmet, expertly navigates the tight gaps, while the red car ahead zips through the congestion. The scene is a thrilling blend of motion and urgency, with the highway's median and guardrails flashing by, underscoring the perilous pursuit."),
]
for NAME,PROMPT in pairs:
sleep(1)
os.environ.update(gather_vars('NAME PROMPT'))
display_code_cell(command,title=f'NAME={NAME} PROMPT={PROMPT}',language='bash')
r._run_sys_command(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment