§
     ’Þj�Z  ã                   óÔ   — d dl Z d dlmZ d dlmZ d dlZd dlmZ d dl	m
Z
 d dlmZmZ ddlmZmZ d	Zd
ZdZdZedz   Zg d¢Z ed¬¦  «        d„ ¦   «         Zdd„Z G d„ d¦  «        ZdS )é    N)Ú	lru_cache)Úurlsplit)Úfiles_locator)Úbuild_hf_url)Úhas_standard_gguf_tensor_namesÚremap_state_dict_tripleté   )Ú
GENERATIONÚEDITINGzQwen3-VL-8B-InstructÚqwen_image_21zDeepBeepMeep/Qwen_image_2zDeepBeepMeep/Ideogram4z_vision_bf16.safetensors)
úconfig_legacy.jsonútokenizer_legacy.jsonútokenizer_config_legacy.jsonúpreprocessor_config.jsonzchat_template.jinjaz
merges.txtz
vocab.jsonzadded_tokens.jsonzspecial_tokens_map.jsonzvideo_preprocessor_config.json)Úmaxsizec                  óN  ‡— dd l } ddlm} ddlm}m} ddlm} t          t          j
        t          j                             t          d¦  «        ¦  «        d¬¦  «        5 }|                      |¦  «        d         Šd d d ¦  «         n# 1 swxY w Y    |di ˆfd	„d
D ¦   «         ¤Ž}t!          j        d¦  «        5   |¦   «         5   ||¦  «        }d d d ¦  «         n# 1 swxY w Y   d d d ¦  «         n# 1 swxY w Y   d„  ||¦  «                             ¦   «         D ¦   «         S )Nr   ©Úinit_empty_weights)ÚQwen3ConfigÚQwen3ForCausalLM)Úget_gguf_hf_weights_mapr   úutf-8©ÚencodingÚtext_configc                 ó"   •— i | ]}|‰|         “ŒS © r   )Ú.0Úkeyr   s     €úDC:\Users\johnn\OneDrive\Documents\AI\models\qwen21\qwen21_handler.pyú
<dictcomp>z)encoder_gguf_name_map.<locals>.<dictcomp>    s2   ø€ ð Cð Cð C°c˜C ¨SÔ!1ð Cð Cð Có    )Ú
vocab_sizeÚhidden_sizeÚintermediate_sizeÚnum_hidden_layersÚnum_attention_headsÚnum_key_value_headsÚhead_dimÚcpuc                 óD   — i | ]\  }}||                      d dd¦  «        “ŒS )úmodel.zmodel.language_model.r	   )Úreplace)r   ÚnameÚtargets      r    r!   z)encoder_gguf_name_map.<locals>.<dictcomp>%   sE   € ð Hð Hð HÙ��fð �&—.’. Ð+BÀAÑFÔFð Hð Hð Hr"   r   )ÚjsonÚ
accelerater   Útransformersr   r   Ú(transformers.modeling_gguf_pytorch_utilsr   ÚopenÚflÚlocate_fileÚosÚpathÚjoinÚENCODERÚloadÚtorchÚdeviceÚitems)	r0   r   r   r   r   ÚreaderÚconfigÚmodelr   s	           @r    Úencoder_gguf_name_maprB      sJ  ø€ à€K€K€KØ-Ð-Ð-Ð-Ð-Ð-Ø:Ð:Ð:Ð:Ð:Ð:Ð:Ð:ØPÐPÐPÐPÐPÐPå	�bŒn�RœWŸ\š\­'Ð3GÑHÔHÑIÔIÐT[Ð	\Ñ	\Ô	\ð 7Ð`fØ—i’i Ñ'Ô'¨Ô6ˆð7ð 7ð 7ñ 7ô 7ð 7ð 7ð 7ð 7ð 7ð 7øøøð 7ð 7ð 7ð 7ð ˆ[ð Dð Dð Cð Cð Cð Cð >Bð Cñ Cô Cð Dð D€Fõ 
Œ�eÑ	Ô	ð )ð )Ð0Ð0Ñ2Ô2ð )ð )Ø Ð  Ñ(Ô(ˆð)ð )ð )ñ )ô )ð )ð )ð )ð )ð )ð )øøøð )ð )ð )ð )ð )ð )ð )ñ )ô )ð )ð )ð )ð )ð )ð )øøøð )ð )ð )ð )ðHð HØ 7Ð 7¸Ñ >Ô >× DÒ DÑ FÔ FðHñ Hô Hð HsH   Á BÂBÂBÂ;C5ÃCÃC5ÃC"	Ã"C5Ã%C"	Ã&C5Ã5C9Ã<C9c                 ó¶   ‡— t          | ¦  «        r"t          | ||t          ¦   «         ¦  «        \  } }}d„ Šˆfd„} || ¦  «         ||¦  «         ||¦  «        fS )zDAccept GGUF, shared encoder-only and conditional-generation layouts.c                 óz   — |                       d¦  «        } |                      d¦  «        d         dv rd| z   } d| z   S )Nr,   ú.r   )Úembed_tokensÚlayersÚnormzlanguage_model.)ÚremoveprefixÚ	partition)r   s    r    Ú
model_namez&encoder_state_dict.<locals>.model_name/   sF   € Ø×Ò˜xÑ(Ô(ˆØ�=Š=˜ÑÔ˜aÔ Ð$FÐFÐFØ# cÑ)ˆCØ˜#‰~Ðr"   c                 óL   •— | €d S ˆfd„|                       ¦   «         D ¦   «         S )Nc                 óŒ   •— i | ]@\  }}|d k    ¯|dk    ¯ ‰|¦  «        t          |t          ¦  «        rˆfd„|D ¦   «         n|“ŒAS )úlm_head.weightÚlm_headc                 ó2   •— g | ]}|d k    ¯ ‰|¦  «        ‘ŒS )rN   r   )r   ÚitemrK   s     €r    ú
<listcomp>z@encoder_state_dict.<locals>.remap.<locals>.<dictcomp>.<listcomp>8   s.   ø€ Ð"bÐ"bÐ"b¸ÈÐQaÒIaÐIa : :¨dÑ#3Ô#3ÐIaÐIaÐIar"   )Ú
isinstanceÚlist)r   r   ÚvaluerK   s      €r    r!   z5encoder_state_dict.<locals>.remap.<locals>.<dictcomp>8   s   ø€ ð cð cð cÙ�C˜°SÐ<LÒ5LÐ5LÐQTÐXaÒQaÐQað �
˜3‘”ÕfpÐqvÕx|Ñf}Ôf}ð  #IÐ"bÐ"bÐ"bÐ"bÀÐ"bÑ"bÔ"bÐ"bð  DIØQaÐQaÐQar"   )r>   )ÚmappingrK   s    €r    Úremapz!encoder_state_dict.<locals>.remap5   sH   ø€ Øˆ?Ø�4ðcð cð cð cØ")§-¢-¡/¤/ðcñ cô cð 	cr"   )r   r   rB   )Ú
state_dictÚquantization_mapÚtied_weights_maprW   rK   s       @r    Úencoder_state_dictr[   )   sœ   ø€ å% jÑ1Ô1ð UÝ9QØÐ(Ð*:Õ<QÑ<SÔ<Sñ:Uô :UÑ6ˆ
Ð$Ð&6ðð ð ðcð cð cð cð cð
 ˆ5�ÑÔ˜e˜eÐ$4Ñ5Ô5°u°uÐ=MÑ7NÔ7NÐNÐNr"   c                   óØ   — e Zd Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zedd„¦   «         Z	ed„ ¦   «         Z
ed	„ ¦   «         Zedd„¦   «         ZdS )Úfamily_handlerc                  ó   — dgS )NÚqwen_image_21_7Br   r   r"   r    Úquery_supported_typesz$family_handler.query_supported_types>   s   € à"Ð#Ð#r"   c                  ó   — dS )NÚqwenr   r   r"   r    Úquery_model_familyz!family_handler.query_model_familyB   s   € àˆvr"   c                  ó
   — ddiS )Nrb   )iV  ÚQwenr   r   r"   r    Úquery_family_infosz!family_handler.query_family_infosF   s   € à˜Ð'Ð'r"   c                 ó   — dS )NÚqwen21r   )Úbase_model_types    r    Úget_lora_dirzfamily_handler.get_lora_dirJ   s   € àˆxr"   c                 ó*  — i dd“dd“ddg“dd“dd	d
