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

JPEG and PNG exif #24

Merged
merged 11 commits into from
Jan 10, 2025
Merged

JPEG and PNG exif #24

merged 11 commits into from
Jan 10, 2025

Conversation

exdysa
Copy link
Collaborator

@exdysa exdysa commented Jan 10, 2025

Comments (from previous pr) :

  • Only use f’ ‘ strings when there’s a variable inside, or the linter tools cry

  • Try/Except catches should only encapsulate the risky code, or else it hides errors in other code, making the code difficult to debug. ASK ME WHY I KNOW LOOL

  • In try/except catches, force the code to fail in the way you predict, then write that exception down instead of using generic as Exception,
    This way we know it is expected it to fail in a certain way, and no other errors are hidden that may need to be addressed differently

  • In general it’s better to use the packages included with python, and as few third-party dependencies as possible. For this reason, pillow and piexif might be redundant, but I’m not yet sure

I check it was working, and added a new test specific for the data you were sharing, but the real test is to open the file you were struggling with before. Send it to me, or try it yourself, w/e. In any case, your code looked pretty good on the whole, nice job! I would encourage you to continue to work on the jpeg aspect. Gonna close this branch and rename mine to kn/x after this merge :3

UPDATE: initial JPEG support added. Removed pixexf, because its outdated AF. Pillow does it all. Test and lmk whats up

Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
"With": '{"Some": "useful", "although": "also"}',
"Only": '{"The": "best", "Algorithm": "Will", "Successfully": "Match"}',
}
assert (

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
# expected_gen_data = ""
# assert result["Generation_Data"] == expected_gen_data
assert mock_delineate_by_esc_codes.call_count == 1
assert (

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylintpython3 (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

dataset_tools/access_disk.py Dismissed Show dismissed Hide dismissed
exif = {TAGS.get(key, val): val for key, val in img.info.items() if key in TAGS}
exif = {
ExifTags.TAGS[label]: content
for label, content in img._getexif().items()

Check warning

Code scanning / Prospector (reported by Codacy)

Access to a protected member _getexif of a client class (protected-access) Warning

Access to a protected member _getexif of a client class (protected-access)
@@ -49,9 +57,15 @@
img = Image.open(file_path_named)
if img is None: # We dont need to load completely unless totally necessary
img.load() # This is the case when we have no choice but to load (slower)
logger.debug(f"Metadata from png: {file_path_named}: {img.info}")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)

from pydantic_core import ValidationError
# from pydantic_core import ValidationError
from pydantic import TypeAdapter, BaseModel, Field, AfterValidator, field_validator, ValidationError

Check warning

Code scanning / Prospector (reported by Codacy)

Import "from pydantic import TypeAdapter, BaseModel, Field, AfterValidator, field_validator, ValidationError" should be placed at the top of the module (wrong-import-position) Warning

Import "from pydantic import TypeAdapter, BaseModel, Field, AfterValidator, field_validator, ValidationError" should be placed at the top of the module (wrong-import-position)
return extracted_data


def arrange_nodeui_metadata(header_data: dict) -> dict:

Check warning

Code scanning / Prospector (reported by Codacy)

Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) Warning

Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
self.display_metadata(metadata, file_path)

def load_metadata(self, file_path: str) -> dict:
def load_metadata(self, file_path: str, extension: str = '.png') -> dict:

Check warning

Code scanning / Prospector (reported by Codacy)

Unused argument 'extension' (unused-argument) Warning

Unused argument 'extension' (unused-argument)
formatted_chunk = delineate_escape_codes(mock_header_data)
self.actual_a1111_metadata = [
"PonyXLV6_Scores GrungeOutfiPDXL_ GlamorShots_PDXL PDXL_FLWRBOY",
'Steps: 30, Sampler: Euler a, Schedule type: Automatic, CFG scale: 7, Hires upscaler: 4x_foolhardy_Remacri, TI hashes: "PonyXLV6_Scores: 4b8555f2fb80, GrungeOutfiPDXL_: b6af61969ec4, GlamorShots_PDXL: 4b8ee3d1bd12, PDXL_FLWRBOY: af38cbdc40f6", Version: v1.10.0',

Check warning

Code scanning / Prospector (reported by Codacy)

line too long (276 > 159 characters) (E501) Warning test

line too long (276 > 159 characters) (E501)
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
tests/test_md_ps.py Dismissed Show dismissed Hide dismissed
if __name__ == "__main__":
unittest.main()

# ['PonyXLV6_Scoresmetadata_parser.py:34 GrungeOutfiPDXL_ GlamorShots_PDXL PDXL_FLWRBOY', 'Steps: 30, Sampler: Euler a, Schedule type: Automatic, CFG scale: 7, Seed: 444906227, Size: 832x1216, Model hash: 5a7e5d791e, Model: PoltergeistCOMIX-PDXL.fp16, Denoising strength: 0.2, Clip skip: 2, ADetailer model: face_yolov8n.pt, ADetailer confidence: 0.3, ADetailer dilate erode: 4, ADetailer mask blur: 4, ADetailer denoising strength: 0.4, ADetailer inpaint only masked: True, ADetailer inpaint padding: 32, ADetailer model 2nd: Anzhc Head+Hair seg medium no dill.pt, ADetailer confidence 2nd: 0.3, ADetailer dilate erode 2nd: 4, ADetailer mask blur 2nd: 4, ADetailer denoising strength 2nd: 0.4, ADetailer inpaint only masked 2nd: True, ADetailer inpaint padding 2nd: 32, ADetailer version: 24.11.1, Hires upscale: 2, Hires steps: 30, Hires upscaler: 4x_foolhardy_Remacri, TI hashes: "PonyXLV6_Scores: 4b8555f2fb80, GrungeOutfiPDXL_: b6af61969ec4, GlamorShots_PDXL: 4b8ee3d1bd12, PDXL_FLWRBOY: af38cbdc40f6, PonyXLV6_Scores: 4b8555f2fb80, GrungeOutfiPDXL_: b6af61969ec4, GlamorShots_PDXL: 4b8ee3d1bd12, PDXL_FLWRBOY: af38cbdc40f6", Version: v1.10.0']

Check warning

Code scanning / Prospector (reported by Codacy)

line too long (1157 > 159 characters) (E501) Warning test

line too long (1157 > 159 characters) (E501)
@exdysa exdysa mentioned this pull request Jan 10, 2025
@duskfallcrew duskfallcrew merged commit 5d8ff25 into main Jan 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants