News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Copy PNG metadata via Regex to import into Lightroom Hierarchical tags?

Started by TushyBhutt, November 11, 2022, 05:47:30 PM

Previous topic - Next topic

StarGeek

Quote from: blue-j on November 14, 2022, 05:48:31 PMI know CUDA is highly recommended and NVIDIA is a leader in the field

That does follow with what I've understood.  I do have a GeForce RTX 3080 10GB marked as the most likely purchase.  It's at the very top of my price range, but it does come with a gift card which would be used toward other parts of the build.

QuoteI will ask my AI team for you.
I highly appreciate that.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

blue-j

Have you played with the online version, DreamStudio?

https://beta.dreamstudio.ai/

blue-j

OK, I have heard back from true experts who do this stuff every day.  NVIDIA with CUDA and CUDNN is their recommendation.  They shared this article:

https://www.projectpro.io/article/gpus-for-machine-learning/677#mcetoc_1ggng87r41d

- J

StarGeek

Quote from: blue-j on November 15, 2022, 12:25:15 AMHave you played with the online version, DreamStudio?
https://beta.dreamstudio.ai/

Not yet.  I made an account a while back but there isn't much with the free credits and I don't have money to spare.

Quote from: blue-j on November 15, 2022, 01:52:06 AMOK, I have heard back from true experts who do this stuff every day.  NVIDIA with CUDA and CUDNN is their recommendation.  They shared this article:

https://www.projectpro.io/article/gpus-for-machine-learning/677#mcetoc_1ggng87r41d

Many thanks.  That will help a lot.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

TushyBhutt

Quote from: StarGeek on November 14, 2022, 03:59:25 PM
Quote from: blue-j on November 14, 2022, 01:27:58 PMEven a custom XMP or Maker Notes namespace would be better.  Do you have an idea of what would be best?

XMP would be best and easiest to deal with.  "Prompt" and "Negative Prompt" would be list type tags.  The rest could be simple strings or if you wanted to get technical, integer/real.

I'm hoping to upgrade my 10 year old computer real soon, and SD is on my list of things to try.

Going off (exiftool) topic, is Nvidia better for the CUDA stuff or is GPU ram better.  I was looking things over and the Nvidea GPUs in my price range were 10-12 gb ram, while there were some 16 gig Radeon GPUs in the same range.  Woefully ill-informed on things at the moment.

NVIDIA has CudA, AMD and Intel do not.  AMD and Intel ARC work (kinda) on Linux, not so well in Windows. I have an NVIDIA 3060 with 12GB of VRAM and it was $500 CDN, outputs an 80 step 768x1152 image in about a minute.

TushyBhutt

Quote from: StarGeek on November 12, 2022, 03:05:51 PMTry this, assuming Windows CMD.  If otherwise, change double quotes into single quotes.  I'm also using ## as a separator.  If that pattern is used as part of the Parameters data at some point, it would have to be changed

exiftool -Sep "##" "-HierarchicalSubject<${Parameters;s/(.*)\nNegative prompt: (.*)\nSteps: (\d+), Sampler:(.*), CFG scale: (\d+), Seed: (\d+), Size: (.*), Model hash: (.*), Model:(.*), Denoising strength: (.*), Eta: (.*), First pass size: (.*)/Prompt|$1##Negative prompt|$2##Steps|$3##Sampler|$4##CFG scale|$5##Seed|$6##Size|$7##Model hash|$8##Model|$9##Denoising strength|$10##Eta|$11##First pass size|$12/}" /path/to/files/

Example output.  The -b (-binary) option is used to make it clear that each item is a separate entry
C:\>exiftool -P -overwrite_original -Sep "##" "-HierarchicalSubject<${Parameters;s/(.*)\nNegative prompt: (.*)\nSteps: (\d+), Sampler:(.*), CFG scale: (\d+), Seed: (\d+), Size: (.*), Model hash: (.*), Model:(.*), Denoising strength: (.*), Eta: (.*), First pass size: (.*)/Prompt|$1##Negative prompt|$2##Steps|$3##Sampler|$4##CFG scale|$5##Seed|$6##Size|$7##Model hash|$8##Model|$9##Denoising strength|$10##Eta|$11##First pass size|$12/}" Y:\!temp\bbb\test.png
    1 image files updated