d
ddg d¢ddœdddddddgddœg“ddddgddœg“dg d¢dddddœd d!œ“d"t           “d#t          “d$t          “d%t          “d&d'“d(d'“d)d'“d*d'“d+d,“d-g d.¢“i d/d0“d1d2“d3d2“d4d5“d6d7g“d8d“d9d:“d;d“d<d“d=d“d>d?“d@d?“dAd0dBg“dCd,“dDg dE¢dFdGidHœ“dId dJgddKœ“dLg dM¢d5dNdBgdOœ“¥t          dP„ dQD ¦   «         g dR¢dSdTœdUdVdWdXdYœ¥}|                     dZ¦  «        d[k    r|                     d\d]gg d^d_¬`¦  «         |S )aNÚimage_outputsTÚdevice_explicitÚcuda_graphsÚtransformerÚresolution_budgetÚ	2400x1792Úcustom_settingsÚqwen21_kv_cachezKV CacheÚdropdownÚDisabled))z$Disabled (Slower but lower VRAM/RAM)ru   )z:Enabled (Fastest, best quality but requires more VRAM/RAM)ÚEnabled)z6INT8 in VRAM (Fastest, about half the VRAM of Enabled)ÚINT8)z!INT8 in RAM (Faster, lowest VRAM)ÚINT8_RAMaÏ  Disabled recomputes conditioning each denoising step without retaining per-layer K/V. Enabled caches conditioning K/V on the GPU for faster denoising. INT8 caches them in about half the memory: with SageAttention the images match Enabled closely, with other attention modes they differ very slightly. INT8 in RAM keeps them in system RAM and streams each layer to the GPU as it runs, for the lowest VRAM. The CPU text-embedding cache remains active in every mode.)Úidr.   ÚlabelÚtypeÚdefaultÚchoicesÚinfoÚrgbaÚRGBA)ru   ru   )rv   rv   z£Disabled saves RGB in your selected image format. Enabled preserves the generated alpha channel and saves RGBA PNG. Request transparency in the prompt when needed.Úspecialitieszalpha outputztransparent backgroundzªSet custom_settings.rgba to Enabled and request an RGBA image with transparent background to preserve generated alpha in PNG. Turbo adapter RGBA quality is not validated.)r.   ÚaliasesÚdescriptionÚprompt_enhancer_def)ÚTÚTIÚT1ÚTI1z2A New Image Description using existing Text Promptz;An Image Edit using existing Text Prompt and {image_inputs}z1An Editing Instruction using existing Text Promptz?A New Composition using existing Text Prompt and {image_inputs}Ú )Ú	selectionÚlabelsr|   Ú!text_prompt_enhancer_instructionsÚ"image_prompt_enhancer_instructionsÚ"text_prompt_enhancer_instructions1Ú#image_prompt_enhancer_instructions1Útext_prompt_enhancer_max_tokensi   Ú image_prompt_enhancer_max_tokensÚ text_prompt_enhancer_max_tokens1Ú!image_prompt_enhancer_max_tokens1Úvae_block_sizeé    Úsample_solvers)©zFlowMatch Eulerr|   ©zQwen Image 2.1 TurboÚqwen21_turbo)zViggle TurboÚ
viggle_v02)ÚPrunaÚprunaÚguidance_max_phasesr	   Úembedded_guidanceFÚNAGÚfit_into_canvas_image_refsr   Úprofiles_dirrh   Úinpaint_supportÚinpaint_video_prompt_typeÚVAGÚinpaint_with_image_refÚimage_ref_inpaintÚmask_strength_always_enabledÚinpaint_colorÚFF0000Úguide_inpaint_colorÚvideo_guide_outpaintingé   Úoutpainting_quantize_marginsÚguide_preprocessing)r‰   ÚPVÚDVÚSVÚCVÚVr³   zControl Image)rŠ   r‹   Úmask_preprocessingÚA)rŠ   ÚvisibleÚmodel_modes))zMasked Denoisingr   )zLanPaint (2 steps)r¬   )zLanPaint (5 steps)é   )zLanPaint (10 steps)é   )zLanPaint (15 steps)é   zInpainting Method)r}   r|   rz   Úimage_modesc                 óT   — g | ]%}t          t          t          t          |z   ¦  «        ‘Œ&S r   )r   ÚENCODER_REPOr:   )r   Úsuffixs     r    rR   z2family_handler.query_model_def.<locals>.<listcomp>†   s=   € ð  "Zð  "Zð  "ZÐ\b¥,­|½WÅgÐPVÑFVÑ"WÔ"Wð  "Zð  "Zð  "Zr"   )z_bf16.safetensorsz_int8_convrot.safetensors))ÚNoner‰   )z,First Image Is the Main Subject or LandscapeÚKI)z&Reference Images Are People or ObjectsÚIrÀ   )r}   Úletters_filterai  **Qwen Image 2.1 (7B)** generates images from text and edits images using up to **10 reference images**. Select reference images in the order you will describe them. Use a control image and a mask for a local edit. For outpainting, select Control Image under Control Image Process (or select a main reference), then enable Spatial Outpainting on Control Image. The same checkbox is available in Image Inpainting. Outpainting replaces red margins with a continuation of the scene. When combined with inpainting, denoising strength applies only to the painted interior. Masked Denoising offers strength controls; LanPaint spends additional time refining masked regions.

For the base model, start with **40 steps**, **guidance 4** and a square image around **1024 pixels**. Qwen Image 2.1 is native 2K: its recommended sizes are 2048x2048, 2400x1792, 2528x1696, 2752x1536 and their portrait versions, up to about 4.3 MP. Larger images require more memory and time; VAE decoding presets use 1024px tiles for 16GB+, 512px for 8GB+, and 256px for 6GB+, with 25% overlap. Auto chooses by GPU capacity. KV Cache defaults to Disabled to reduce VRAM; enable it for faster denoising when memory permits, or choose INT8 for the same speedup in about half the memory. The CPU text-embedding cache stays active. The VAE runs in BF16. Text-rendering quality is moderate: prefer short text and proofread spelling. Dense infographics are not a recommended use. RGBA defaults to Disabled: outputs are RGB and use your selected image format. For transparent cutouts or stickers, set RGBA to Enabled and explicitly request an RGBA image, an alpha channel and a transparent background; WanGP saves RGBA output as PNG to preserve transparency. This uses model-generated alpha, not a background-removal toggle. Prompt enhancement is optional and disabled by default.

