diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-11-27 13:28:32 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-11-27 13:28:32 +0000 |
commit | 506d529d19f135f57e142371271f84d4971b456f (patch) | |
tree | 2ce3f9431baa71149afc320eacd6d23118847832 /modules/extras.py | |
parent | 488f831d528f538f8c6a801e91d80c5e2ee05cf1 (diff) | |
download | stable-diffusion-webui-gfx803-506d529d19f135f57e142371271f84d4971b456f.tar.gz stable-diffusion-webui-gfx803-506d529d19f135f57e142371271f84d4971b456f.tar.bz2 stable-diffusion-webui-gfx803-506d529d19f135f57e142371271f84d4971b456f.zip |
rework #5012 to also work for pictures dragged into the prompt and also add Clip skip + ENSD to parameters
Diffstat (limited to 'modules/extras.py')
-rw-r--r-- | modules/extras.py | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/modules/extras.py b/modules/extras.py index 0057bf9c..6021a024 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -1,6 +1,8 @@ from __future__ import annotations
import math
import os
+import sys
+import traceback
import numpy as np
from PIL import Image
@@ -12,7 +14,7 @@ from typing import Callable, List, OrderedDict, Tuple from functools import partial
from dataclasses import dataclass
-from modules import processing, shared, images, devices, sd_models
+from modules import processing, shared, images, devices, sd_models, sd_samplers
from modules.shared import opts
import modules.gfpgan_model
from modules.ui import plaintext_to_html
@@ -22,7 +24,6 @@ import piexif.helper import gradio as gr
import safetensors.torch
-
class LruCache(OrderedDict):
@dataclass(frozen=True)
class Key:
@@ -214,39 +215,8 @@ def run_pnginfo(image): if image is None:
return '', '', ''
- items = image.info
- geninfo = ''
-
- if "exif" in image.info:
- exif = piexif.load(image.info["exif"])
- exif_comment = (exif or {}).get("Exif", {}).get(piexif.ExifIFD.UserComment, b'')
- try:
- exif_comment = piexif.helper.UserComment.load(exif_comment)
- except ValueError:
- exif_comment = exif_comment.decode('utf8', errors="ignore")
-
- items['exif comment'] = exif_comment
- geninfo = exif_comment
-
- for field in ['jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'dpi', 'exif',
- 'loop', 'background', 'timestamp', 'duration']:
- items.pop(field, None)
-
- geninfo = items.get('parameters', geninfo)
-
- # nai prompt
- if "Software" in items.keys() and items["Software"] == "NovelAI":
- import json
- json_info = json.loads(items["Comment"])
- geninfo = f'{items["Description"]}\r\nNegative prompt: {json_info["uc"]}\r\n'
- sampler = "Euler a"
- if json_info["sampler"] == "k_euler_ancestral":
- sampler = "Euler a"
- elif json_info["sampler"] == "k_euler":
- sampler = "Euler"
- model_hash = '925997e9' # assuming this is the correct model hash
- # not sure with noise and strength parameter
- geninfo += f'Steps: {json_info["steps"]}, Sampler: {sampler}, CFG scale: {json_info["scale"]}, Seed: {json_info["seed"]}, Size: {image.width}x{image.height}, Model hash: {model_hash}' # , Denoising strength: {json_info["noise"]}'
+ geninfo, items = images.read_info_from_image(image)
+ items = {**{'parameters': geninfo}, **items}
info = ''
for key, text in items.items():
|