fenneishi / Fooocus-ControlNet-SDXL

add more control to fooocus
GNU General Public License v3.0
226 stars 9 forks source link

Api PyraCanny Image Prompt #29

Closed usliders closed 6 months ago

usliders commented 6 months ago

Describe the problem По API пытаюсь совместитть изображение с промтом. Через GUI работает великолепно, а вот с теми же настройками, но в скрипте, на выходе генерируется исключительно по промту. В чем может быть причина? Describe the problem Using the API, I'm trying to combine the image with the script. It works great through the GUI, but with the same settings, but in the script, the output is generated exclusively by promt. What could be the reason?

    result = client.predict(
        chosen_style_description, # str in 'parameter_10' Textbox component
        chosen_style_neodescription, # str in 'Negative Prompt' Textbox component
        ["Fooocus V2", "Default (Slightly Cinematic)", "SAI Fantasy Art"], # List[str] in 'Selected Styles' Checkboxgroup component
        "Speed", # str in 'Performance' Radio component
        "1152×896", # <span style=\"color: color;\"> ∣ 1:2</span>", # str in 'Aspect Ratios' Radio component
        1, # int | float (numeric value between 1 and 32) in 'Image Number' Slider component
        seed_rnd, # str in 'Seed' Textbox component
        20, # int | float (numeric value between 0.0 and 30.0) in 'Image Sharpness' Slider component
        4, # int | float (numeric value between 1.0 and 30.0) in 'Guidance Scale' Slider component 
        "sd_xl_base_1.0_0.9vae.safetensors", # str (Option from: ['bluePencilXL_v050.safetensors
        "sd_xl_refiner_1.0_0.9vae.safetensors", # str (Option from: ['None', 'bluePencilXL_v050.safetensors', 
        "sd_xl_offset_example-lora_1.0.safetensors", # in 'LoRA 1'
        1, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
        "None", # in 'LoRA 2' 
        -2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
        "None", # in 'LoRA 3'
        -2, # int | float (numeric value between -2 and 2)
        "None", # in 'LoRA 4'
        -2, # int | float (numeric value between -2 and 2)
        "None", # in 'LoRA 5'
        -2, # int | float (numeric value between -2 and 2)
        True, # bool in 'Input Image' Checkbox component
        "Image Prompt", # str in 'parameter_83' Textbox component
        "Disabled", # str in 'Upscale or Variation:' Radio component
        encoded_image, # str (filepath or URL to image) in 'Drag above image to here' Image component
        "Left, Right, Top, Bottom", # List[str] in 'Outpaint Direction' Checkboxgroup component  Left, 
        encoded_image,      
        1.0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0.6, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "PyraCanny", # str in 'Type' Radio component
        "data:image/jpeg;base64," + encoded_image, # str (filepath or URL to image) in 'Image' Image component
        0.4,    # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0.7, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "sketch", # str in 'Type' Radio component
        encoded_image, # str (filepath or URL to image) in 'Image' Image component
        0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "Image Prompt", # str in 'Type' Radio component
        encoded_image, # str (filepath or URL to image) in 'Image' Image component
        0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "Image Prompt", # str in 'Type' Radio component
        fn_index=23
    )

В логах ошибок нет There are no errors in the logs

Ответ API (value_4): {'visible': False, 'type': 'update'} Ответ API (Preview): {'visible': False, 'type': 'update'} Ответ API (Gallery): {'visible': True, 'value': [{'name': 'C:\TEmp\gradio\319c5d5643faf7e82331d38149a91a2257960a5c\image.png', 'data': None, 'is_file': True}], 'type': 'update'}

Full Console Log Requested to load SDXLClipModel Requested to load GPT2LMHeadModel Loading 2 new models [Fooocus Model Management] Moving model(s) has taken 0.43 seconds Total time: 44.19 seconds [Parameters] Adaptive CFG = 7 [Parameters] Sharpness = 20 [Parameters] ADM Scale = 1.5 : 0.8 : 0.3 [Parameters] CFG = 4.0 [Parameters] Sampler = dpmpp_2m_sde_gpu - karras [Parameters] Steps = 30 - 20 [Fooocus] Initializing ... [Fooocus] Loading models ... [Fooocus] Processing prompts ... [Fooocus] Preparing Fooocus text #1 ... [Prompt Expansion] New suffix: intricate, highly detailed 8K, smooth, sharp focus, beautiful and aesthetic shape of face and body, artgerm, artstation, art by zexi guo and nira and junpei suzuki and gharliera and rinotuna [Fooocus] Encoding positive #1 ... [Fooocus Model Management] Moving model(s) has taken 0.26 seconds [Fooocus] Encoding negative #1 ... Preparation time: 2.75 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.02916753850877285, sigma_max = 14.614643096923828 Requested to load SDXL Loading 1 new model [Fooocus Model Management] Moving model(s) has taken 2.60 seconds [Sampler] Fooocus sampler is activated. 67%|██████████████████████████████████████████████████████▋ | 20/30 [00:11<00:05, 1.72it/s]Requested to load SDXLRefiner Loading 1 new model [Fooocus Model Management] Moving model(s) has taken 1.21 seconds Refiner Swapped 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:19<00:00, 1.57it/s] Image generated with private log at: S:\FooocusControl\Fooocus\outputs\2024-01-08\log.html Generating and saving time: 26.30 seconds Requested to load SDXLClipModel Requested to load GPT2LMHeadModel Loading 2 new models [Fooocus Model Management] Moving model(s) has taken 0.44 seconds Total time: 30.59 seconds

По факту генерации - Upon generation По факту генерации - Upon generation

Генерация через GUI - Generation via GUI Генерация через GUI - Generation via GUI

Конечно ожидаем генерацию через API как на фото через GUI но этого не происходит Of course, we expect generation via the API as in the photo via the GUI, but this does not happen

usliders commented 6 months ago

Добрый день, разобрался с причиной которую описал в теме. Работает это так.

  1. Загружаем сервис Foocus control
  2. Во вкладке дополнительно ставим галки Advances
  3. Появляется вкладка справа наверху, Выбираем еще вкладку Advances
  4. Выставляем Developer Debug Mode галку И финал
  5. Выбираем Control Debug
  6. Ставим галки на Mixing Image Prompt and Vary/Upscale и Mixing Image Prompt and Inpaint генерируем в гуишке

и только после этого по api начнет работать смешение промт фотографий

вот рабочая версия

# Прочитайте изображение из файла и закодируйте его в base64
with open(photo_filename, "rb") as image_file:
    original_image_data = image_file.read()
    encoded_image = base64.b64encode(original_image_data).decode("utf-8")

# получаем рандомные числа
seed_rnd = random.randint(1, 9611608263085119394)
# Отправляем запрос к API
client = Client("http://127.0.0.1:7860/", serialize=False)
try:
    result = client.predict(
        chosen_style_description, # str in 'parameter_10' Textbox component
        chosen_style_neodescription, # str in 'Negative Prompt' Textbox component
        ["Fooocus V2", "Fooocus Photograph", "Default (Slightly Cinematic)", "SAI Fantasy Art"], # List[str] in 'Selected Styles' Checkboxgroup component
        "Quality", # str in 'Performance' Radio component
        "1152×896", # <span style=\"color: color;\"> ∣ 1:2</span>", # str in 'Aspect Ratios' Radio component
        1, # int | float (numeric value between 1 and 32) in 'Image Number' Slider component
        seed_rnd, # str in 'Seed' Textbox component
        10, # int | float (numeric value between 0.0 and 30.0) in 'Image Sharpness' Slider component
        7, # int | float (numeric value between 1.0 and 30.0) in 'Guidance Scale' Slider component 
        "juggernautXL_version6Rundiffusion.safetensors", #juggernautXL_version6Rundiffusion.safetensors", # str (Option from: ['bluePencilXL_v050.safetensors', 'DreamShaper_8_pruned.safetensors', 'juggernautXL_version6Rundiffusion.safetensors', 'realisticStockPhoto_v10.safetensors']) in 'Base Model (SDXL only)' Dropdown component
        "realisticStockPhoto_v10.safetensors", #realisticStockPhoto_v10.safetensors", # str (Option from: ['None', 'bluePencilXL_v050.safetensors', 'DreamShaper_8_pruned.safetensors', 'juggernautXL_version6Rundiffusion.safetensors', 'realisticStockPhoto_v10.safetensors'])
        "sd_xl_offset_example-lora_1.0.safetensors", #sd_xl_offset_example-lora_1.0.safetensors", # in 'LoRA 1' str (Option from: ['None', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors']) in 'LoRA 1' Dropdown component
        1.2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
        "None", # in 'LoRA 2' str (Option from: ['None', 'SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors', 'sd_xl_offset_example-lora_1.0.safetensors']) in 'LoRA 2' Dropdown component
        -2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
        "None", # in 'LoRA 3'
        -2, # int | float (numeric value between -2 and 2)
        "None", # in 'LoRA 4'
        -2, # int | float (numeric value between -2 and 2)
        "None", # in 'LoRA 5'
        -2, # int | float (numeric value between -2 and 2)
        True, # bool in 'Input Image' Checkbox component
        "None", # str in 'parameter_83' Textbox component
        "Disabled", # str in 'Upscale or Variation:' Radio component
        f"data:image/png;base64,{encoded_image}", # str (filepath or URL to image) in 'Drag above image to here' Image component
        ["Left", "Right", "Top", "Bottom"], # List[str] in 'Outpaint Direction' Checkboxgroup component  Left,  
        f"data:image/png;base64,{encoded_image}",
        f"data:image/png;base64,{encoded_image}",
        0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "PyraCanny", # str in 'Type' Radio component
        f"data:image/png;base64,{encoded_image}", # str (filepath or URL to image) in 'Image' Image component
        0.7,    # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        1.139, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "PyraCanny", # str in 'Type' Radio component
        f"data:image/png;base64,{encoded_image}", # str (filepath or URL to image) in 'Image' Image component
        0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "PyraCanny", # str in 'Type' Radio component
        f"data:image/png;base64,{encoded_image}", # str (filepath or URL to image) in 'Image' Image component
        0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
        0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
        "PyraCanny", # str in 'Type' Radio component
        fn_index=23
    )

Надеюсь комуто помог!!!