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
logs/stable_diff_telegram_bot.log
*.session
images/

View File

@ -3,6 +3,7 @@ import re
import io
import uuid
import base64
import json
import requests
from datetime import datetime
from PIL import Image, PngImagePlugin
@ -102,7 +103,7 @@ def update_resolution(model_name):
def update_cfg_scale(model_name):
"""Update CFG scale based on the selected model."""
if model_name == "Juggernaut-XL_v9_RunDiffusionPhoto_v2":
default_payload["cfg_scale"] = 1
default_payload["cfg_scale"] = 2.5
else:
default_payload["cfg_scale"] = 7
@ -236,7 +237,11 @@ def process_images(images, user_id, user_name):
png_payload = {"image": "data:image/png;base64," + i}
response2 = requests.post(f"{SD_URL}/sdapi/v1/png-info", json=png_payload)
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.add_text("parameters", response2.json().get("info"))
image.save(f"{IMAGE_PATH}/{word}.png", pnginfo=pnginfo)