mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
567 stars 152 forks source link

After update Fooocus and Fooocus-api, The image-inpaint-outpaint function is invalid when dealing with old parameters #307

Closed illusiona closed 2 months ago

illusiona commented 5 months ago

Here is my query parameter domo, it seems that fooocus has changed the parameter format

error response text: '{"detail":[{"type":"missing","loc":["body","loras",0,"enabled"],"msg":"Field required","input": {"model_name":"bathroom.safetensors","weight":0.8},"url":"https://errors.pydantic.dev/2.4/v/missing"}]}'

para { "prompt": "yushi, Bathtub, clean walls, no bathtub faucet on the wall, interior, bathroom, Masterpiece, " "Best Quality, ((Masterpiece)), (Cyberpunk 1.3), Gorath ((Best Quality: 1.4)), (Ultra HD: 1.2), " "(real:1.4), (8k:1.2), extremely detailed, architectural, landscaped toilets, no defects", "negative_prompt": "White edges, white spots, defects, (low quality: 2), white background, watermark," "(low resolution: 2), no unnecessary things around the product, floor-standing, " "(There is a stainless steel faucet on the wall:1.5),(there are defects on the " "wall:1.5),(there is excess on the wall:1.5), No dim", "style_selections": ['Fooocus V2', 'Fooocus Masterpiece', 'Fooocus Enhance', 'Fooocus Sharp', 'SAI Enhance'], "performance_selection": "Quality", "aspect_ratios_selection": f"{aspect_ratios_selection}", "image_number": image_number, "image_seed": -1, "sharpness": 4, "guidance_scale": 6, "base_model_name": "Actual_Texture_ZY_SDXL.safetensors", "refiner_model_name": "None", "refiner_switch": 0.8, "loras": [ { "model_name": "bathroom.safetensors", "weight": 0.8 } ], "advanced_params": { "adaptive_cfg": 7, "adm_scaler_end": 0.3, "adm_scaler_negative": 0.8, "adm_scaler_positive": 1.5, "canny_high_threshold": 128, "canny_low_threshold": 64, "controlnet_softness": 0.25, "debugging_cn_preprocessor": False, "debugging_inpaint_preprocessor": False, "disable_preview": False, "freeu_b1": 1.3, "freeu_b2": 1.4, "freeu_enabled": False, "freeu_s1": 0.9, "freeu_s2": 0.2, "inpaint_disable_initial_latent": True, "inpaint_engine": "v2.6", "inpaint_erode_or_dilate": 0, "inpaint_respective_field": 1, "inpaint_strength": 1, "invert_mask_checkbox": False, "mixing_image_prompt_and_inpaint": True, "mixing_image_prompt_and_vary_upscale": False, "overwrite_width": int(aspect_ratios_selection.split("")[0]), "overwrite_height": int(aspect_ratios_selection.split("")[1]), "overwrite_step": 30, "overwrite_switch": -1, "overwrite_upscale_strength": -1, "overwrite_vary_strength": -1, "refiner_swap_method": "vae", "sampler_name": "dpmpp_3m_sde_gpu", "scheduler_name": "karras", "skipping_cn_preprocessor": False }, "require_base64": True, "async_process": False, "webhook_url": "", "input_image": image_base64, "input_mask": mask_base64, "inpaint_additional_prompt": prompt, "outpaint_selections": [], "outpaint_distance_left": -1, "outpaint_distance_right": -1, "outpaint_distance_top": -1, "outpaint_distance_bottom": -1, "image_prompts": [{"cn_img": mask_base64.split(',')[-1], "cn_stop": 0.5, "cn_weight": 1, "cn_type": "PyraCanny", },

                          {"cn_img": original_base64.decode('utf-8'),
                           "cn_stop": 1,
                           "cn_weight": 0.23,
                           "cn_type": "ImagePrompt"}
                          ]

    }

requests.post(url=f"{host}/v2/generation/image-inpaint-outpaint", data=json.dumps(params), headers={"Content-Type": "application/json"})

mrhan1993 commented 5 months ago
"loras": [
  {
    "model_name": "bathroom.safetensors",
    "weight": 0.8
  }
]

change to

"loras": [
  {
    "enabled": true,
    "model_name": "bathroom.safetensors",
    "weight": 0.8
  }
]
illusiona commented 5 months ago
"loras": [
  {
    "model_name": "bathroom.safetensors",
    "weight": 0.8
  }
]

change to

"loras": [
  {
    "enabled": true,
    "model_name": "bathroom.safetensors",
    "weight": 0.8
  }
]

It's very useful, thank you very much for your help. There is now a new error that appears after generation. What is the reason for this PydanticJsonSchemaWarning: Default value annotation=NoneType required=False json_schema_extra={} is not JSON serializable; excluding default from JSON schema [non-serializable-default] warnings.warn(message, PydanticJsonSchemaWarning)

mrhan1993 commented 5 months ago

That is not an error