From b6e5d1f3baca2ef9c321cf4548a7f58786f997f3 Mon Sep 17 00:00:00 2001 From: skier233 Date: Wed, 3 Jul 2024 18:15:36 -0400 Subject: [PATCH 1/6] add path mutation (and by extension docker) support --- plugins/AITagger/ai_tagger.py | 11 +++++++++++ plugins/AITagger/config.py | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/AITagger/ai_tagger.py b/plugins/AITagger/ai_tagger.py index 8d06e60..e8d966b 100644 --- a/plugins/AITagger/ai_tagger.py +++ b/plugins/AITagger/ai_tagger.py @@ -129,6 +129,13 @@ async def tag_scenes(): async def __tag_images(images): async with semaphore: imagePaths, imageIds, temp_files = media_handler.get_image_paths_and_ids(images) + mutated_image_paths = [] + for path in imagePaths: + mutated_path = path + for key, value in config.path_mutation.items(): + mutated_path = mutated_path.replace(key, value) + mutated_image_paths.append(mutated_path) + imagePaths = mutated_image_paths try: server_result = await ai_server.process_images_async(imagePaths) if server_result is None: @@ -175,6 +182,10 @@ async def __tag_images(images): async def __tag_scene(scene): async with semaphore: scenePath = scene['files'][0]['path'] + mutated_path = scenePath + for key, value in config.path_mutation.items(): + mutated_path = mutated_path.replace(key, value) + scenePath = mutated_path sceneId = scene['id'] log.debug("files result:" + str(scene['files'][0])) phash = scene['files'][0].get('fingerprint', None) diff --git a/plugins/AITagger/config.py b/plugins/AITagger/config.py index 1cd4d1c..3f504e4 100644 --- a/plugins/AITagger/config.py +++ b/plugins/AITagger/config.py @@ -13,4 +13,8 @@ ai_base_tag_name = "AI" tagme_tag_name = "AI_TagMe" updateme_tag_name = "AI_UpdateMe" aitagged_tag_name = "AI_Tagged" -aierrored_tag_name = "AI_Errored" \ No newline at end of file +aierrored_tag_name = "AI_Errored" + +# Example for mutating paths +# path_mutation = {"E:": "F:", "G:": "D:"} +path_mutation = {} From 5b353e8aaeb49e4b1d4dd926664463b42b9c80a9 Mon Sep 17 00:00:00 2001 From: skier233 Date: Wed, 3 Jul 2024 18:17:59 -0400 Subject: [PATCH 2/6] update version --- plugins/AITagger/ai_tagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/AITagger/ai_tagger.yml b/plugins/AITagger/ai_tagger.yml index d422660..84bc850 100644 --- a/plugins/AITagger/ai_tagger.yml +++ b/plugins/AITagger/ai_tagger.yml @@ -1,6 +1,6 @@ name: AI Tagger description: Tag videos and Images with Locally hosted AI using Skier's Patreon AI models -version: 1.3 +version: 1.4 url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/AITagger exec: - python From ca49dd14293ad1372c3dbf541c683a2177e2239a Mon Sep 17 00:00:00 2001 From: skier233 Date: Tue, 9 Jul 2024 10:07:57 -0400 Subject: [PATCH 3/6] fix mutating path bug with json file path --- plugins/AITagger/ai_tagger.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/AITagger/ai_tagger.py b/plugins/AITagger/ai_tagger.py index e8d966b..45d971f 100644 --- a/plugins/AITagger/ai_tagger.py +++ b/plugins/AITagger/ai_tagger.py @@ -185,7 +185,6 @@ async def __tag_scene(scene): mutated_path = scenePath for key, value in config.path_mutation.items(): mutated_path = mutated_path.replace(key, value) - scenePath = mutated_path sceneId = scene['id'] log.debug("files result:" + str(scene['files'][0])) phash = scene['files'][0].get('fingerprint', None) @@ -244,7 +243,7 @@ async def __tag_scene(scene): vr_video = media_handler.is_vr_scene(scene.get('tags')) if vr_video: log.info(f"Processing VR video {scenePath}") - server_result = await ai_server.process_video_async(scenePath, vr_video) + server_result = await ai_server.process_video_async(mutated_path, vr_video) if server_result is None: log.error("Server returned no results") media_handler.add_error_scene(sceneId) From 5b209a3711039ec7bc3d6d43ef5b563e879903ba Mon Sep 17 00:00:00 2001 From: skier233 Date: Tue, 9 Jul 2024 10:09:36 -0400 Subject: [PATCH 4/6] bump version --- plugins/AITagger/ai_tagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/AITagger/ai_tagger.yml b/plugins/AITagger/ai_tagger.yml index 84bc850..d2c37e7 100644 --- a/plugins/AITagger/ai_tagger.yml +++ b/plugins/AITagger/ai_tagger.yml @@ -1,6 +1,6 @@ name: AI Tagger description: Tag videos and Images with Locally hosted AI using Skier's Patreon AI models -version: 1.4 +version: 1.5 url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/AITagger exec: - python From 9021f7b25d5eb628c151fb5e0d5cb042c883b3d0 Mon Sep 17 00:00:00 2001 From: skier233 Date: Thu, 11 Jul 2024 12:14:00 -0400 Subject: [PATCH 5/6] improve error message clarity for when no scenes are found --- plugins/AITagger/ai_tagger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/AITagger/ai_tagger.py b/plugins/AITagger/ai_tagger.py index 45d971f..918e0ce 100644 --- a/plugins/AITagger/ai_tagger.py +++ b/plugins/AITagger/ai_tagger.py @@ -111,7 +111,7 @@ async def tag_images(): tasks = [__tag_images(batch) for batch in image_batches] await asyncio.gather(*tasks) else: - log.info("No images to tag") + log.info("No images to tag. Have you tagged any images with the AI_TagMe tag to get processed?") async def tag_scenes(): @@ -122,7 +122,7 @@ async def tag_scenes(): tasks = [__tag_scene(scene) for scene in scenes] await asyncio.gather(*tasks) else: - log.info("No scenes to tag") + log.info("No scenes to tag. Have you tagged any scenes with the AI_TagMe tag to get processed?") # ----------------- Image Processing ----------------- From a3f10ea1fa7379bb4c236e89170926a830b7c7ae Mon Sep 17 00:00:00 2001 From: skier233 Date: Fri, 12 Jul 2024 08:39:30 -0400 Subject: [PATCH 6/6] fix incorrect merge conflict resolution --- plugins/AITagger/ai_tagger.py | 3 +++ plugins/AITagger/ai_tagger.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/AITagger/ai_tagger.py b/plugins/AITagger/ai_tagger.py index 0b097c4..918e0ce 100644 --- a/plugins/AITagger/ai_tagger.py +++ b/plugins/AITagger/ai_tagger.py @@ -182,6 +182,9 @@ async def __tag_images(images): async def __tag_scene(scene): async with semaphore: scenePath = scene['files'][0]['path'] + mutated_path = scenePath + for key, value in config.path_mutation.items(): + mutated_path = mutated_path.replace(key, value) sceneId = scene['id'] log.debug("files result:" + str(scene['files'][0])) phash = scene['files'][0].get('fingerprint', None) diff --git a/plugins/AITagger/ai_tagger.yml b/plugins/AITagger/ai_tagger.yml index d2c37e7..34166da 100644 --- a/plugins/AITagger/ai_tagger.yml +++ b/plugins/AITagger/ai_tagger.yml @@ -1,6 +1,6 @@ name: AI Tagger description: Tag videos and Images with Locally hosted AI using Skier's Patreon AI models -version: 1.5 +version: 1.6 url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/AITagger exec: - python