cfg for XL

This commit is contained in:
tami-p40 2024-06-09 10:39:34 +03:00
parent ec900759a1
commit 9f8bff3540
2 changed files with 8 additions and 2 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ venv/
*.session-journal *.session-journal
logs/stable_diff_telegram_bot.log logs/stable_diff_telegram_bot.log
*.session *.session
images/

View File

@ -3,6 +3,7 @@ import re
import io import io
import uuid import uuid
import base64 import base64
import json
import requests import requests
from datetime import datetime from datetime import datetime
from PIL import Image, PngImagePlugin from PIL import Image, PngImagePlugin
@ -102,7 +103,7 @@ def update_resolution(model_name):
def update_cfg_scale(model_name): def update_cfg_scale(model_name):
"""Update CFG scale based on the selected model.""" """Update CFG scale based on the selected model."""
if model_name == "Juggernaut-XL_v9_RunDiffusionPhoto_v2": if model_name == "Juggernaut-XL_v9_RunDiffusionPhoto_v2":
default_payload["cfg_scale"] = 1 default_payload["cfg_scale"] = 2.5
else: else:
default_payload["cfg_scale"] = 7 default_payload["cfg_scale"] = 7
@ -237,6 +238,10 @@ def process_images(images, user_id, user_name):
response2 = requests.post(f"{SD_URL}/sdapi/v1/png-info", json=png_payload) response2 = requests.post(f"{SD_URL}/sdapi/v1/png-info", json=png_payload)
response2.raise_for_status() response2.raise_for_status()
# Write response2 json next to the image
with open(f"{IMAGE_PATH}/{word}.json", "w") as json_file:
json.dump(response2.json(), json_file)
pnginfo = PngImagePlugin.PngInfo() pnginfo = PngImagePlugin.PngInfo()
pnginfo.add_text("parameters", response2.json().get("info")) pnginfo.add_text("parameters", response2.json().get("info"))
image.save(f"{IMAGE_PATH}/{word}.png", pnginfo=pnginfo) image.save(f"{IMAGE_PATH}/{word}.png", pnginfo=pnginfo)