NAG controls are temporarily hidden. Use guidance above 1 for standard CFG and negative prompts.

Viggle Turbo profiles use LoRA strength 1 and guidance 1: v0.1 runs 4 steps, v0.2 runs 5, and the recommended v0.2.1 runs 6. Each profile selects the Viggle Turbo scheduler, which applies the matching sigma nodes and disables terminal shift. The built-in Deepy image-generation and editing recipes use the v0.2.1 six-step settings. Viggle calls these adapters previews; complex edits remain weaker than the base model, and masks, RGBA, more than three references and 2K output have not been validated for them.

Pruna v0.1 has separate 5-step and 8-step profiles; 8 steps is the recommended starting point, while 5 steps is faster with lower visual quality. Both use guidance 1, LoRA strength 1, and the Pruna scheduler with the matching sigma nodes and no dynamic or terminal shift. Pruna trained these adapters around 1024x1024 for text-to-image and edits with up to three references; higher resolutions and more references have not been validated. The built-in Deepy Pruna recipes use the recommended 8-step settings.

Use **Qwen Image 2.1 7B LoRAs** in the dedicated LoRA folder. Older Qwen Image/Edit 20B adapters are incompatible even when their filenames use the same convention. Diffusers/PEFT and Kohya naming are supported.a¦  Describe the finished image, including the subject, composition, lighting and style. Put any exact visible text in quotes. Text-rendering quality is moderate. Prefer short quoted text and proofread spelling and layout; avoid dense infographics.

**Generation:** A red ceramic teapot on a wooden table, soft window light, detailed product photograph.

**Editing:** Change the cat's fur to orange. Keep its pose and the green background unchanged.

**Multiple references:** Put the person from `<image1>` in the jacket from `<image2>`. Keep the person's face and pose. Number references in their selected order.

**Masked editing:** Select the region to replace, then describe what belongs there: Replace the background with a bright blue sky.

**Transparency:** Set RGBA to Enabled, then prompt: This is an RGBA image with transparency. A cartoon dragon sticker. The image has alpha channel and the background is transparent. WanGP saves RGBA output as PNG automatically to retain alpha; JPEG cannot store transparency.

Use the negative prompt to describe unwanted content when guidance is above 1. Keep editing instructions specific about both the requested change and details to preserve.aq  Generate images from text or edit with up to 10 ordered reference images. Use the main/control image plus a mask for local edits; outpainting extends the canvas. Outpainting uses red canvas margins; combined inpainting applies denoising strength only to painted interior pixels. Base model: start at 40 steps, guidance 4 and roughly 1024 pixels. Viggle Turbo profiles use guidance 1, LoRA strength 1 and the Viggle Turbo scheduler: v0.1 uses 4 steps, v0.2 uses 5, and the recommended v0.2.1 uses 6. The built-in Deepy image-generation and editing recipes use the recommended v0.2.1 six-step settings. The scheduler selects the matching nodes and disables terminal shift. Viggle adapters are previews best suited to text-to-image and simple edits with up to 3 references. Complex editing, masks, RGBA and 2K output are not validated for them. Pruna v0.1 profiles use a separate Pruna scheduler at 5 or 8 steps, guidance 1 and LoRA strength 1; 8 steps is recommended for better quality and is available in Deepy generation and editing recipes. Pruna trained at roughly 1024 pixels with up to three references; higher resolutions and more references are outside its training coverage. LanPaint adds refinement steps for masked editing. KV Cache defaults to Disabled for lower VRAM; custom_settings.qwen21_kv_cache='Enabled' speeds up denoising when memory permits, 'INT8' gives the same speedup in about half the memory (near-identical images with SageAttention). VAE Auto tiles larger images; The VAE runs in BF16. Text-rendering quality is moderate, best with short copy; proofread spelling and layout. Do not recommend this model for dense infographics. RGBA defaults to Disabled (RGB in the selected image format). Enable RGBA and explicitly request transparency to preserve alpha in PNG output. Prompt enhancement defaults off. Only Qwen Image 2.1 7B LoRAs are compatible; old Qwen 20B adapters are not.a  For generation, describe subject, composition, lighting, style and quoted visible text. Text-rendering quality is moderate: prefer short quoted copy and proofread it; avoid dense infographics. For editing, specify what changes and what stays: 'Change the cat fur to orange; keep its pose and background.' Refer to ordered references as `<image1>`, `<image2>`, etc. For masked edits, describe the desired replacement. For transparency, set custom_settings.rgba to Enabled and explicitly request an RGBA image, alpha channel and transparent background. Negative prompts apply with guidance above 1 (CFG). NAG controls are temporarily hidden.)Útext_encoder_folderÚtext_encoder_URLsÚimage_ref_choicesÚinfosÚprompt_infosÚdeepy_infosÚdeepy_prompt_infosÚqwen21_variantÚturbor˜   r—   a  **Qwen Image 2.1 Turbo (7B)** generates images from text and edits images using ordered references. This is Qwen's full distilled checkpoint; no acceleration LoRA is needed. Start with **8 steps**, **guidance 1** and the **Qwen Image 2.1 Turbo** scheduler. Its eight released sigma values are fixed, without dynamic or terminal shifting. FlowMatch Euler remains available for experiments, but vanilla sigmas and other step counts have not been quality-validated for this checkpoint. Negative prompts have no effect at guidance 1. Do not apply the base model's Viggle or Pruna acceleration profiles.

