§
    9†Æje   ã                   ó4   — d Z ddlZdZdZdZdZd„ Zd„ Zd	„ ZdS )
zÜLTX-2.5 VFX recipes, using the shared LTX pipeline and RGBA exporter.

Recipes: https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Alpha-Gen
and https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Layout-To-Render.
é    Nu  ### Alpha Gen
Generate a soft grayscale matte from a source video: white is opaque, black is transparent.
Upload the RGB clip as **Source Video**. Its original dimensions are preserved; dimensions are
padded internally to multiples of 32, then cropped back. Keep clips at **145 frames or fewer**
(121 is a good starting point), up to 1920Ã—1088, with a frame count of 8n+1. The selected clip is
trimmed to a supported frame count. Resize larger footage before loading it.

**Whole Frame** needs no mask. **Masked Area** optionally restricts the result to your uploaded
or Magic Mask selection; **Non Masked Area** uses the inverse. The selection multiplies the final
matte, preserving soft edges. It does not change which foreground the model detects.

The gallery video is the grayscale matte. The original RGB clip with that alpha is saved beside
it as RGBA PNG frames in a ZIP or ProRes 4444 MOV, chosen in **Configuration â†’ Outputs â†’ RGBA
Video Output**. Alpha Gen uses one phase, eight steps and no text conditioning.
a	  Alpha Gen does not use a text prompt. Keep the default **Generate Alpha Matte**
operation label; it is ignored during inference. Use the optional selection mask to restrict the
finished matte. Text cannot select a subject or create a foreground missed by the model.uß  ### Layout to Render
Turn a clay viewport animation or a simple blockout/playblast into a finished shot.
Upload the animation as **Layout Video** and a finished version of its first frame as the
**Appearance Reference**. The clip supplies camera motion, composition and object placement;
the appearance image supplies lighting, palette, materials and detail. Do not use the clay
frame itself as the appearance image. An optional End Image can help maintain the look.

Start with two phases, eight first-pass steps, LoRA strength 1 in both phases and 24 fps.
1920Ã—1088 output uses a 960Ã—544 first pass and three full-resolution refinement steps.
Dimensions must be multiples of 64; clip lengths use 8n+1 frames.
**Two Phases with Tiling** evaluates overlapping spatial crops during each second-pass step
and blends their predictions before advancing the whole video. It reduces the spatial extent
of each transformer call and can change fine details. VAE tiling remains a separate setting.
u­  Describe the finished shot in one or two sentences, matching the appearance
reference: materials, lighting, atmosphere and subject details. Avoid describing it as clay,
3D or Unreal footage. Example: â€œA weathered stone well surrounded by summer grass and small
white flowers. Warm midday sunlight, realistic stone and wood, matching the reference image.â€�
The layout clip already supplies camera movement and object placement.c                 óR  — |                       dd¦  «        }|                       dd¦  «        }|s|si S i dd“dd“dg “dg “d	d“d
d“d|rdnd“dd“dd“dd“d|rdnddfgddddœ“dd “d|rg d¢ndg|ddœ“d d“d!d“d"d#di“}|rn|                     i d$t          “d%t          “d&d'“d(t          “d)d*g d+¢d,d-œg“d.d“d/d“d0d“d1d“d2d “d3d “d4d“d5d“d"ddd6œ“d7g dd8œ“d9d:“d;d“dd<d=d>d?dd@œ¥¦  «         n5|                     t          t
          dAt
          dBgdCdCdDddEœdddddFœ	¦  «         |S )GNÚltx2_alpha_genFÚltx2_layout_to_renderÚacceleratedÚnativeÚsliding_windowÚvideo_guide_outpaintingÚcustom_settingsÚv2i_switch_supportedÚmultiple_images_as_text_promptsÚimage_prompt_types_allowedÚTÚTEÚcustom_frames_injectionÚcontrol_video_trimTÚextra_control_framesr   Úguide_custom_choiceszSource VideozLayout VideoÚVGz
