Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions plugins/AITagger/ai_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def install(package):
except ModuleNotFoundError:
install('pydantic')
toRaise = True

try:
import cv2
except ModuleNotFoundError:
install('opencv-python')
toRaise = True

if toRaise:
raise Exception("Installed required packages, please retry the task.")
Expand All @@ -53,11 +59,6 @@ def install(package):
import ai_server
import utility
from datetime import datetime
try:
import cv2
except ModuleNotFoundError:
install('opencv-python')
toRaise = True
except:
log.error("Attempted to install required packages, please retry the task.")
log.error(f"Stack trace {traceback.format_exc()}")
Expand Down Expand Up @@ -238,7 +239,7 @@ async def __tag_images(images):
else:
tags_list = []
for _, tags in result.items():
stashtag_ids = media_handler.get_tag_ids(tags)
stashtag_ids = media_handler.get_tag_ids(tags, create=True)
stashtag_ids.append(media_handler.ai_tagged_tag_id)
tags_list.extend(stashtag_ids)
media_handler.add_tags_to_image(id, tags_list)
Expand Down Expand Up @@ -375,4 +376,4 @@ def increment_progress():
global increment
progress += increment
log.progress(progress)
asyncio.run(main())
asyncio.run(main())
2 changes: 1 addition & 1 deletion plugins/AITagger/ai_tagger.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: AI Tagger
description: Tag videos and Images with Locally hosted AI using Skier's Free and Patreon AI models
version: 2.0
version: 2.1
url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/AITagger
exec:
- python
Expand Down
Loading