Describe the desired result, quote exact visible text, and refer to ordered inputs as `<image1>`, `<image2>`, etc. The shared pipeline accepts up to 10 reference images, control-image masks and outpainting. Those inherited editing controls still need Turbo-specific validation. Upstream examples use roughly 2K output; 1024 pixels is a practical smaller starting point. KV Cache defaults to Disabled to reduce memory; enable it to reuse text and reference conditioning across steps, or choose INT8 to do so in about half the memory. VAE tiling and the shared BF16 VAE remain available.

RGBA defaults to Disabled. To preserve generated transparency, enable RGBA and request an RGBA image with an alpha channel and transparent background; output is saved as PNG. Proofread rendered text. Prompt enhancement remains optional and disabled by default. Qwen Image 2.1 7B adapters share the tensor layout; older Qwen 20B LoRAs are incompatible.am  Qwen's full distilled Qwen Image 2.1 Turbo 7B checkpoint, for text-to-image and reference editing. Default: 8 steps, guidance 1, sample_solver=qwen21_turbo. The named Turbo scheduler uses the released fixed sigmas, with no dynamic/terminal shifting; it requires 8 steps. No acceleration LoRA is needed. Do not use the base model's Viggle/Pruna profiles. Vanilla FlowMatch Euler remains experimental for this checkpoint. Negative prompts are inactive at CFG 1. The shared pipeline accepts up to 10 ordered references, masks and outpainting; inherited controls need Turbo-specific quality validation. Upstream examples use roughly 2K; defaults start at 1024. KV Cache (qwen21_kv_cache Enabled, or INT8 at about half the memory) and RGBA default off. Enable RGBA and explicitly request transparency to retain alpha in PNG. Prompt enhancement defaults off; proofread rendered text.)r–   r¡   rÆ   rÈ   )r
   r   r:   ÚgetÚupdate)ri   Ú	model_defÚ
definitions      r    Úquery_model_defzfamily_handler.query_model_defN   sÖ  € ð<
Ø˜Tð<
à˜tð<
ð ˜M˜?ð<
ð   ð	<
ð
 Ø'Ø"Ø#Ø"Ø%ð Tð  Tð  Tð jð!ð !ð ØØØ"Ø%Ø4Ð6LÐMð ~ðð ð ð<