OPDEMVG&KFzVideo Input)ÚchoicesÚletters_filterÚdefaultÚlabelÚguide_custom_choices_imageÚmask_preprocessing)Ú ÚAÚNAr   zAlpha Selection)Ú	selectionÚvisibler   Úself_refinerÚNAGÚcapability_overridesÚtext_to_videoÚinfosÚprompt_infosÚdeepy_infosuæ   Alpha Gen: source RGB video â†’ grayscale matte plus RGBA ZIP/ProRes companion. Native source dimensions, â‰¤1920Ã—1088, â‰¤145 frames, 8n+1. One phase, 8 steps. Optional mask restricts the final alpha; source RGB stays unchanged.Údeepy_prompt_infosÚspecialitieszalpha output)ÚRGBAzalpha mattezvideo mattingztransparent videozŸExtract a grayscale matte from source video and export original RGB with alpha as PNG ZIP or ProRes 4444. An optional selection mask restricts the final matte.)ÚnameÚaliasesÚdescriptionÚreturns_audioÚmultimedia_generationÚauto_null_audioÚany_audio_promptÚaudio_prompt_choicesÚaudio_prompt_type_sourcesÚoutput_audio_is_input_audioÚend_frames_always_enabled)r#   Ú
inpaintingÚprompt_enhancer_def)r   r   Úguidance_max_phasesé   Úlock_guidance_phasesé    é	   é‘   z$Preparing Alpha Source and Selection)Úphase_2_spatial_tilingÚvae_block_sizeÚframes_minimumÚframes_selection_maximumÚcustom_preprocessorÚcustom_preprocessor_raw_inputszõLayout to Render: provide a layout/playblast video plus one finished appearance image based on its first frame. Optional End Image. Two phases (8+3 steps), LoRA 1; optional phase-2 spatial tiling. 24 fps, 8n+1 frames, dimensions divisible by 64.)úAppearance ReferenceÚIrD   rC   )r   r   r   r   Ú
show_label)	r$   r%   r&   r'   Úimage_ref_choicesÚone_image_ref_neededÚone_image_ref_onlyÚno_background_removalr=   )ÚgetÚupdateÚALPHA_INFOSÚALPHA_PROMPT_INFOSÚLAYOUT_INFOSÚLAYOUT_PROMPT_INFOS)Ú	model_defÚalphaÚlayoutÚresults       ú7C:\Users\johnn\OneDrive\Documents\AI\models\ltx2\vfx.pyÚvfx_model_defrU   1   s  € Ø�MŠMÐ*¨EÑ2Ô2€EØ�]Š]Ð2°EÑ:Ô:€FØð �Vð Øˆ	ðØ�xðà˜%ðà!:¸Bðà@QÐSUðð 	 ðð (IÈ%ðð 	%¨UÐ&< c c¸ð	ð ?XÐY^ð	ð
 	˜dðð
 %;¸Aðð 	ÀÐ.Y¨n¨nÈ>Ð[_Ð-`Ð,að  vBð  OSð  ^kð  !lð  !lðð 	% dðð 	¸uÐ,N¨O¨O¨O¨OÈ2È$Ð[`Ðk|Ð}Ð}ðð 	˜ðð  % eðð 	 °%Ð 8ð€Fð ð Ø�Šð 
Ø•[ð
Ø"0Õ2Dð
àð  Dð
ð !Õ"4ð
ð  nÐA~ÐA~ÐA~ð  Pqð  rð  rð  sð	
ð
 ˜Uð
ð
 %<¸Uð
ð
 EVÐW\ð
ð  ð
ð (>¸tð
ð (¨ð
ð 0MÈeð
ð (¨ð
ð #°eÈ5Ð$QÐ$Qð
ð "°ÀÐ#CÐ#Cð
ð " 1ð
ð '=¸dð
ð _dØ °AÐSVØ#IÐmqð
ð 
ð 
ñ 	ô 	ð 	ð 	ð  	�ŠÝ!Õ3Fð SÝ"5Ø.KÐ-LÐ`cÐpsð  Uð  eið  "jð  "jØ$(ÀÐ_cØ&*ð
ð 
ñ 	ô 	ð 	ð €Mó    c                 ó”  — |                       dddd¦  «                             ¦   «                              d¦  «                             d¦  «        }d}|�ï|j        dd…         | j        dd…         k    rt          d¦  «        ‚|j        d         d| j        d         fvrt          d	¦  «        ‚|d
dd…f                              ¦   «                              d¬¦  «                             d¦  «                             d¦  «        }|j        d         dk    r#|                     d|j        d         dd¦  «        }d|v rd|z
  }|d|dfS )zNRaw THWC bytes from the shared reader; do not erase RGB outside the selection.é   r   r8   é   ç     à_@ç      ð?NzGAlpha selection mask must have the same dimensions as the source video.zGAlpha selection mask must be one frame or match the source clip length..éÿÿÿÿ©Údimç     ào@ÚN)	ÚpermuteÚfloatÚdiv_Úsub_ÚshapeÚ
