some fixes:
utf-8 from nvidia driver is supported comfyui files added read metadata from webp
This commit is contained in:
@@ -38,3 +38,23 @@ print(f"> File2 {file2}")
|
||||
with open(file2, "w") as f2:
|
||||
f2.writelines([f"version = \"{version}\"\n"])
|
||||
|
||||
|
||||
# modify pyproject.toml file with @version
|
||||
file3 = os.path.join(os.path.dirname(__file__), "../pyproject.toml")
|
||||
print(f"> File3: {file3}")
|
||||
|
||||
file3VersionFound = False
|
||||
# lines = None
|
||||
with open(file3, "r") as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
|
||||
if "version = " in line:
|
||||
file3VersionFound = True
|
||||
lines[lines.index(line)] = f"version = \"{version}\"\n"
|
||||
|
||||
if not file3VersionFound:
|
||||
raise RuntimeError(f"Version label not found in file: {file3}")
|
||||
|
||||
with open(file3, "w") as f3:
|
||||
f3.writelines(lines)
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
@author: Crystian
|
||||
@title: Crystools
|
||||
@nickname: Crystools
|
||||
@version: 1.12.0
|
||||
@version: 1.13.0
|
||||
@project: "https://github.com/crystian/ComfyUI-Crystools",
|
||||
@description: Plugins for multiples uses, mainly for debugging, you need them! IG: https://www.instagram.com/crystian.ia
|
||||
"""
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
version = "1.12.0"
|
||||
version = "1.13.0"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
+7
-1
@@ -39,9 +39,15 @@ class CGPUInfo:
|
||||
# deviceHandle = pynvml.nvmlDeviceGetHandleByIndex(0)
|
||||
for deviceIndex in range(self.cudaDevicesFound):
|
||||
deviceHandle = pynvml.nvmlDeviceGetHandleByIndex(deviceIndex)
|
||||
gpuName = 'Unknown GPU'
|
||||
|
||||
try:
|
||||
gpuName = pynvml.nvmlDeviceGetName(deviceHandle).decode('utf-8', errors='ignore')
|
||||
gpuName = pynvml.nvmlDeviceGetName(deviceHandle)
|
||||
try:
|
||||
gpuName = gpuName.decode('utf-8', errors='ignore')
|
||||
except AttributeError as e:
|
||||
pass
|
||||
|
||||
except UnicodeDecodeError as e:
|
||||
gpuName = 'Unknown GPU (decoding error)'
|
||||
print(f"UnicodeDecodeError: {e}")
|
||||
|
||||
+29
-8
@@ -2,6 +2,7 @@ import os
|
||||
import random
|
||||
import sys
|
||||
import json
|
||||
import piexif
|
||||
import hashlib
|
||||
from datetime import datetime
|
||||
import torch
|
||||
@@ -262,13 +263,15 @@ class CImageLoadWithMetadata:
|
||||
def execute(self, image):
|
||||
image_path = folder_paths.get_annotated_filepath(image)
|
||||
|
||||
img = Image.open(image_path)
|
||||
if img.format == 'WEBP':
|
||||
imgF = Image.open(image_path)
|
||||
img, prompt, metadata = buildMetadata(image_path)
|
||||
if imgF.format == 'WEBP':
|
||||
# Use piexif to extract EXIF data from WebP image
|
||||
exif_data = piexif.load(image_path)
|
||||
prompt, metadata = self.process_exif_data(exif_data)
|
||||
else:
|
||||
img, prompt, metadata = buildMetadata(image_path)
|
||||
try:
|
||||
exif_data = piexif.load(image_path)
|
||||
prompt, metadata = self.process_exif_data(exif_data)
|
||||
except ValueError:
|
||||
prompt = {}
|
||||
|
||||
img = ImageOps.exif_transpose(img)
|
||||
image = img.convert("RGB")
|
||||
@@ -281,7 +284,7 @@ class CImageLoadWithMetadata:
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
|
||||
return image, mask.unsqueeze(0), prompt, metadata
|
||||
|
||||
|
||||
def process_exif_data(self, exif_data):
|
||||
metadata = {}
|
||||
# 检查 '0th' 键下的 271 值,提取 Prompt 信息
|
||||
@@ -306,9 +309,26 @@ class CImageLoadWithMetadata:
|
||||
except json.JSONDecodeError:
|
||||
# 如果转换失败,则将原始字符串存储在 metadata 中
|
||||
metadata['workflow'] = workflow_data
|
||||
|
||||
metadata.update(exif_data)
|
||||
return metadata
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, image):
|
||||
image_path = folder_paths.get_annotated_filepath(image)
|
||||
m = hashlib.sha256()
|
||||
with open(image_path, 'rb') as f:
|
||||
m.update(f.read())
|
||||
return m.digest().hex()
|
||||
|
||||
@classmethod
|
||||
def VALIDATE_INPUTS(cls, image):
|
||||
if not folder_paths.exists_annotated_filepath(image):
|
||||
return "Invalid image file: {}".format(image)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class CImageSaveWithExtraMetadata(SaveImage):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -371,7 +391,8 @@ class CImageSaveWithExtraMetadata(SaveImage):
|
||||
|
||||
if metadata_extra is not None and metadata_extra != 'undefined':
|
||||
try:
|
||||
metadata_extra = json.loads(f"{{{metadata_extra}}}")
|
||||
# metadata_extra = json.loads(f"{{{metadata_extra}}}") // a fix?
|
||||
metadata_extra = json.loads(metadata_extra)
|
||||
except Exception as e:
|
||||
logger.error(f"Error parsing metadata_extra (it will send as string), error: {e}")
|
||||
metadata_extra = {"extra": str(metadata_extra)}
|
||||
|
||||
+14
-14
@@ -1,14 +1,14 @@
|
||||
[project]
|
||||
name = "comfyui-crystools"
|
||||
description = "With this suit, you can see the resources monitor, progress bar & time elapsed, metadata and compare between two images, compare between two JSONs, show any value to console/display, pipes, and more!\nThis provides better nodes to load/save images, previews, etc, and see \"hidden\" data without loading a new workflow."
|
||||
version = "1.0.0"
|
||||
license = "LICENSE"
|
||||
dependencies = ["deepdiff", "torch", "numpy", "Pillow>=9.5.0", "pynvml", "py-cpuinfo"]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/crystian/ComfyUI-Crystools"
|
||||
|
||||
[tool.comfy]
|
||||
PublisherId = ""
|
||||
DisplayName = "ComfyUI-Crystools"
|
||||
Icon = ""
|
||||
[project]
|
||||
name = "comfyui-crystools"
|
||||
description = "With this suit, you can see the resources monitor, progress bar & time elapsed, metadata and compare between two images, compare between two JSONs, show any value to console/display, pipes, and more!\nThis provides better nodes to load/save images, previews, etc, and see \"hidden\" data without loading a new workflow."
|
||||
version = "1.13.0"
|
||||
license = "LICENSE"
|
||||
dependencies = ["deepdiff", "torch", "numpy", "Pillow>=9.5.0", "pynvml", "py-cpuinfo"]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/crystian/ComfyUI-Crystools"
|
||||
|
||||
[tool.comfy]
|
||||
PublisherId = "crystian"
|
||||
DisplayName = "ComfyUI-Crystools"
|
||||
Icon = "https://raw.githubusercontent.com/crystian/ComfyUI-Crystools/main/docs/screwdriver.png"
|
||||
|
||||
@@ -4,3 +4,4 @@ numpy
|
||||
Pillow>=9.5.0
|
||||
pynvml
|
||||
py-cpuinfo
|
||||
piexif
|
||||
|
||||
Reference in New Issue
Block a user