ð, Ø'°VÐ=UÐ4Vð  hTð  Uð  Uðð-<
ð2 "Ð1IÐ1IÐ1Ið  \Pð  XUð  ]Pð  YZð  V[ð  V[ð  hjð  $kð  $kð3<
ð4 0µð5<
ð6 1µ'ð7<
ð8 1µ'ð9<
ð: 2µ7ð;<
ð< .¨sð=<
ð> /°ð?<
ð@ /°ðA<
ðB 0°ðC<
ðD ˜bðE<
ðF ð  ]ð  ]ð  ]ðG<
ð <
ðH " 1ðI<
ðJ   ðK<
ðL �5ðM<
ðN )¨!ðO<
ðP ˜X˜JðQ<
ðR ˜tðS<
ðT (¨ðU<
ðV % dðW<
ðX   ðY<
ðZ +¨Dð[<
ð\ ˜Xð]<
ð^ " 8ð_<
ð` &¨¨1 vða<
ðb +¨Bðc<
ðd "Ð1RÐ1RÐ1RÐ_bÐdsÐ^tÐ#uÐ#uðe<
ðf !°°S°	ÀdÐ"KÐ"Kðg<
ðh ð  (oð  (oð  (oð  |}ð  H[ð  mnð  loð  pð  pði<
ð <
õj $+ð "Zð  "Zð  gYð  "Zñ  "Zô  "Zð .eð  .eð  .eð  y}ð  "~ð  "~ð K2ð Qð Oð #d
ðw<
ð <
ð <
ˆ
ðz �=Š=Ð)Ñ*Ô*¨gÒ5Ð5Ø×ÒØ HÐJhÐiØð _ð Lð	 ñ ô ð ð Ðr"   Nc                 ó  — t                                ¦   «         }|�Gt          d„ |                     dg ¦  «        D ¦   «         ¦  «        r|                     t
          ¦  «         t          t          gg d¢gdœt          t          g|gdœgS )Nc              3   ó¼   K  — | ]W}t          |                     d d¦  «        d         ¦  «        j                             ¦   «                              d¦  «        V — ŒXdS )ú|r	   r   z.ggufN)r   Úsplitr8   ÚlowerÚendswith)r   Úurls     r    ú	<genexpr>z3family_handler.query_model_files.<locals>.<genexpr>™   sw   è è € ð )\ð )\Ø-0õ *2°#·)²)¸CÀÑ2CÔ2CÀAÔ2FÑ)GÔ)GÔ)L×)RÒ)RÑ)TÔ)T×)]Ò)]Ð^eÑ)fÔ)fð )\ð )\ð )\ð )\ð )\ð )\r"   rÄ   )zqwen_image_21_vae.safetensorszvae_config.jsonzscheduler_config.json)ÚrepoIdÚsourceFolderListÚfileList)
ÚPROCESSOR_FILESÚcopyÚanyrÌ   ÚappendÚVISION_FILEÚREPOÚPROJECTr½   r:   )ÚcomputeListri   rÎ   Úencoder_filess       r    Úquery_model_filesz family_handler.query_model_files–   s½   € å'×,Ò,Ñ.Ô.ˆØÐ ¥Sð )\ð )\Ø4=·M²MÐBUÐWYÑ4ZÔ4Zð)\ñ )\ô )\ñ &\ô &\Ð à× Ò ¥Ñ-Ô-Ð-Ýµg°Yð  N[ð  N[ð  N[ð  M\ð  ]ð  ]Ý'½g¸YÐUbÐTcÐdÐdðfð 	fr"   c                 ó¨   — |                      ddddddddd¬¦	  «	         |                     d	¦  «        d
k    r|                      ddd¬¦  «         d S d S )Nr	   é(   g      @r|   r‰   r   g      ð?)	Ú
image_modeÚnum_inference_stepsÚguidance_scaleÚsample_solverÚvideo_prompt_typeÚprompt_enhancerÚremove_background_images_refÚ
model_modeÚdenoising_strengthrÊ   rË   é   r™   )ré   rê   rë   )rÍ   rÌ   )ri   rÎ   Úui_defaultss      r    Úupdate_default_settingsz&family_handler.update_default_settingsŸ   s�   € à×Ò a¸RÐPSÐclð  ACð  UWð  vwð  DEð  Z]Ðñ  	^ô  	^ð  	^Ø�=Š=Ð)Ñ*Ô*¨gÒ5Ð5Ø×Ò°1ÀSÐXfÐÑgÔgÐgÐgÐgð 6Ð5r"   c                 óà   — |                      d¦  «        }t          |t          ¦  «        r%d|v r!d„ |                     ¦   «         D ¦   «         |d<   |                      d¦  «        dv rd|d<   d S d S )Nrr   Úoutpainting_bordersc                 ó&   — i | ]\  }}|d k    ¯||“ŒS )rõ   r   )r   r   rU   s      r    r!   z/family_handler.fix_settings.<locals>.<dictcomp>©   s*   € Ð-zÐ-zÐ-z¹Z¸SÀ%Ð]`ÐdyÒ]yÐ]y¨c°5Ð]yÐ]yÐ]yr"   rè   )Nr   Ú0r	   )rÌ   rS   Údictr>   )ri   Úsettings_versionrÎ   rò   Úcustoms        r    Úfix_settingszfamily_handler.fix_settings¥   s„   € à—’Ð!2Ñ3Ô3ˆÝ�f�dÑ#Ô#ð 	{Ð(=ÀÐ(GÐ(GØ-zÐ-zÈ6Ï<Ê<É>Ì>Ð-zÑ-zÔ-zˆKÐ)Ñ*ð �?Š?˜<Ñ(Ô(¨NÐ:Ð:Ø()ˆK˜Ñ%Ð%Ð%ð ;Ð:r"   Fc           
      ó¸  — ddl m}m}	m}
 ddlm} ddlm}m} ddl	m
} ddlm} t          j                             t          j                             t"          ¦  «        dd	¦  «        }|                     | d         d
|||o| ¬¦  «        }|r%ddlm}  |||| d         t*          j        |¦  «         d„ t.          D ¦   «         } |t          j                             |d         ¦  «        |d         |d         |d         ¬¦  «        }dd l}ddlm} t7          |d         d¬¦  «        5 }|                     |¦  «        }d d d ¦  «         n# 1 swxY w Y   t+          j        d¦  «        5   |¦   «         5   ||¦  «        }d d d ¦  «         n# 1 swxY w Y   d d d ¦  «         n# 1 swxY w Y   ||_        |g}|	                     |¦  «        \  }}tA          d„ |D ¦   «         ¦  «        sO| !                    tE          j#        t          j                             tH          tJ          ¦  «        ¦  «        ¦  «         | &                    ||d
tN          ¬¦  «         |
 (                    |j)        j*        j+        ¦  «         |                     tE          j#        tX          dz   ¦  «        d
