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

Transfer generation parameters to previews #8944

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modules/ui_extra_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import os.path
import urllib.parse
from pathlib import Path
from PIL import PngImagePlugin

from modules import shared
from modules.images import read_info_from_image
import gradio as gr
import json
import html
Expand Down Expand Up @@ -290,6 +292,7 @@ def save_preview(index, images, filename):

img_info = images[index if index >= 0 else 0]
image = image_from_url_text(img_info)
geninfo, items = read_info_from_image(image)

is_allowed = False
for extra_page in ui.stored_extra_pages:
Expand All @@ -299,7 +302,12 @@ def save_preview(index, images, filename):

assert is_allowed, f'writing to {filename} is not allowed'

image.save(filename)
if geninfo:
pnginfo_data = PngImagePlugin.PngInfo()
pnginfo_data.add_text('parameters', geninfo)
image.save(filename, pnginfo=pnginfo_data)
else:
image.save(filename)

return [page.create_html(ui.tabname) for page in ui.stored_extra_pages]

Expand Down