Warning: No writable tags set from

Started by inclusivetech, January 11, 2023, 09:15:09 PM

Previous topic - Next topic

inclusivetech

I had the Imagga AI run against some pics to generate tags.  These come out with the pics as JSON files.  I am working on merging the tags back into the original jpg files. and it's coming back like this.

{
    "result": {
        "tags": [
            {
                "confidence": 89.5181579589844,
                "tag": {
                    "en": "bikini"
                }
            },
            {
                "confidence": 61.2723846435547,
                "tag": {
                    "en": "swimsuit"
                }
            },
            {
                "confidence": 53.3320236206055,
                "tag": {
                    "en": "attractive"


This is the command I am running. Output Below

exiftool -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Wonder 1.11"

D:\Unstable Diffustion\Images\Wonder 1.11> ./exiftool -r -d %s -tagsfromfile "%d/%F.json" "-Tags" -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Wonder 1.11"
======== D:/Unstable Diffustion/Images/Wonder 1.11/exiftool.exe [1/82]
./exiftool : Warning: Error opening file - D:/Unstable Diffustion/Images/Wonder 1.11/exiftool.exe.json
At line:1 char:1
+ ./exiftool -r -d %s -tagsfromfile "%d/%F.json" "-Tags" -ext "*" -over ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Warning: Error ...iftool.exe.json:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Nothing changed in D:/Unstable Diffustion/Images/Wonder 1.11/exiftool.exe
======== D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455156722.jpg [2/82]
Warning: No writable tags set from D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455156722.jpg.json
Nothing changed in D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455156722.jpg
======== D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455233506.jpg [3/82]
Warning: No writable tags set from D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455233506.jpg.json
Nothing changed in D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455233506.jpg
======== D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455266904.jpg [4/82]
Warning: No writable tags set from D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673455266904.jpg.json

Phil Harvey

First, you're also trying to write exiftool.exe since you are processing all extensions except .json.

Second, run exiftool -s on one of the JSON files to see what tags are available for copying, and use those.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

inclusivetech

#2
Cool Thanks.

-s output...  looks like it's called.  ResultTagsTagEn  I am not sure what to do with it.

I dropped it in the command, just to see what it does.

./exiftool -r -d %s -tagsfromfile "%d/%F.json" "-ResultTagsTagEn"  -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Wonder 1.11"

Which comes back undefined.

Warning: Tag 'resulttagstagen' is not defined - D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673462486272.jpg.json
Warning: No writable tags set from D:/Unstable Diffustion/Images/Wonder 1.11/wonder_1673462486272.jpg.json

no surprise there, but I don't know what to do with it from here.

exiftool -s

D:\Unstable Diffustion\Images\Wonder 1.11> .\exiftool.exe -s wonder_1673455156722.jpg.json
ExifToolVersion                : 12.54
FileName                        : wonder_1673455156722.jpg.json
Directory                      : .
FileSize                        : 15 kB
FileModifyDate                  : 2023:01:11 16:45:05-08:00
FileAccessDate                  : 2023:01:11 17:35:15-08:00
FileCreateDate                  : 2023:01:11 16:45:05-08:00
FilePermissions                : -rw-rw-rw-
FileType                        : JSON
FileTypeExtension              : json
MIMEType                        : application/json
ResultTagsConfidence            : 55.424560546875, 52.2147750854492, 44.0831832885742, 41.4701652526855, 40.449951171875, 33.5914688110352, 33.5796508789062, 30.6748733520508, 30.4014911651611, 28.5399150848389, 28.4369621276855, 26.3776378631592, 25.2322044
372559, 24.546968460083, 24.5322570800781, 23.9478626251221, 23.8399696350098, 22.726448059082, 19.3346900939941, 19.2913665771484, 18.2972640991211, 18.1309413909912, 17.7607975006104, 17.6919898986816, 17.496826171875, 16.478588104248, 16.2935028076172, 16
.0449886322021, 15.821192741394, 15.6811504364014, 14.9968481063843, 14.9163084030151, 14.6897830963135, 14.5904197692871, 14.4393644332886, 13.7870092391968, 13.631609916687, 13.5912179946899, 13.5642690658569, 13.3367881774902, 13.081561088562, 12.65133094
7876, 12.598370552063, 12.4309568405151, 12.2259950637817, 11.9270191192627, 11.9020776748657, 11.4401950836182, 11.4055156707764, 10.8778123855591, 10.8739948272705, 10.8307027816772, 10.7573671340942, 10.4717245101929, 10.3779706954956, 10.0472383499146, 9
.98433399200439, 9.91506385803223, 9.87940692901611, 9.63485622406006, 9.48180675506592, 9.42571067810059, 9.38421535491943, 9.36707019805908, 9.30603694915771, 8.8770923614502, 8.82676410675049, 8.79378128051758, 8.77444076538086, 8.64815902709961, 8.517061
23352051, 8.3528528213501, 8.28499984741211, 8.22709560394287, 8.19260215759277, 7.95902824401855, 7.94987916946411, 7.88072395324707, 7.81133079528809, 7.78130149841309, 7.74615097045898, 7.71131038665771, 7.67988681793213, 7.59536123275757, 7.5597701072692
9, 7.49069976806641, 7.38744068145752, 7.33018398284912, 7.32242107391357, 7.24566173553467, 7.19850158691406, 7.14901304244995, 7.07396078109741
ResultTagsTagEn                : costume, sexy, attractive, fashion, model, pretty, body, lingerie, adult, hair, posing, sensual, erotic, people, sensuality, portrait, person, lady, underwear, style, brunette, gorgeous, face, black, slim, makeup, glamor, bl
ond, women, one, human, skin, long, clothing, temptation, happy, cute, pose, stylish, lovely, feminine, dress, elegance, seductive, passion, mask, bikini, hairstyle, smile, pedestrian, pink, stockings, bra, wearing, legs, hot, make, dance, studio, sexual, fa
shionable, elegant, expression, youth, outfit, hat, panties, provocative, babe, covering, dancer, skirt, fit, harness, exotic, smiling, lifestyle, sunglasses, alluring, carnival, glamorous, modern, shoes, hand, healthy, clothes, leather, 20s, cover girl, fig
ure, looking, bright, summer
StatusText                      :
StatusType                      : success

Phil Harvey

From your previous post it looked like you wanted to copy this tag to Subject and Keywords, ie)

"-subject<ResultTagsTagEn" "-keywords<ResultTagsTagEn"

I would also suggest adding -sep ", " to split them into individual words when writing.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

inclusivetech


   1 directories scanned
   81 image files updated
    1 image files unchanged

Awesome!  Thank You

55,000 to go.   :D

Quote from: Phil Harvey on January 12, 2023, 07:18:25 AMFrom your previous post it looked like you wanted to copy this tag to Subject and Keywords, ie)

"-subject<ResultTagsTagEn" "-keywords<ResultTagsTagEn"

I would also suggest adding -sep ", " to split them into individual words when writing.

- Phil

inclusivetech

#5
Another Question:

The Imagga api also has a basic NSFW check. The output looks like this.

PS D:\Unstable Diffustion> .\exiftool.exe "D:\Unstable Diffustion\Images\Export\Test\PhotoRealistic-204.jpg.json"
ExifTool Version Number        : 12.54
File Name                      : PhotoRealistic-204.jpg.json
Directory                      : D:/Unstable Diffustion/Images/Export/Test
File Size                      : 461 bytes
File Modification Date/Time    : 2023:01:12 17:35:58-08:00
File Access Date/Time          : 2023:01:12 17:47:51-08:00
File Creation Date/Time        : 2023:01:12 17:35:58-08:00
File Permissions                : -rw-rw-rw-
File Type                      : JSON
File Type Extension            : json
MIME Type                      : application/json
Result Categories Confidence    : 85.2599258422852, 13.8019952774048
Result Categories Name En      : underwear, nsfw
Status Text                    :
Status Type                    : success

Not the same at all.  Read the category as a tag, and append to the other list is what I would like to do.

The confidence level is also above the category, I only need the highest one.  I should be able to filter on confidence in this query.  If you have an easy way to just catch the first one, I would use that.

Thanks for looking.


Phil Harvey

This is getting more complicated, but your command should look something like this:

exiftool -r -d %s -addtagsfromfile "%d/%F.json" "-subject<ResultTagsTagEn" "-keywords<ResultTagsTagEn""-subject<ResultCategoriesNameEn" "-keywords<ResultCategoriesNameEn" "-subject<${ResultCategoriesConfidence;s/,.*//}" "-keywords<${ResultCategoriesConfidence;s/,.*//}" -sep ", " -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Wonder 1.11"

Note that -addtagsfromfile is needed instead of -tagsfromfile to allow multiple copy operations to the same list-type tag.  Also, I wasn't clear on what you wanted to do with the first confidence number so I assumed you wanted to write it to Subject and Keywords as well (although that doesn't make a lot of sense to me), but you can change the command to do whatever else you want with it.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

inclusivetech

Cool thanks,

No I don't need the confidence tag.  However thank you.  I will give it a shot.

inclusivetech

#8
I had to run this in two processes, so two sets of files.
#apply tags to images
./exiftool -r -d %s -tagsfromfile "%d/%F.json" "-subject<ResultTagsTagEn" "-keywords<ResultTagsTagEn" "-subject<ResultCategoriesNameEn" "-keywords<ResultCategoriesNameEn"  -sep ", "  -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Export\PhotoRealistic"
#nsfw add Tags to images

./exiftool -r -d %s -addtagsfromfile "%d/%F.json"  "-subject<ResultCategoriesNameEn" "-keywords+=ResultCategoriesNameEn" -sep ", "  -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Export\PhotoRealistic"

It works, but it appends all of the categories from the second command.

I am waiting to hear back from support at Imagga on if I can filter it. 

Thanks.

Phil Harvey

Quote from: inclusivetech on January 13, 2023, 01:27:09 AM#nsfw add Tags to images

./exiftool -r -d %s -addtagsfromfile "%d/%F.json"  "-subject<ResultCategoriesNameEn" "-keywords+=ResultCategoriesNameEn" -sep ", "  -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Export\PhotoRealistic"

I don't think this is what you want.  This command will overwrite existing Subject entries with the ResultCategoriesNameEn tag value, and add the literal string "ResultCategoriesNameEn" to the Keywords.  I'm guessing you were trying to do this to add the ResultCategoriesNameEn values to the existing Subject and Keywords:

./exiftool -r -d %s -addtagsfromfile "%d/%F.json"  "-subject+<ResultCategoriesNameEn" "-keywords+<ResultCategoriesNameEn" -sep ", "  -ext "*" -overwrite_original -progress --ext json "D:\Unstable Diffustion\Images\Export\PhotoRealistic"

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


Phil Harvey

Hold on.  Why did you run this as 2 processes?  If you used -addtagsfromfile instead of -tagsfromfile in the first command, then it should have done everything in one command.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

inclusivetech

#12
Because the Imagga endpoints were separate (What they call the AI interface that is online).  The 'tagging' endpoint and the 'NSFW' endpoint produced files with the same name, each independently.  So I just kept them in separate folders, ran one command then the next.

This is a workflow in development.  I expect to streamline the steps.

What I just did is had ChatGPT help with this python script. (it does not always get it right, but pretty close) it saves some time.  This takes all of the categories, and just keeps the top one.  It changed the formatting a little, but does what I wanted it to do. 

import os
import json

# Define the path of the folder containing the JSON files
folder_path = 'D:/Unstable Diffustion/Images/Export/PhotoRealistic'

# Iterate over all files in the folder
for file_name in os.listdir(folder_path):
    if file_name.endswith(".json"):
        # Read the original JSON file
        file_path = os.path.join(folder_path, file_name)
        with open(file_path, "r") as file:
            data = json.load(file)

        # Extract the first entry of the "categories" array
        first_category = data["result"]["categories"]
[o]if data.get("result", {}).get("categories") else None

        # Write the first entry to a new JSON file
        new_file_path = os.path.join(folder_path, "new_" + file_name)
        with open(new_file_path, "w") as file:
            json.dump(first_category, file)


New data.

PS D:\Unstable Diffustion> .\exiftool.exe "D:\Unstable Diffustion\Images\Export\PhotoRealistic\PhotoRealistic-996.jpg.json"
ExifTool Version Number        : 12.54
File Name                      : PhotoRealistic-996.jpg.json
Directory                      : D:/Unstable Diffustion/Images/Export/PhotoRealistic
File Size                      : 54 bytes
File Modification Date/Time    : 2023:01:13 11:05:18-08:00
File Access Date/Time          : 2023:01:13 11:24:28-08:00
File Creation Date/Time        : 2023:01:13 11:05:18-08:00
File Permissions                : -rw-rw-rw-
File Type                      : JSON
File Type Extension            : json
MIME Type                      : application/json
Confidence                      : 91.11376953125
Name En                        : safe


inclusivetech

The output format changed, and now the command does not work.  I managed to fix it with a python script that removes the change from each json file.  It seems like an adjustment to the command would work.  I am just not sure how to do it.

Old Format
{
    "result": {
        "tags": [
            {
                "confidence": 53.9348640441895,
                "tag": {
                    "en": "clothing"
                }
            },
            {

New Format

{
    "Women_only_11322.jpg": {
        "result": {
            "tags": [
                {
                    "confidence": 69.5323867797852,
                    "tag": {
                        "en": "magazine"
                    }
                },
                {


The file name is now the top level of each json file.  And because it's unique for each file I am not sure how to let exiftool know how to find it.

#apply tags to images
./exiftool -r -d %s -tagsfromfile "%d/%F.json" "-subject+<ResultTagsTagEn" "-keywords+<ResultTagsTagEn"   -sep ", "  -ext "*" -overwrite_original -progress --ext json "PathToImages"


inclusivetech

PS D:\Unstable Diffustion> .\exiftool.exe .\Women_only_17112.jpg.json
ExifTool Version Number         : 12.54
File Name                       : Women_only_17112.jpg.json
Directory                       : .
File Size                       : 2.2 kB
File Modification Date/Time     : 2023:02:06 12:50:27-08:00
File Access Date/Time           : 2023:02:06 12:51:27-08:00
File Creation Date/Time         : 2023:02:06 12:51:18-08:00
File Permissions                : -rw-rw-rw-
File Type                       : JSON
File Type Extension             : json
MIME Type                       : application/json
Women Only 17112 Jpg Result Tags Confidence: 51.0314064025879, 50.9314994812012, 49.9793701171875, 49.958610534668, 47.0643577575684, 44.3553199768066, 43.501350402832, 42.8822021484375, 41.6058120727539, 37.2326431274414, 35.7153625488281
Women Only 17112 Jpg Result Tags Tag En: make, hair, model, fashion, attractive, sexy, face, portrait, coquette, pretty, adult
Women Only 17112 Jpg Status Text:
Women Only 17112 Jpg Status Type: success