|tE          j#        tX          dz   ¦  «        t*          j-        ¬¦  «        }| .                    ¦   «          /                    d
¦  «         ||j)        j*        |j)        j0        |dœ}| 1                    ¦   «         D ]y}| .                    ¦   «          /                    d
¦  «         d |_2        tg          | 4                    ¦   «         ¦  «        j5        |_6        | 7                    ¦   «         D ]	} d | _8        Œ
Œz|d         j6        |_6        | 9                    dt*          j-        ¦  «        t*          j-        k    r;t*          j        |_2        t*          j        |_6        | 7                    ¦   «         D ]} | `8Œd |_:         |||||tE          j#        tX          dz   ¦  «        ¦  «        }!|!i |¥d |j;        i¥fS )!Nr   )ÚoffloadÚquant_routerÚruntimer	   )ÚQwen3VLForConditionalGeneration)ÚQwen21PipelineÚload_processor)ÚQwenImage21Transformer2DModel)ÚAutoencoderKLQwenImage21Úconfigszqwen_image_21_7B.jsonF)Úwritable_tensorsÚ
modelClassÚdefaultConfigPathÚdo_quantize)Úsave_quantized_modelc           	      ó~   — i | ]:}|t          j        t          j                             t
          |¦  «        ¦  «        “Œ;S r   )r5   r6   r7   r8   r9   r:   )r   r.   s     r    r!   z-family_handler.load_model.<locals>.<dictcomp>¼   s5   € ÐiÐiÐiÐQU˜4¥¤µ´·²½WÀdÑ0KÔ0KÑ!LÔ!LÐiÐiÐir"   r   r   r   )Útokenizer_pathÚtokenizer_config_pathr   r   r   r   r*   c              3   ó@   K  — | ]}|                      d ¦  «        V — ŒdS ))zvisual.zmodel.visual.N)Ú
startswith)r   r   s     r    rØ   z,family_handler.load_model.<locals>.<genexpr>È   s/   è è € ÐXÐXÀC�3—>’>Ð">Ñ?Ô?ÐXÐXÐXÐXÐXÐXr"   )r  Úpreprocess_sdz/qwen_image_21_vae.safetensorsz/vae_config.json)r  r  r  Údefault_dtype)ro   Útext_encoderÚvision_encoderÚvaer  Ú	VAE_dtypez/scheduler_config.jsonÚ	tokenizer)<Úmmgprý   rþ   rÿ   r  r   Úpipeliner  r  ro   r  r  r  r7   r8   r9   ÚdirnameÚ__file__Úfast_load_transformers_modelÚwgpr
  r<   Úbfloat16rÜ   r0   r1   r   r4   r;   r=   Ú_configÚload_metadata_state_dictrÞ   rß   r5   r6   r:   rà   Úload_model_datar[   Úlookup_on_cpurA   Úlanguage_modelrF   râ   Úfloat32ÚevalÚrequires_grad_ÚvisualÚvaluesÚ_convertWeightsFloatToÚnextÚ
parametersÚdtypeÚ_model_dtypeÚmodulesÚ_lock_dtyperÌ   Úupsampling_setr  )"Úmodel_filenameÚ
model_typeri   rÎ   Útext_encoder_filenameÚsave_quantizedÚquantizeTransformerÚkwargsrý   rþ   rÿ   r   r  r  r  r  r@   ro   r
  Úprocessor_pathsÚ	processorr0   r   r?   Úencoder_configr  rä   Úencoder_keysÚ_r  ÚpipeÚ	componentÚmoduler  s"                                     r    Ú
load_modelzfamily_handler.load_model¯   sÎ  € à7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7Ð7ØAÐAÐAÐAÐAÐAØ<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ø>Ð>Ð>Ð>Ð>Ð>Ø1Ð1Ð1Ð1Ð1Ð1å”—’�bœgŸošo­hÑ7Ô7¸ÐD[Ñ\Ô\ˆØ×:Ò:¸>È!Ô;LÐ_dð  rOð  cið  wJð  wað  Sað  OaÐ:ñ  bô  bˆØð 	eØ0Ð0Ð0Ð0Ð0Ð0Ø Ð  ¨j¸.ÈÔ:KÍUÌ^Ð]cÑdÔdÐdØiÐiÕYhÐiÑiÔiˆØ"�N¥2¤7§?¢?°?ÐCZÔ3[Ñ#\Ô#\Ð^mð  oIô  _JØ2AÐBYÔ2Zð  sBð  Caô  sbðcñ cô cˆ	àˆˆˆØ1Ð1Ð1Ð1Ð1Ð1Ý�/Ð"6Ô7À'ÐJÑJÔJð 	/ÈfØ!ŸYšY vÑ.Ô.ˆNð	/ð 	/ð 	/ñ 	/ô 	/ð 	/ð 	/ð 	/ð 	/ð 	/ð 	/øøøð 	/ð 	/ð 	/ð 	/åŒ\˜%Ñ Ô ð 	Kð 	KÐ"4Ð"4Ñ"6Ô"6ð 	Kð 	KØ:Ð:¸>ÑJÔJˆLð	Kð 	Kð 	Kñ 	Kô 	Kð 	Kð 	Kð 	Kð 	Kð 	Kð 	Køøøð 	Kð 	Kð 	Kð 	Kð 	Kð 	Kð 	Kñ 	Kô 	Kð 	Kð 	Kð 	Kð 	Kð 	Kð 	Køøøð 	Kð 	Kð 	Kð 	Kà-ˆÔØ.Ð/ˆØ&×?Ò?Ð@UÑVÔV‰ˆ�aÝÐXÐXÈ<ÐXÑXÔXÑXÔXð 	UØ× Ò ¥¤µ´·²½WÅkÑ0RÔ0RÑ!SÔ!SÑTÔTÐTØ×Ò ¨mÈeÕcuÐÑvÔvÐvØ×Ò˜lÔ0Ô?ÔLÑMÔMÐMØ×2Ò2µ2´>Å'ÐLlÑBlÑ3mÔ3mð  AFð  Skõ  Aô  Mõ  NUð  Xjñ  Njñ  kô  kõ  {@ô  {HÐ2ñ  Iô  IˆØ×ÒÑÔ×*Ò*¨5Ñ1Ô1Ð1Ø*¸LÔ<NÔ<]Ø".Ô"4Ô";ÀCðIð IˆàŸš™œð 	*ð 	*ˆIØ�NŠNÑÔ×+Ò+¨EÑ2Ô2Ð2Ø/3ˆIÔ,Ý%)¨)×*>Ò*>Ñ*@Ô*@Ñ%AÔ%AÔ%GˆIÔ"Ø#×+Ò+Ñ-Ô-ð *ð *�Ø%)�Ô"Ð"ð*à$(¨Ô$8Ô$EˆÔ!Ø�:Š:�k¥5¤=Ñ1Ô1µU´]ÒBÐBõ */¬ˆCÔ&Ý$œ~ˆCÔØŸ+š+™-œ-ð 'ð '�ØÐ&Ð&Ø!ˆÔØ!�> +¨|¸SÀ)ÍRÌ^Õ\cÐf~Ñ\~ÑMÔMñ  Aô  AˆØÐC˜DÐC +¨yÔ/BÐCÐCÐCÐCsH   Ä(E
Å
EÅEÅ)F#Å4FÆ F#ÆF	ÆF#ÆF	ÆF#Æ#F'Æ*F')N)NFF)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr`   rc   rf   rj   rÐ   rå   ró   rû   r>  r   r"   r    r]   r]   =   s   € € € € € Øð$ð $ñ „\ð$ð ðð ñ „\ðð ð(ð (ñ „\ð(ð ðð ñ „\ðð ðEð Eñ „\ðEðN ðfð fð fñ „\ðfð ðhð hñ „\ðhð
 ð*ð *ñ „\ð*ð ð0Dð 0Dð 0Dñ „\ð0Dð 0Dð 0Dr"   r]   )NN)r7   Ú	functoolsr   Úurllib.parser   r<   Úshared.utilsr   r5   Úshared.utils.hfr   Úshared.utils.gguf_mappingr   r   Úenhancerr
   r   r:   râ   rá   r½   rà   rÜ   rB   r[   r]   r   r"   r    ú<module>rI     sN  ðà 	€	€	€	Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à €€€à ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø (Ð (Ð (Ð (Ð (Ð (Ø ^Ð ^Ð ^Ð ^Ð ^Ð ^Ð ^Ð ^Ø )Ð )Ð )Ð )Ð )Ð )Ð )Ð )ð !€Ø
€Ø"€Ø'€ØÐ2Ñ2€ð Cð  Cð  C€ð €�1ÐÑÔðHð Hñ ÔðHð$Oð Oð Oð Oð(cDð cDð cDð cDð cDñ cDô cDð cDð cDð cDr"   