ValueErrorÚmeanÚ	unsqueezeÚexpand)ÚvideoÚmaskÚvideo_prompt_typeÚsourcer   s        rT   Úpreprocess_alpha_sourcern   ^   sE  € à�]Š]˜1˜a  AÑ&Ô&×,Ò,Ñ.Ô.×3Ò3°EÑ:Ô:×?Ò?ÀÑDÔD€FØ€IØÐØŒ:�a˜�cŒ?˜eœk¨!¨A¨#Ô.Ò.Ð.ÝÐfÑgÔgÐgØŒ:�aŒ=  E¤K°¤NÐ 3Ð3Ð3ÝÐfÑgÔgÐgØ˜˜b˜q˜b˜”M×'Ò'Ñ)Ô)×.Ò.°2Ð.Ñ6Ô6×@Ò@ÀÑCÔC×HÒHÈÑOÔOˆ	ØŒ?˜1Ô Ò"Ð"Ø!×(Ò(¨¨V¬\¸!¬_¸bÀ"ÑEÔEˆIØÐ#Ð#Ð#Ø˜i™ˆIØ�4˜ DÐ(Ð(rV   c                 ó´  — ddl m} |                      ¦   «                              dd¬¦  «        }| j        t
          j        k    r|                     d¦  «        n'|                     d¦  «         	                    d¦  «        }| 
                    dd¦  «         |�?| 	                    |d d …d |j        d	         …f                              |¦  «        ¦  «         | 	                    d¦  «                             ¦   «                              d
t
          j        ¬¦  «        }|d d …d |j        d	         …f                              d
t
          j        ¬¦  «                             d	¦  «         	                    d¦  «                             ¦   «          
                    dd¦  «                             t
          j        ¦  «        }t          j        |g d¢         |fd¬¦  «                             d	ddd¦  «                             ¦   «                              ¦   «         }	 ||	|||¬¦  «        }
|
€d S |                     dddd¦  «                             ¦   «         |
dœS )Nr   )Úrgba_video_side_filesT)r^   Úkeepdimr_   r[   g      à?g        r8   Úcpu)ÚdeviceÚdtyperZ   éÿ   )rY   r8   r   r]   rY   rX   )Úinterrupt_checkr\   )ÚxÚ
side_files)Úshared.utils.rgba_videorp   rb   rg   rt   ÚtorchÚuint8rc   Úadd_Úmul_Úclamp_re   ÚtoÚround_Úfloat32ÚaddÚcatra   Ú
contiguousÚnumpyri   )Úmatterm   r   ÚfpsÚoutput_formatrv   rp   rQ   ÚrgbÚbgrarx   s              rT   Úalpha_resultr‹   o   s  € Ø=Ð=Ð=Ð=Ð=Ð=à�KŠK‰MŒM×Ò 1¨dÐÑ3Ô3€EØ!&¤µ´Ò!;Ð!;ˆE�JŠJ�uÑÔÐÀÇÂÈCÁÄ×AUÒAUÐVYÑAZÔAZ€EØ	‡L‚L��cÑÔÐØÐØ�
Š
�9˜Q˜Q˜Q  ¤¨Q¤ Ð/Ô0×3Ò3°EÑ:Ô:Ñ;Ô;Ð;Ø�JŠJ�uÑÔ×$Ò$Ñ&Ô&×)Ò)°½e¼kÐ)ÑJÔJ€EØ
����O�U”[ ”^�OÐ#Ô
$×
'Ò
'¨u½E¼MÐ
'Ñ
JÔ
J×
NÒ
NÈqÑ
QÔ
Q×
VÒ
VÐW\Ñ
]Ô
]×
dÒ
dÑ
fÔ
f×
mÒ
mÐnoÐqtÑ
uÔ
u×
xÒ
xÕy~ô  zEñ  Fô  F€CÝŒ9�c˜)˜)˜)”n eÐ,°!Ð4Ñ4Ô4×<Ò<¸QÀÀ1ÀaÑHÔH×SÒSÑUÔU×[Ò[Ñ]Ô]€DØ&Ð& t¨S°-ÐQ`ÐaÑaÔa€JØÐØˆtØ—’˜a  R¨Ñ,Ô,×7Ò7Ñ9Ô9ÈÐTÐTÐTrV   )	Ú__doc__rz   rL   rM   rN   rO   rU   rn   r‹   © rV   rT   ú<module>rŽ      sw   ððð ð €€€ð€ð\Ð ð€ðJÐ ð*ð *ð *ðZ)ð )ð )ð"Uð Uð Uð Uð UrV   