Closed michaelmariaott closed 6 months ago
nothing happen for me,here is code
import requests
import json
import base64
params = {
"prompt": "a girl in the ground",
"negative_prompt": "",
"style_selections": [
"Fooocus V2",
"Fooocus Enhance",
"Fooocus Sharp"
],
"performance_selection": "Speed",
"aspect_ratios_selection": "1152*896",
"image_number": 1,
"image_seed": -1,
"sharpness": 2,
"guidance_scale": 4,
"base_model_name": "juggernautXL_version6Rundiffusion.safetensors",
"refiner_model_name": "None",
"refiner_switch": 0.5,
"loras": [
{
"model_name": "sd_xl_offset_example-lora_1.0.safetensors",
"weights": 0.1
}
],
"advanced_params": {
"adm_scaler_positive": 1.5,
"adm_scaler_negative": 0.6,
"adm_scaler_end": 0.3,
"refiner_swap_method": "joint",
"adaptive_cfg": 7,
"sampler_name": "dpmpp_2m_sde_gpu",
"scheduler_name": "karras",
"overwrite_step": -1,
"overwrite_switch": -1,
"overwrite_width": -1,
"overwrite_height": -1,
"overwrite_vary_strength": -1,
"overwrite_upscale_strength": -1,
"mixing_image_prompt_and_vary_upscale": False,
"mixing_image_prompt_and_inpaint": False,
"debugging_cn_preprocessor": False,
"skipping_cn_preprocessor": False,
"controlnet_softness": 0.25,
"canny_low_threshold": 64,
"canny_high_threshold": 128,
"inpaint_engine": "v1",
"freeu_enabled": False,
"freeu_b1": 1.01,
"freeu_b2": 1.02,
"freeu_s1": 0.99,
"freeu_s2": 0.95
},
"require_base64": False,
"async_process": True,
"uov_method": "Upscale (2x)",
"input_image": ""
}
def upscale_vary(image, params = params) -> dict:
"""
Upscale or Vary
"""
params["input_image"] = image
data = json.dumps(params)
response = requests.post(url="http://127.0.0.1:8888/v2/generation/image-upscale-vary",
data=data,
timeout=300)
return response.json()
i_image = open(".\\examples\\imgs\\bear.jpg", 'rb').read()
base64_iamge = base64.b64encode(i_image).decode('utf-8')
r = upscale_vary(image=base64_iamge, params=params)
Thank you, that helped me figure it out: The server error is thrown if {'Content-Type': 'application/json'}
is passed as a header. Appereantly the version in the Swagger UI docs is doing this by default as well. I think this should be changed, so the docs are working.
Edit: In Python it works without any specified headers. In Node.js, both headers (Content-Type
and accept
) have to be specified.
Post requests to /v2/generation/image-upscale-vary throw an Internal Server Error (with default settings/body from the documentation).