|
|
class SdConfig { |
|
|
constructor() { |
|
|
this.config |
|
|
} |
|
|
|
|
|
async getConfig() { |
|
|
try { |
|
|
this.config = await sdapi.requestGetConfig() |
|
|
return this.config |
|
|
} catch (e) { |
|
|
console.warn(e) |
|
|
} |
|
|
} |
|
|
getUpscalerModels() { |
|
|
try { |
|
|
|
|
|
let upscaler_comp |
|
|
|
|
|
for (let comp of this.config.components) { |
|
|
if (comp?.props?.elem_id) { |
|
|
const elem_id = comp?.props?.elem_id |
|
|
if (elem_id === 'txt2img_hr_upscaler') { |
|
|
console.log('elem_id: ', elem_id) |
|
|
upscaler_comp = comp |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log('upscaler_comp: ', upscaler_comp) |
|
|
const upscalers = upscaler_comp.props.choices |
|
|
|
|
|
return upscalers |
|
|
} catch (e) { |
|
|
console.warn(e) |
|
|
} |
|
|
} |
|
|
|
|
|
getControlNetMaxModelsNum() { |
|
|
try { |
|
|
let max_models_num = 0 |
|
|
for (let comp of this.config.components) { |
|
|
if (comp?.props?.elem_id) { |
|
|
const elem_id = comp?.props?.elem_id |
|
|
if (elem_id === 'setting_control_net_max_models_num') { |
|
|
console.log( |
|
|
'setting_control_net_max_models_num: ', |
|
|
comp?.props?.value |
|
|
) |
|
|
max_models_num = comp?.props?.value |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log('max_models_num: ', max_models_num) |
|
|
return max_models_num |
|
|
} catch (e) { |
|
|
console.warn(e) |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
|
|
|
getControlNetPreprocessors() { |
|
|
try { |
|
|
let max_models_num |
|
|
let choices |
|
|
for (let comp of this.config.components) { |
|
|
const label = comp?.props?.label |
|
|
if (label === 'Preprocessor') { |
|
|
choices = comp?.props?.choices |
|
|
break |
|
|
} |
|
|
} |
|
|
console.log('Preprocessor list: ', choices) |
|
|
return choices |
|
|
} catch (e) { |
|
|
console.warn(e) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
module.exports = { |
|
|
SdConfig, |
|
|
} |
|
|
|