cfg for XL
This commit is contained in:
parent
ec900759a1
commit
9f8bff3540
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ venv/
|
||||||
*.session-journal
|
*.session-journal
|
||||||
logs/stable_diff_telegram_bot.log
|
logs/stable_diff_telegram_bot.log
|
||||||
*.session
|
*.session
|
||||||
|
images/
|
9
main.py
9
main.py
|
@ -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
|
||||||
|
|
||||||
|
@ -236,7 +237,11 @@ def process_images(images, user_id, user_name):
|
||||||
png_payload = {"image": "data:image/png;base64," + i}
|
png_payload = {"image": "data:image/png;base64," + i}
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user