File size: 5,685 Bytes
c10aebf |
1 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# API
Stable diffusion webui์ API๋ฅผ ์ด์ฉํ์ฌ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ ์๋์ ๊ฐ์ด BMAB๋ฅผ ์ฌ์ฉํ์ฌ API Call์ ํ ์ ์์ต๋๋ค.
```python
import requests
import json
import base64
prompt = '''
1girl
'''
negative_prompt = '(worst quality, low quality:1.4),'
txt2img = {
'prompt': prompt,
'negative_prompt': negative_prompt,
'steps': 20,
'width': 512,
'height': 768,
'cfg_scale': 7,
'seed': -1,
'sampler_index': 'DPM++ SDE Karras',
'script_name': None,
'alwayson_scripts': {
'BMAB': {
'args': [
{
'enabled': True,
'face_detailing_enabled': True,
}
]
}
}
}
response = requests.post('http://localhost:7860/sdapi/v1/txt2img', data=json.dumps(txt2img))
print(response)
j = response.json()
b64_image = j['images'][0]
with open('test.png', 'wb') as image_file:
image_file.write(base64.b64decode(b64_image))
```
BAMB์ Argument๋ ์ ์ฅ๋ ์ค์ ํ์ผ๊ณผ ๋์ผํ๋ฉฐ,
์ด๊ฒ์ ๊ธฐ๋ฐ์ผ๋ก ๋ชจ๋ ์ค์ ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ค์ ์ ์๋ ๊ฒฝ์ฐ ๊ธฐ๋ณธ๊ฐ์ ์ฌ์ฉํฉ๋๋ค.
์๋๋ json ํํ์ ๊ธฐ๋ณธ ์ค์ ๊ฐ์
๋๋ค.
```json
{
"enabled": false,
"preprocess_checkpoint": "Use same checkpoint",
"preprocess_vae": "Use same vae",
"txt2img_noise_multiplier": 1,
"txt2img_extra_noise_multiplier": 0,
"txt2img_filter_hresfix_before_upscale": "None",
"txt2img_filter_hresfix_after_upscale": "None",
"resample_enabled": false,
"module_config": {
"resample_opt": {
"save_image": false,
"hiresfix_enabled": false,
"checkpoint": "Use same checkpoint",
"vae": "Use same vae",
"method": "txt2img-1pass",
"filter": "None",
"prompt": "",
"negative_prompt": "",
"sampler": "Use same sampler",
"upscaler": "BMAB fast",
"steps": 20,
"cfg_scale": 7,
"denoising_strength": 0.75,
"strength": 0.5,
"begin": 0.1,
"end": 0.9
},
"pretraining_opt": {
"hiresfix_enabled": false,
"pretraining_model": "Select Model",
"prompt": "",
"negative_prompt": "",
"sampler": "Use same sampler",
"steps": 20,
"cfg_scale": 7,
"denoising_strength": 0.75,
"dilation": 4,
"box_threshold": 0.35
},
"resize_intermediate_opt": {
"resize_by_person": true,
"method": "stretching",
"alignment": "bottom",
"filter": "None",
"scale": 0.85,
"denoising_strength": 0.75
},
"refiner_opt": {
"checkpoint": "Use same checkpoint",
"keep_checkpoint": true,
"prompt": "",
"negative_prompt": "",
"sampler": "Use same sampler",
"upscaler": "BMAB fast",
"steps": 20,
"cfg_scale": 7,
"denoising_strength": 0.75,
"scale": 1,
"width": 0,
"height": 0
},
"person_detailing_opt": {
"best_quality": false,
"force_1:1": false,
"block_overscaled_image": true,
"auto_upscale": true,
"scale": 4,
"dilation": 3,
"area_ratio": 0.1,
"limit": 1,
"background_color": 1,
"background_blur": 0
},
"person_detailing": {
"denoising_strength": 0.4,
"cfg_scale": 7
},
"face_detailing_opt": {
"best_quality": false,
"sort_by": "Score",
"limit": 1,
"prompt0": "",
"negative_prompt0": "",
"prompt1": "",
"negative_prompt1": "",
"prompt2": "",
"negative_prompt2": "",
"prompt3": "",
"negative_prompt3": "",
"prompt4": "",
"negative_prompt4": "",
"override_parameter": false,
"sampler": "Use same sampler",
"detection_model": "BMAB Face(Normal)",
"dilation": 4,
"box_threshold": 0.35,
"skip_large_face": false,
"large_face_pixels": 0.26
},
"face_detailing": {
"width": 512,
"height": 512,
"cfg_scale": 7,
"steps": 20,
"mask_blur": 4,
"inpaint_full_res": "Only masked",
"inpaint_full_res_padding": 32,
"denoising_strength": 0.4
},
"hand_detailing_opt": {
"block_overscaled_image": true,
"best_quality": false,
"detailing_method": "subframe",
"auto_upscale": true,
"scale": 4,
"box_threshold": 0.3,
"dilation": 0.1,
"additional_parameter": ""
},
"hand_detailing": {
"prompt": "",
"negative_prompt": "",
"denoising_strength": 0.4,
"cfg_scale": 7,
"inpaint_full_res": "Only masked",
"inpaint_full_res_padding": 32
},
"controlnet": {
"enabled": false,
"with_refiner": false,
"noise": false,
"noise_strength": 0.4,
"noise_begin": 0.1,
"noise_end": 0.9
},
"resize_by_person_opt": {
"mode": "Inpaint",
"scale": 0.85,
"denoising_strength": 0.6,
"dilation": 30
}
},
"pretraining_enabled": false,
"edge_flavor_enabled": false,
"edge_low_threadhold": 50,
"edge_high_threadhold": 200,
"edge_strength": 0.5,
"resize_intermediate_enabled": false,
"refiner_enabled": false,
"contrast": 1,
"brightness": 1,
"sharpeness": 1,
"color_saturation": 1,
"color_temperature": 0,
"noise_alpha": 0,
"noise_alpha_final": 0,
"input_image": null,
"blend_enabled": false,
"blend_alpha": 1,
"detect_enabled": false,
"masking_prompt": "",
"person_detailing_enabled": false,
"face_detailing_enabled": false,
"face_detailing_before_hiresfix_enabled": false,
"hand_detailing_enabled": false,
"resize_by_person_enabled": false,
"upscale_enabled": false,
"detailing_after_upscale": true,
"upscaler_name": "None",
"upscale_ratio": 1.5,
"config_file": "test",
"preset": "None"
}
```
|