@ -83,7 +83,7 @@ class SDPipeline:
self . model_type = os . environ . get ( " SD_MODEL_TYPE " , " sd15 " )
self . model_type = os . environ . get ( " SD_MODEL_TYPE " , " sd15 " )
self . low_vram = os . environ . get ( " SD_LOW_VRAM " , " " ) . lower ( ) in ( " 1 " , " true " , " yes " )
self . low_vram = os . environ . get ( " SD_LOW_VRAM " , " " ) . lower ( ) in ( " 1 " , " true " , " yes " )
self . lora_stack = self . _parse_lora_stack ( os . environ . get ( " SD_LORA_STACK " , " " ) )
self . lora_stack = self . _parse_lora_stack ( os . environ . get ( " SD_LORA_STACK " , " " ) )
self . quality_keywords = " hyper detail, Canon50, cinematic lighting, realistic, f/1.4, ISO 200, 1/160s, 8K, RAW, unedited "
self . quality_keywords = " hyper detail, cinematic lighting, realistic, unedited " #Canon50, f/1.4, ISO 200, 1/160s, 8K, RAW
def _parse_lora_stack ( self , lora_env : str ) - > list [ tuple [ str , float ] ] :
def _parse_lora_stack ( self , lora_env : str ) - > list [ tuple [ str , float ] ] :
""" Parse SD_LORA_STACK env var into list of (path, weight) tuples.
""" Parse SD_LORA_STACK env var into list of (path, weight) tuples.
@ -175,7 +175,6 @@ class SDPipeline:
if self . pipe is None :
if self . pipe is None :
self . load ( )
self . load ( )
seed = options . seed if options . seed is not None else self . _random_seed ( )
self . _stop_requested = False
self . _stop_requested = False
with self . _generation_lock :
with self . _generation_lock :
@ -184,7 +183,7 @@ class SDPipeline:
self . _stop_requested = False
self . _stop_requested = False
return
return
params = self . _compute_params ( options , seed , i )
params = self . _compute_params ( options , i )
full_prompt = f " { options . prompt } , { self . quality_keywords } " if options . add_quality_keywords else options . prompt
full_prompt = f " { options . prompt } , { self . quality_keywords } " if options . add_quality_keywords else options . prompt
image = self . _generate_image ( full_prompt , options . negative_prompt , params , options . width , options . height )
image = self . _generate_image ( full_prompt , options . negative_prompt , params , options . width , options . height )
@ -196,9 +195,13 @@ class SDPipeline:
result = self . _save_and_encode ( image , options , params , full_prompt , i )
result = self . _save_and_encode ( image , options , params , full_prompt , i )
yield result
yield result
def _compute_params ( self , options : GenerationOptions , seed : int , index : int ) - > ImageParams :
def _compute_params ( self , options : GenerationOptions , index : int ) - > ImageParams :
""" Compute generation parameters for a single image. """
""" Compute generation parameters for a single image. """
current_seed = seed + index if options . increment_seed else seed
if options . seed is not None :
if options . increment_seed :
current_seed = options . seed + index
else :
current_seed = self . _random_seed ( )
if options . vary_guidance and options . count > 1 :
if options . vary_guidance and options . count > 1 :
t = index / ( options . count - 1 )
t = index / ( options . count - 1 )