Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result output of the API is different from the result of webUI? #275

Open
yexin2124 opened this issue Oct 20, 2023 · 0 comments
Open

Comments

@yexin2124
Copy link

The same parameters and pictures, the face change result of the API is completely different from the face change result on webui, why is it?

def image_to_base64(image_path):
with open(image_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
base64_string = encoded_string.decode("utf-8")
return base64_string

def save_encoded_image(b64_image, output_path):  
    # Check if file exists, create if it doesn't exist
    if not os.path.exists(output_path):
        open(output_path, 'wb').close()

    # Open file in binary mode
    with open(output_path, 'wb') as f:
        f.write(base64.b64decode(b64_image))
        f.flush()
        f.close()


# base64
file_input_base64 = image_to_base64(file_input)     
file_ref_base64 = image_to_base64(file_ref)        

# Roop:
args_roop = [
    file_input_base64,                                                      #0 File Input
    True,                                                                   #1 Enable Roop
    '0',                                                                    #2 Comma separated face number(s)
    'H:/AI/sd-webui-aki-v4.3/models/roop/inswapper_128.onnx',               #3 Model
    'GFPGAN',                                                               #4 Restore Face: None; CodeFormer; GFPGAN
    1,                                                                      #5 Restore visibility value
    "4x-UltraSharp",                                                        #6 Upscaler (type 'None' if doesn't need)
    1,                                                                      #7 Upscaler scale value
    1,                                                                      #8 Upscaler visibility (if scale = 1)
    False,                                                                  #9 Swap in source image
    True                                                                    #11 Swap in generated image
]


data_face={
    "override_settings": {
        "sd_model_checkpoint": "majicmixRealistic_v7.safetensors [7c819b6d13]",
        "sd_vae": "vae-ft-mse-840000-ema-pruned.safetensors",
        "CLIP_stop_at_last_layers": 2, 
     },
    "prompt": "",  
    "negative_prompt": "",
    "init_images": [file_ref_base64],  
    "steps": 20,  
    "sampler_index": "Euler a",  
    "width": 1688,  
    "height": 1120,  
    "batch_size": 1,  
    "n_iter": 1,  
    "cfg_scale": 7,# CFG
    "denoising_strength": 0.1,
    "seed": -1,
    "alwayson_scripts": {
        "roop": {"is_img2img": True, "is_alwayson": True, "args": args_roop}
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant