a
    Ad                     @   sF   d dl Zd dlmZmZ d dlmZ d dlmZ G dd dej	Z
dS )    N)scripts	sd_models)create_refresh_button)InputAccordionc                   @   s<   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dS )ScriptRefiner
accordionsFc                 C   s   d S N selfr	   r	   J/var/www/html/stable-diffusion-webui/modules/processing_scripts/refiner.py__init__   s    zScriptRefiner.__init__c                 C   s   dS NRefinerr	   r
   r	   r	   r   title   s    zScriptRefiner.titlec                 C   s   t jS r   )r   AlwaysVisible)r   
is_img2imgr	   r	   r   show   s    zScriptRefiner.showc                    s   t dd| dd}t f tjd| dt ddd	}t|tjd
d | d tj	ddddd| ddd}W d    n1 s0    Y  W d    n1 s0    Y  dd  |dd f| fddf|dfg| _
|||fS )NFr   enable)labelelem_id
Checkpoint
checkpoint z3switch to another model in the middle of generation)r   r   choicesvaluetooltipc                   S   s   dt  iS )Nr   )r   checkpoint_tilesr	   r	   r	   r   <lambda>       z"ScriptRefiner.ui.<locals>.<lambda>Zcheckpoint_refreshg?z	Switch atg{Gz?g      ?Z	switch_atzzfraction of sampling steps when the switch to refiner model should happen; 1=never, 0.5=switch in the middle of generation)r   r   minimummaximumstepr   r   c                 S   s   t | }|d u rd S |jS r   )r   get_closet_checkpoint_matchr   )r   infor	   r	   r   lookup_checkpoint   s    
z+ScriptRefiner.ui.<locals>.lookup_checkpointc                 S   s   d| v S r   r	   dr	   r	   r   r   "   r   c                    s    |  dS r   )getr&   r%   r	   r   r   #   r   zRefiner switch at)r   r   grRowDropdownr   r   r   list_modelsSliderinfotext_fields)r   r   enable_refinerrefiner_checkpointrefiner_switch_atr	   r)   r   ui   s    
Z
zScriptRefiner.uic                 C   s*   |r|dv rd |_ d |_n||_ ||_d S )N)Nr   None)r1   r2   )r   pr0   r1   r2   r	   r	   r   setup)   s
    zScriptRefiner.setupN)
__name__
__module____qualname__sectioncreate_groupr   r   r   r3   r6   r	   r	   r	   r   r      s   r   )gradior*   modulesr   r   Zmodules.ui_commonr   Zmodules.ui_componentsr   ScriptBuiltinUIr   r	   r	   r	   r   <module>   s   