sd.js 1.1 KB
Newer Older
1
export default {
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
    draw (config, prompt) {
debugger    
        return new Promise(function(resolve,rejcet){
            debugger
            const data = {
                prompt: prompt,
                steps: config?.steps??20,
                negative_prompt: config?.negative_prompt??'',
                width: config?.width??512,
                height: config?.height??512,
                cfg_scale: config?.cfg_scale??6,
                seed : config?.seed??-1,
                sampler_name: config?.sampler_name??"DPM++ SDE Karras"
            }
            const headers = { 
                'content-type': 'application/json'
            };
    
            axios.post(config?.sd_api, data, { headers }).then(response => {
    
                debugger
                if (response.statusCode === 200 && response?.data?.images){
                    const image = res?.data?.images[0]                    
                    resolve('data:image/png;base64,' + image)
                }
                
            }).catch(err => {
                rejcet(err)
            });
31

32
        })
33

34
        
35 36 37 38
        
    }

}