C:\>exiftool -G1 -a -s -b -HierarchicalSubject Y:\!temp\bbb\test.png
Prompt|professional [digital airbrush:photo:0.5] art of an imp with sword, wearing old cloak, curly pale red-blonde hair, with few tattoos, dynamic bright atmospheric lighting
Negative prompt|logo, text, signature, (bad art)
Steps|75
Sampler| DPM++ 2M Karras
CFG scale|12
Seed|3334373882
Size|768x1152
Model hash|81761151
Model| Stable1.5
Denoising strength|0.7
Eta|0.89
First pass size|0x0


Ooooh.... follow up question!  Sometimes not all fields are output and sometimes not in the same order.  I would imagine that this is not something Regex could easily account for? The names are always the same, just not order/occurrence depending on the setting chosen to write to the file.

StarGeek

Quote from: TushyBhutt on November 17, 2022, 08:25:39 PMI have an NVIDIA 3060 with 12GB of VRAM and it was $500 CDN, outputs an 80 step 768x1152 image in about a minute.

Ah, ok.  That answers one question I couldn't figure out.  I had read somewhere that the 3060 had something that was to discourage bit coin miners, but I wasn't sure if it would affect other computations.

Quote from: TushyBhutt on November 17, 2022, 08:27:16 PMOoooh.... follow up question!  Sometimes not all fields are output and sometimes not in the same order.  I would imagine that this is not something Regex could easily account for? The names are always the same, just not order/occurrence depending on the setting chosen to write to the file.

That would be doable, but I think a bit different.  My original thought was to use a Perl split rather than regex but the fact that it was only 3 string separated by new lines and the final bit was all comma separated made me discard it.

I have to go run an errand, but the basic idea now would be to split on new line, then split the last string on the comma(space), them run all that through map. A bit more Perl-ish and complex.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

TushyBhutt

Quote from: StarGeek on November 18, 2022, 11:13:42 AM
Quote from: TushyBhutt on November 17, 2022, 08:27:16 PMOoooh.... follow up question!  Sometimes not all fields are output and sometimes not in the same order.  I would imagine that this is not something Regex could easily account for? The names are always the same, just not order/occurrence depending on the setting chosen to write to the file.

That would be doable, but I think a bit different.  My original thought was to use a Perl split rather than regex but the fact that it was only 3 string separated by new lines and the final bit was all comma separated made me discard it.

I have to go run an errand, but the basic idea now would be to split on new line, then split the last string on the comma(space), them run all that through map. A bit more Perl-ish and complex.

Oh, cool.  But please don't put too much work into it if I'm the only one asking.  In the meantime I can use the script to capture maybe one variable at a time.  Is there a flag that would append the PNG data into XMP:LR instead of just overwrite it?

TushyBhutt

Quote from: StarGeek on November 18, 2022, 11:13:42 AMI have to go run an errand, but the basic idea now would be to split on new line, then split the last string on the comma(space), them run all that through map. A bit more Perl-ish and complex.

Would this link help? Someone used PERL to extract the PNG data from a StableDiffusion image

https://github.com/Eugenii10/exiftool-sd-format

blue-j

I haven't seen "SD Extras" in the wild, so that's helpful!  Might you have a sample that evidences that?  I also wonder if they store whether CLIP was used or not.  I have yet to see it.

- J

TushyBhutt

Quote from: blue-j on November 20, 2022, 03:04:05 PMI haven't seen "SD Extras" in the wild, so that's helpful!  Might you have a sample that evidences that?  I also wonder if they store whether CLIP was used or not.  I have yet to see it.

- J

Are you looking for evidence of readable data in a PNG file from Stable Diffusion, or a program that reads it?  ImageGlass can do it with Exiftool as a plugin and the code above according to this link:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/1569#discussioncomment-4175458

I haven't tried it myself, I'm trying to get the PNG data into Lightroom :)

Also the screenshot there shows a weird cutoff for keywords fourteen and fifteen, so looks like the code could be tweaked

blue-j

Our software already reads all mentioned SD and OpenAI metadata. It is not yet available to the public though.

- J


TushyBhutt

Quote from: blue-j on November 26, 2022, 09:14:43 PMOur software already reads all mentioned SD and OpenAI metadata. It is not yet available to the public though.

- J



Is that software ExifTool or something else?  I don't think the new Stable 2.0 release from Thursday has anything new but may be worth checking.

blue-j

Our software uses ExifTool but also other tools, and post-processing.

Stable 2 is out!  Nice!  Will check, thanks so much for the heads up.  : )

- J

blue-j

I don't see any change in metadata using Stable v2 using DreamStudio.  - J