mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
fix sendto metadata
This commit is contained in:
+1
-1
@@ -659,7 +659,7 @@ def run_setup():
|
||||
if errors == 0:
|
||||
log.debug(f'Setup complete without errors: {round(time.time())}')
|
||||
else:
|
||||
log.warning(f'Setup complete with errors ({errors})')
|
||||
log.warning(f'Setup complete with errors: {errors}')
|
||||
log.warning('See log file for more details: setup.log')
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ svg.feather.feather-image, .feather .feather-image { display: none }
|
||||
#txt2img_cfg_scale { min-width: 200px; }
|
||||
#txt2img_checkboxes, #img2img_checkboxes { background-color: transparent; }
|
||||
#txt2img_checkboxes, #img2img_checkboxes { margin-bottom: 0.2em; }
|
||||
#txt2img_gallery, #img2img_gallery, #extras_gallery { background: black !important; padding: 0; margin: 0; object-fit: contain; box-shadow: none; min-height: 0; height: 45vh; }
|
||||
#txt2img_gallery, #img2img_gallery, #extras_gallery { background: black !important; padding: 0; margin: 0; object-fit: contain; box-shadow: none; min-height: 0; }
|
||||
#txt2img_generate, #img2img_generate { height: 36px; border: none; border-radius: 0; min-height: 36px; padding: 0; }
|
||||
#txt2img_interrupt, #img2img_interrupt, #txt2img_skip, #img2img_skip { height: 36px; min-width: 116px; max-width: 116px; border: none; border-radius: 0; background-color: var(--inactive-color); margin-top: 46px; display: block !important; padding: 0; }
|
||||
#txt2img_progress_row > div { min-width: var(--left-column); max-width: var(--left-column); }
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@ def run_pnginfo(image):
|
||||
items = {**{'parameters': geninfo}, **items}
|
||||
info = ''
|
||||
for key, text in items.items():
|
||||
info += f"<div><b>{html.escape(str(key))}</b>: {html.escape(str(text))}</div>"
|
||||
if key != 'UserComment':
|
||||
info += f"<div><b>{html.escape(str(key))}</b>: {html.escape(str(text))}</div>"
|
||||
if len(info) == 0:
|
||||
message = "Nothing found in the image."
|
||||
info = f"<div><p>{message}<p></div>"
|
||||
|
||||
@@ -6,7 +6,7 @@ import re
|
||||
from PIL import Image
|
||||
import gradio as gr
|
||||
from modules.paths import data_path
|
||||
from modules import shared, ui_tempdir, script_callbacks
|
||||
from modules import shared, ui_tempdir, script_callbacks, images
|
||||
|
||||
re_param_code = r'\s*([\w ]+):\s*("(?:\\"[^,]|\\"|\\|[^\"])+"|[^,]*)(?:,|$)'
|
||||
re_param = re.compile(re_param_code)
|
||||
@@ -51,7 +51,10 @@ def image_from_url_text(filedata):
|
||||
filename = filedata["name"]
|
||||
is_in_right_dir = ui_tempdir.check_tmp_file(shared.demo, filename)
|
||||
if is_in_right_dir:
|
||||
return Image.open(filename)
|
||||
image = Image.open(filename)
|
||||
geninfo, _items = images.read_info_from_image(image)
|
||||
image.info['parameters'] = geninfo
|
||||
return image
|
||||
else:
|
||||
shared.log.warning(f'File access denied: {filename}')
|
||||
return None
|
||||
@@ -70,6 +73,7 @@ def image_from_url_text(filedata):
|
||||
filedata = filedata[len("data:image/jpeg;base64,"):]
|
||||
filedata = base64.decodebytes(filedata.encode('utf-8'))
|
||||
image = Image.open(io.BytesIO(filedata))
|
||||
images.read_info_from_image(image)
|
||||
return image
|
||||
|
||||
|
||||
|
||||
+11
-4
@@ -14,7 +14,7 @@ import numpy as np
|
||||
import piexif
|
||||
import piexif.helper
|
||||
from PIL import Image, ImageFont, ImageDraw, PngImagePlugin, ExifTags
|
||||
from modules import sd_samplers, shared, script_callbacks, errors
|
||||
from modules import sd_samplers, shared, script_callbacks, errors, paths
|
||||
|
||||
LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)
|
||||
|
||||
@@ -449,9 +449,11 @@ def atomically_save_image():
|
||||
if shared.opts.save_txt and len(exifinfo_data) > 0:
|
||||
with open(txt_fullfn, "w", encoding="utf8") as file:
|
||||
file.write(exifinfo_data + "\n")
|
||||
with open(os.path.join(paths.data_path, "params.txt"), "w", encoding="utf8") as file:
|
||||
file.write(exifinfo_data)
|
||||
if shared.opts.save_log_fn != '' and len(exifinfo_data) > 0:
|
||||
try:
|
||||
with open(shared.opts.save_log_fn, mode='a+', encoding='utf-8') as f:
|
||||
with open(os.path.join(paths.data_path, shared.opts.save_log_fn), mode='a+', encoding='utf-8') as f:
|
||||
try:
|
||||
entries = json.load(f)
|
||||
except:
|
||||
@@ -582,7 +584,11 @@ def safe_decode_string(s: bytes):
|
||||
def read_info_from_image(image):
|
||||
items = image.info or {}
|
||||
geninfo = items.pop('parameters', None)
|
||||
if geninfo is None:
|
||||
geninfo = items.pop('UserComment', None)
|
||||
if geninfo is not None and len(geninfo) > 0:
|
||||
if 'UserComment' in geninfo:
|
||||
geninfo = geninfo['UserComment']
|
||||
items['UserComment'] = geninfo
|
||||
|
||||
if "exif" in items:
|
||||
@@ -595,9 +601,11 @@ def read_info_from_image(image):
|
||||
if isinstance(val, tuple) and isinstance(val[0], int) and isinstance(val[1], int): # convert camera ratios
|
||||
val = round(val[0] / val[1], 2)
|
||||
if val is not None and key in ExifTags.TAGS: # add known tags
|
||||
items[ExifTags.TAGS[key]] = val
|
||||
if ExifTags.TAGS[key] == 'UserComment': # add geninfo from UserComment
|
||||
geninfo = val
|
||||
items['parameters'] = val
|
||||
else:
|
||||
items[ExifTags.TAGS[key]] = val
|
||||
elif val is not None and key in ExifTags.GPSTAGS:
|
||||
items[ExifTags.GPSTAGS[key]] = val
|
||||
|
||||
@@ -617,7 +625,6 @@ Negative prompt: {json_info["uc"]}
|
||||
Steps: {json_info["steps"]}, Sampler: {sampler}, CFG scale: {json_info["scale"]}, Seed: {json_info["seed"]}, Size: {image.width}x{image.height}, Clip skip: 2, ENSD: 31337"""
|
||||
except Exception as e:
|
||||
errors.display(e, 'novelai image parser')
|
||||
|
||||
return geninfo, items
|
||||
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ def create_output_panel(tabname, outdir):
|
||||
open_folder_button = gr.Button('show', visible=not shared.cmd_opts.hide_ui_dir_config)
|
||||
|
||||
if tabname != "extras":
|
||||
save = gr.Button('Save', elem_id=f'save_{tabname}')
|
||||
save_zip = gr.Button('Zip', elem_id=f'save_zip_{tabname}')
|
||||
save = gr.Button('save', elem_id=f'save_{tabname}')
|
||||
save_zip = gr.Button('zip', elem_id=f'save_zip_{tabname}')
|
||||
|
||||
buttons = parameters_copypaste.create_buttons(["img2img", "inpaint", "extras"])
|
||||
|
||||
|
||||
@@ -4,6 +4,14 @@ import modules.generation_parameters_copypaste as parameters_copypaste
|
||||
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call # pylint: disable=unused-import
|
||||
from modules.extras import run_pnginfo
|
||||
|
||||
|
||||
def submit_click(tab_index, extras_image, image_batch, extras_batch_input_dir, extras_batch_output_dir, show_extras_results, *script_inputs):
|
||||
result_images, html_info_x, html_info = postprocessing.run_postprocessing(tab_index, extras_image, image_batch, extras_batch_input_dir, extras_batch_output_dir, show_extras_results, *script_inputs)
|
||||
if result_images is not None and len(result_images) > 0:
|
||||
_html_info, _generation_info, html_info_x = run_pnginfo(result_images[0])
|
||||
return result_images, html_info_x, html_info
|
||||
|
||||
|
||||
def create_ui():
|
||||
tab_index = gr.State(value=0) # pylint: disable=abstract-class-instantiated
|
||||
|
||||
@@ -63,7 +71,7 @@ def create_ui():
|
||||
)
|
||||
|
||||
submit.click(
|
||||
fn=call_queue.wrap_gradio_gpu_call(postprocessing.run_postprocessing, extra_outputs=[None, '']),
|
||||
fn=call_queue.wrap_gradio_gpu_call(submit_click, extra_outputs=[None, '']),
|
||||
inputs=[
|
||||
tab_index,
|
||||
extras_image,
|
||||
|
||||
Reference in New Issue
Block a user