o yf @s`ddlZddlmZmZddlmZmZddlmZm Z ddl m Z GdddeZ dd Z dS) N) modelloadererrors)cmd_optsopts)Upscaler UpscalerData)upscale_with_modelcs,eZdZfddZddZddZZS) UpscalerDATcsd|_||_g|_t|jddgdD]}t|}t|||dd}|j |qt |D]}|jt j vr>|j |q0dS)NDATz.ptz.pth) ext_filter)upscalerscale) name user_pathscalerssuper__init__ find_modelsr friendly_namerappendget_dat_modelsrdat_enabled_models)selfrfiler scaler_datamodel __class__bC:\Users\Luke\Documents\Stable diffusion\Automatic1111\stable-diffusion-webui\modules\dat_model.pyr s     zUpscalerDAT.__init__cCspz||}Wntytjd|dd|YSwtj|j|jtj o*tj dd}t ||t j t jdS)NzUnable to load DAT model T)exc_infor )device prefer_halfexpected_architecture) tile_size tile_overlap) load_model Exceptionrreportrload_spandrel_modellocal_data_pathr!rno_halfupcast_samplingrrDAT_tileDAT_tile_overlap)rimgpathinfomodel_descriptorrrr do_upscales$ zUpscalerDAT.do_upscalecCsj|jD]*}|j|kr-|jdrtj|j|jd|_tj |js)t d|j|Sqt d|)Nhttp) model_dirzDAT data missing: zUnable to find model info: ) r data_pathr* startswithrload_file_from_urlmodel_download_pathosr0existsFileNotFoundError ValueError)rr0scalerrrrr&-s    zUpscalerDAT.load_model)__name__ __module__ __qualname__rr3r& __classcell__rrrrr s r cCs.tddd|dtddd|dtdd d |dgS) NzDAT x2zEhttps://github.com/n0kovo/dat_upscaler_models/raw/main/DAT/DAT_x2.pth)rr0r r zDAT x3zEhttps://github.com/n0kovo/dat_upscaler_models/raw/main/DAT/DAT_x3.pthzDAT x4zEhttps://github.com/n0kovo/dat_upscaler_models/raw/main/DAT/DAT_x4.pth)r)r>rrrr;s&r)r:modulesrrmodules.sharedrrmodules.upscalerrrZmodules.upscaler_utilsrr rrrrrs  2