Open Polarisjiumengyichang opened 1 year ago
same problem,how to solve?
img2img works well in webui, so I copied the image data from the browser network panel to postman, but it still not work.
Can you check if the mask field is present, I had the same issue and I had mask : "string" which was throwing the error
Can you check if the mask field is present, I had the same issue and I had mask : "string" which was throwing the error
you are right,thx
error "Invalid encoded" got resplved after I used a base64 image string as input in "init_images". It worked for .png image for me.
{
"init_images": [
"iV.... " #paste your base64 image sting here
],
"denoising_strength": 0.75,
"image_cfg_scale": 0,
"mask_blur": 4,
"inpainting_fill": 0,
"inpaint_full_res": true,
"prompt": "",
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"batch_size": 2,
"n_iter": 1,
"steps": 50,
"cfg_scale": 7,
"width": 512,
"height": 512
}
I used this as the body of my post request from Postman
Hello everybody,
just joining as well to share the same fate, running into the same issues that when using img2img I get the same error that the init image cannot be found even though I have a base64 img string specified. I'm using javascript instead of python but for text2img with controlnet where you can input imagebase64 it is working properly
const imageData = fs.readFileSync(path.resolve('../../gui/assets/images/image.png'));
const base64Image = "data:image/png;base64," + imageData.toString('base64');
const postData = JSON.stringify({
"init_images": [base64Image],
"prompt": prompt,
"negative_prompt": negativePrompt,
"alwayson_scripts": {
"controlnet": {
"args": controlNetUnits
}
},
"seed": seed,
"batch_size": numSamples,
"steps": steps,
"width": width,
"height": height,
"cfg_scale": 14,
});
const options = {
hostname: '127.0.0.1',
port: port,
path: '/sdapi/v1/img2img',
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
};
const requestResults = await postRequest(options, postData);
const info = JSON.parse(requestResults['info']);
const results = saveOutputs(requestResults['images'], info, outputPath)
If someone has experienced this and found a solution that would be amazing if you could share it. Drinks on me if we could resolve this since it seems like not working for a while now.
Many thanks in advance, Emre
i do a tyr, when i remove the mask args,but i generate a picture with blank
The string in "init_images" may be like this: def get_base64_image(path): with open(path, "rb") as f: data = base64.b64encode(f.read()).decode('ascii') return str(data)
一样,要创建公共链接,请在 .启动时间:13.3 秒(导入割炬:2.2 秒,导入 GRADIO:1.3 秒,导入 LDM:0.6 秒,其他导入:1.2 秒,安装代码:0.2 秒,加载脚本:2.4 秒,加载 SD 检查点:2.4 秒,创建 UI:2.8 秒,GRADIO 启动:0.2 秒)。 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████50/50 [01:16<00:00, 1.53s/it] API 错误: 发布: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: 发布: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: 发布: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: 发布: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''} API 错误: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'init image not found', 'body': '', 'errors': ''}
share=True``launch()
我的问题解决了,,,,多次尝试后 我全部重新下载,原因是ps的插件版本跟sd上的扩展版本不一样,因为sd有时候我会更新一下插件
img2img works well in webui, so I copied the image data from the browser network panel to postman, but it still not work.
have you solved this issue?
Hi all, I'm running the exact same issue and unable to solve it, has anyone figure it out...? using the API on port http://127.0.0.1:7861/ so no UI
Edit: I finally got this right I think. The issue was that I had a placeholder "string" on some of the keys value and got that error. Make sure to remove all of the keys with "string" so you don't get the error... Anyway the below code should work. I omitted most of them but you can use the payload object.
~~
img= toB64('./sd-img2img-input.jpeg')
payload = {
"prompt": "A fantasy landscape, trending on artstation, mystical sky",
"negative_prompt": "nude, disfigured, blurry",
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"batch_size": 1,
"n_iter": 1,
"steps": 50,
"cfg_scale": 7,
"width": 512,
"height": 512,
"restore_faces": True,
"tiling": True,
"do_not_save_samples": False,
"do_not_save_grid": False,
"eta": 0,
"denoising_strength": 0.75,
"s_min_uncond": 0,
"s_churn": 0,
"s_tmax": 0,
"s_tmin": 0,
"s_noise": 0,
"override_settings": {},
"override_settings_restore_afterwards": True,
"refiner_switch_at": 0,
"disable_extra_networks": False,
"comments": {},
"init_images": [img],
"resize_mode": 0,
"image_cfg_scale": 0,
"mask_blur_x": 4,
"mask_blur_y": 4,
"mask_blur": 0,
"inpainting_fill": 0,
"inpaint_full_res": True,
"inpaint_full_res_padding": 0,
"inpainting_mask_invert": 0,
"initial_noise_multiplier": 0,
"sampler_index": "Euler",
"include_init_images": True,
"script_args": [],
"send_images": True,
"save_images": False,
"alwayson_scripts": {}
}
~~
def toB64(imgPath):
with open(imgPath, "rb") as imageFile:
return base64.b64encode(imageFile.read()).decode("utf-8")
Hello, I have been testing several ways to get around this bug and the way I found I will share with you.
I'm using postman, POST method, with the FASTAPI endpoint /sdapi/v1/img2img windows 11 PRO running everything locally
{ "init_images": ["iV.. //image base64 encode//"], "payload": { "prompt": "A fantasy landscape, trending on artstation, mystical sky", "negative_prompt": "nude, disfigured, blurry", "seed": -1, "subseed": -1, "subseed_strength": 0, "seed_resize_from_h": -1, "seed_resize_from_w": -1, "batch_size": 1, "n_iter": 1, "steps": 50, "cfg_scale": 7, "width": 512, "height": 512, "restore_faces": "True", "tiling": "True", "do_not_save_samples": "False", "do_not_save_grid": "False", "eta": 0, "denoising_strength": 0.75, "s_min_uncond": 0, "s_churn": 0, "s_tmax": 0, "s_tmin": 0, "s_noise": 0, "override_settings": {}, "override_settings_restore_afterwards": "True", "refiner_switch_at": 0, "disable_extra_networks": "False", "comments": {}, "resize_mode": 0, "image_cfg_scale": 0, "mask_blur_x": 4, "mask_blur_y": 4, "mask_blur": 0, "inpainting_fill": 0, "inpaint_full_res": "True", "inpaint_full_res_padding": 0, "inpainting_mask_invert": 0, "initial_noise_multiplier": 0, "sampler_index": "Euler", "include_init_images": "True", "script_args": [], "send_images": "True", "save_images": "False", "alwayson_scripts": {} } }
Hello, I have been testing several ways to get around this bug and the way I found I will share with you.
I'm using postman, POST method, with the FASTAPI endpoint /sdapi/v1/img2img windows 11 PRO running everything locally
{ "init_images": ["iV.. //image base64 encode//"], "payload": { "prompt": "A fantasy landscape, trending on artstation, mystical sky", "negative_prompt": "nude, disfigured, blurry", "seed": -1, "subseed": -1, "subseed_strength": 0, "seed_resize_from_h": -1, "seed_resize_from_w": -1, "batch_size": 1, "n_iter": 1, "steps": 50, "cfg_scale": 7, "width": 512, "height": 512, "restore_faces": "True", "tiling": "True", "do_not_save_samples": "False", "do_not_save_grid": "False", "eta": 0, "denoising_strength": 0.75, "s_min_uncond": 0, "s_churn": 0, "s_tmax": 0, "s_tmin": 0, "s_noise": 0, "override_settings": {}, "override_settings_restore_afterwards": "True", "refiner_switch_at": 0, "disable_extra_networks": "False", "comments": {}, "resize_mode": 0, "image_cfg_scale": 0, "mask_blur_x": 4, "mask_blur_y": 4, "mask_blur": 0, "inpainting_fill": 0, "inpaint_full_res": "True", "inpaint_full_res_padding": 0, "inpainting_mask_invert": 0, "initial_noise_multiplier": 0, "sampler_index": "Euler", "include_init_images": "True", "script_args": [], "send_images": "True", "save_images": "False", "alwayson_scripts": {} } }
Thanks for this solution. Work well with img2img but when I added a "mask" key and value above "mask_blur_x", it does not work, just return image without masked inpainting
Is there an existing issue for this?
What happened?
when i use api img2img error happend API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
Steps to reproduce the problem
API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
What should have happened?
API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
Commit where the problem happens
API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
What platforms do you use to access the UI ?
No response
What browsers do you use to access the UI ?
No response
Command Line Arguments
List of extensions
API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
Console logs
Additional information
API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}