o yfA@sddlZddlmZmZmZddlmZmZmZddl m Z ddl m Z m Z ddlmZmZmZgdZGdd d eZGd d d Zed e d edddedddegddedddedddeiddedddeddgZede d edddedddedddedddeddddedddegddedddedddeiddedddeddg ZGd d!d!eZGd"d#d#eZGd$d%d%eZGd&d'd'eZ Gd(d)d)eZ!Gd*d+d+e Z"Gd,d-d-eZ#Gd.d/d/eZ$Gd0d1d1e Z%Gd2d3d3eZ&Gd4d5d5eZ'Gd6d7d7eZ(Gd8d9d9eZ)Gd:d;d;eZ*Gdd?d?eZ,Gd@dAdAeZ-iZ.ej/0D]B\Z1Z2ej34e1Z5e2j6rbej74e8e2j6e8e2j6neZ9e2dur|e.:e1ee9ee2j6e2j;dBfiqGe.:e1ee9efiqGediie.ZedDZ?e?D]0Z1e?e1j@dEkre?e1ZAeZBe?e1j6dure8e?e1j6ZBe=:eAj@eBeeAj6eAjCdBfiqedjie=ZDGdGdHdHeZEGdIdJdJeZFGdKdLdLeZGGdMdNdNeZHGdOdPdPeZIGdQdRdReZJGdSdTdTeZKGdUdVdVeZLGdWdXdXeZMGdYdZdZeZNGd[d\d\eZOGd]d^d^eZPGd_d`d`eZQGdadbdbeZRGdcddddeZSGdedfdfeZTGdgdhdheZUdS)kN) BaseModelField create_model)AnyOptionalLiteral) underscore) StableDiffusionProcessingTxt2Img StableDiffusionProcessingImg2Img) sd_upscalersoptsparser) selfkwargssd_modeloutpath_samples outpath_grids sampler_indexextra_generation_paramsoverlay_imagesdo_not_reload_embeddingsseed_enable_extrasprompt_for_display sampler_noise_scheduler_overrideddim_discretizec@s>eZdZUdZeed<eed<eed<eed<dZeed<dS) ModelDefz6Assistance Class for Pydantic Dynamic Model Generationfield field_alias field_type field_valueF field_excludeN) __name__ __module__ __qualname____doc__str__annotations__rr boolr(r(cC:\Users\Luke\Documents\Stable diffusion\Automatic1111\stable-diffusion-webui\modules\api\models.pyrs rc@s.eZdZdZ   ddefddZddZdS) PydanticModelGeneratorz Takes in created classes and stubs them out in a way FastAPI/Pydantic is happy about: source_data is a snapshot of the default values produced by the class params are the names of the actual keys required by __init__ N model_namec sdddd}||_|||_fdd|jD|_|D]!}|jtt|d|d|d|d d |vr;|d nd d qdS) NcSs|j}|dkr d}t|S)NImager%) annotationr)kvrr(r(r)field_type_generator2sz=PydanticModelGenerator.__init__..field_type_generatorcSs@ttddt|}i}|D] }i|t|jj}q|S)NcSs|tuS)N)object)xr(r(r)<szMPydanticModelGenerator.__init__..merge_class_params..)listfilterinspectgetmro signature__init__ parameters)class_Z all_classesr:classesr(r(r)merge_class_params;s z;PydanticModelGenerator.__init__..merge_class_paramsc sDg|]\}}|tvrtt||||t|jtrdn|jdqS)N)rrrr)API_NOT_ALLOWEDrr isinstancedefaultproperty).0r.r/r0r(r) Esz3PydanticModelGenerator.__init__..keytyper@excludeF)rrrrr ) _model_nameZ _class_dataitems _model_defappendrr)rr+class_instanceZadditional_fieldsr=fieldsr(rCr)r9,s       zPydanticModelGenerator.__init__cCs6dd|jD}t|jfi|}d|j_d|j_|S)zm Creates a pydantic BaseModel from the json and overrides provided at initialization c Ss*i|]}|j|jt|j|j|jdfqS))r@aliasrG)rrrrrr )rBdr(r(r) \sz9PydanticModelGenerator.generate_model..T)rJrrH __config__allow_population_by_field_nameallow_mutation)rrMZ DynamicModelr(r(r)generate_modelWsz%PydanticModelGenerator.generate_model)NNN)r!r"r#r$r%r9rTr(r(r(r)r*%s +r*r rEuler)rErFr@ script_name script_argsZ send_imagesTZ save_imagesFalwayson_scripts force_task_idinfotextr init_imagesdenoising_strengthg?maskZinclude_init_images)rErFr@rGc@8eZdZUeddddZeeed<eed<eed<dS)TextToImageResponseNr,%The generated image in base64 format.r@title descriptionimagesr:info r!r"r#rrdr4r%r&dictr(r(r(r)r_  r_c@r^)ImageToImageResponseNr,r`rardr:rerfr(r(r(r)rirhric@szeZdZUeddddZeded<eddd dZeed <edd dd d ddZ e ed<edddd d ddZ e ed<edddd d ddZ e ed<edddddZ e ed<eddd ddZeed <edd!d d"dZeed#<edd$d%dZeed&<ed'd(d)d*d+d,eDdZeed-<ed'd.d/d*d0d,eDdZeed1<edd2dd d d3dZe ed4<ed d5d6dZeed7<d8S)9ExtrasBaseRequestrz Resize ModezzSets the resize mode: 0 to upscale by upscaling_resize amount, 1 to upscale up to upscaling_resize_h x upscaling_resize_w.ra)r resize_modeTz Show resultsz.Should the backend return the generated image?show_extras_resultszGFPGAN VisibilityrkFz@Sets the visibility of GFPGAN, values should be between 0 and 1.)r@rbgele allow_inf_nanrcgfpgan_visibilityzCodeFormer VisibilityzDSets the visibility of CodeFormer, values should be between 0 and 1.codeformer_visibilityzCodeFormer Weightz@Sets the weight of CodeFormer, values should be between 0 and 1.codeformer_weightzUpscaling Factorz?By how much to upscale the image, only used when resize_mode=0.)r@rbgtrcupscaling_resizeiz Target WidthzCTarget width for the upscaler to hit. Only used when resize_mode=1.)r@rbrnrcupscaling_resize_wz Target HeightzDTarget height for the upscaler to hit. Only used when resize_mode=1.upscaling_resize_hz Crop to fitz=Should the upscaler crop the image to fit in the chosen size?upscaling_cropNonez Main upscalerzEThe name of the main upscaler to use, it has to be one of this list: z , cCg|]}|jqSr(namerBr2r(r(r)rDzExtrasBaseRequest. upscaler_1zSecondary upscalerzJThe name of the secondary upscaler to use, it has to be one of this list: cCr{r(r|r~r(r(r)rDr upscaler_2zSecondary upscaler visibilityzLSets the visibility of secondary upscaler, values should be between 0 and 1.extras_upscaler_2_visibilityz Upscale firstz/Should the upscaler run before restoring faces? upscale_firstN)r!r"r#rrlrr&rmr'rqfloatrrrsrvrwintrxryjoinr rr%rrrr(r(r(r)rjs ,,rjc@"eZdZUedddZeed<dS)ExtraBaseResponsez HTML infoz2A series of HTML tags containing the process info.rbrc html_infoN)r!r"r#rrr%r&r(r(r(r)r rc@$eZdZUeddddZeed<dS)ExtrasSingleImageRequestr,FImage to work on, must be a Base64 string containing the image's data.raimageNr!r"r#rrr%r&r(r(r(r)r rc@$eZdZUeddddZeed<dS)ExtrasSingleImageResponseNr,r`rarrr(r(r(r)rrrc@s4eZdZUedddZeed<eddZeed<dS) FileDataz File dataz!Base64 representation of the filerdataz File namerbr}N)r!r"r#rrr%r&r}r(r(r(r)rs rc@&eZdZUedddZeeed<dS)ExtrasBatchImagesRequestImagesz1List of images to work on. Must be Base64 stringsr imageListN)r!r"r#rrr4rr&r(r(r(r)r rc@r)ExtrasBatchImagesResponserz&The generated images in base64 format.rrdN)r!r"r#rrdr4r%r&r(r(r(r)rrrc@r)PNGInfoRequestr,zThe base64 encoded PNG imagerrNrr(r(r(r)rrrc@sJeZdZUedddZeed<edddZeed<edd dZ eed <d S) PNGInfoResponsez Image infoz7A string with the parameters used to generate the imagerreZItemsz:A dictionary containing all the other fields the image hadrI Parametersz/A dictionary with parsed generation info fieldsr:N) r!r"r#rrer%r&rIrgr:r(r(r(r)rs rc@r)ProgressRequestFzSkip current imagez Skip current image serializationraskip_current_imageN)r!r"r#rrr'r&r(r(r(r)rrrc@steZdZUedddZeed<eddZeed<edd dZe ed <ed d d dZ e ed<ed dddZ e ed<d S)ProgressResponseProgressz#The progress with a range of 0 to 1rprogressz ETA in secsr eta_relativeStatezThe current state snapshotstateNz Current imagezbThe current image in base64 format. opts.show_progress_every_n_steps is required for this to work.ra current_imagez Info textzInfo text used by WebUI.textinfo) r!r"r#rrrr&rrrgrr%rr(r(r(r)rs rc@s:eZdZUeddddZeed<eddddZeed <d S) InterrogateRequestrr,rrarclipModelzThe interrogate model used.modelN)r!r"r#rrr%r&rr(r(r(r)r rc@r)InterrogateResponseNCaptionz$The generated caption for the image.racaption)r!r"r#rrr%r&r(r(r(r)rrrc@r) TrainResponsez Train infoz:Response string from train embedding or hypernetwork task.rreNr!r"r#rrer%r&r(r(r(r)rrrc@r)CreateResponsez Create infoz;Response string from create embedding or hypernetwork task.rreNrr(r(r(r)rrr)r@rcOptions_option_string_actionshelpFlagsc@sPeZdZUeddZeed<eddZeeed<eddZ e eefed<dS) SamplerItemNamerr}AliasesaliasesroptionsN) r!r"r#rr}r%r&rr4rrgr(r(r(r)rs rc@sxeZdZUeddZeed<eddZeed<eddZe e eed<eddZ e e ed <ed dZ e eed <d S) SchedulerItemrrr}Labellabelrrz Default Rho default_rhozNeeds Inner Modelneed_inner_modelN)r!r"r#rr}r%r&rrrr4rrrr'r(r(r(r)rs rc@sxeZdZUeddZeed<eddZeeed<eddZ eeed<eddZ eeed <ed dZ ee ed <d S) UpscalerItemrrr} Model Namer+Path model_pathURL model_urlScalescaleN) r!r"r#rr}r%r&r+rrrrrr(r(r(r)rs rc@s eZdZUeddZeed<dS)LatentUpscalerModeItemrrr}N)r!r"r#rr}r%r&r(r(r(r)rs rc@seZdZUeddZeed<eddZeed<eddZe eed<eddZ e eed <ed dZ eed <ed dZ e eed <dS) SDModelItemTitlerrbrr+z Short hashhashz sha256 hashsha256Filenamefilenamez Config fileconfigN) r!r"r#rrbr%r&r+rrrrrr(r(r(r)rs rc@s2eZdZUeddZeed<eddZeed<dS) SDVaeItemrrr+rrN)r!r"r#rr+r%r&rr(r(r(r)rs rc@6eZdZUeddZeed<eddZeeed<dS)HypernetworkItemrrr}rpathN) r!r"r#rr}r%r&rrr(r(r(r)r  rc@r)FaceRestorerItemrrr}rcmd_dirN) r!r"r#rr}r%r&rrr(r(r(r)rrrc@sLeZdZUeddZeed<eddZeeed<eddZ ee ed<dS) RealesrganItemrrr}rrrrN) r!r"r#rr}r%r&rrrrr(r(r(r)r rc@sLeZdZUeddZeed<eddZeeed<eddZ eeed<dS) PromptStyleItemrrr}PromptpromptzNegative Promptnegative_promptN) r!r"r#rr}r%r&rrrr(r(r(r)rrrc@s~eZdZUedddZeeed<edddZee ed<edd dZ ee ed <ed d dZ eed <edddZ eed<dS) EmbeddingItemStepzHThe number of steps that were used to train this embedding, if availablerstepz SD CheckpointzFThe hash of the checkpoint this embedding was trained on, if available sd_checkpointzSD Checkpoint NamezThe name of the checkpoint this embedding was trained on, if available. Note that this is the name that was used by the trainer; for a stable identifier, use `sd_checkpoint` insteadsd_checkpoint_nameShapez5The length of each individual vector in the embeddingshapeZVectorsz&The number of vectors in the embeddingvectorsN) r!r"r#rrrrr&rr%rrrr(r(r(r)rs rc@sFeZdZUedddZeeefed<edddZ eeefed<dS) EmbeddingsResponseZLoadedz'Embeddings loaded for the current modelrloadedZSkippedzUEmbeddings skipped for the current model (likely due to architecture incompatibility)skippedN) r!r"r#rrrgr%rr&rr(r(r(r)r%s  rc@s6eZdZUedddZeed<edddZeed<dS) MemoryResponseRAMzSystem memory statsrramCUDAznVidia CUDA memory statscudaN)r!r"r#rrrgr&rr(r(r(r)r)s rc@s:eZdZUeddddZeed<eddddZeed<dS) ScriptsListNZTxt2imgzTitles of scripts (txt2img)ratxt2imgZImg2imgzTitles of scripts (img2img)img2img)r!r"r#rrr4r&rr(r(r(r)r.rrc@seZdZUeddddZeed<eddddZee ed<edd d dZ ee ed <edd d dZ ee ed <edd ddZ ee ed<eddddZ eeeed<dS) ScriptArgNrzName of the argument in UIrarValuezDefault value of the argumentvalueZMinimumz+Minimum allowed value for the argumentin UIminimumz+Maximum allowed value for the argumentin UImaximumz,Step for changing value of the argumentin UIrZChoicesz Possible values for the argumentchoices)r!r"r#rrr%r&rrrrrrrr4r(r(r(r)r3s "rc@sheZdZUeddddZeed<eddddZeed<edd d dZ eed <ed d dZ e e ed<dS) ScriptInfoNrz Script namerar}Z IsAlwaysonz9Flag specifying whether this script is an alwayson script is_alwaysonZ IsImg2imgz8Flag specifying whether this script is an img2img script is_img2img ArgumentszList of script's argumentsrargs) r!r"r#rr}r%r&rr'rrr4rr(r(r(r)r<s rc@seZdZUedddZeed<edddZeed<edd dZeed <ed d dZ eed <edddZ eed<edddZ eed<edddZ e ed<dS) ExtensionItemrzExtension namerr}RemotezExtension Repository URLremoteBranchzExtension Repository Branchbranchz Commit Hashz Extension Repository Commit Hash commit_hashVersionzExtension Versionversionz Commit Datez Extension Repository Commit Date commit_dateZEnabledz1Flag specifying whether this extension is enabledenabledN)r!r"r#rr}r%r&rrrrrrr'r(r(r(r)rBs r)r)r)Vr6pydanticrrrtypingrrrZ inflectionrmodules.processingr r modules.sharedr r r r>rr*r%r4r'rgrTZ#StableDiffusionTxt2ImgProcessingAPIrZ#StableDiffusionImg2ImgProcessingAPIr_rirjrrrrrrrrrrrrrrrM data_labelsrIrEmetadatargetrr@typemaprFZoptTypeupdaterZ OptionsModelflagsvars_optionsdestflag_typerZ FlagsModelrrrrrrrrrrrrrrrrrr(r(r(r)s  ?                      & &