Skip to content

Commit

Permalink
[AItagger] Fix MaxGaps issue (#318)
Browse files Browse the repository at this point in the history
* Fix mintags duration being lower than the frame interval

* cleanup debug message
  • Loading branch information
skier233 authored Jun 1, 2024
1 parent adade5e commit bdf1f04
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
12 changes: 9 additions & 3 deletions plugins/AITagger/ai_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Any

# ----------------- Setup -----------------
os.chdir(os.path.dirname(os.path.realpath(__file__)))

def install(package):
try:
Expand Down Expand Up @@ -93,6 +92,7 @@ async def run(json_input, output):
global updateme_tag_id
try:
log.debug(json_input["server_connection"])
os.chdir(json_input["server_connection"]["PluginDir"])
stash = StashInterface(json_input["server_connection"])
aierroed_tag_id = stash.find_tag(config.aierrored_tag_name, create=True)["id"]
tagme_tag_id = stash.find_tag(config.tagme_tag_name, create=True)["id"]
Expand Down Expand Up @@ -231,6 +231,8 @@ def process_server_video_result(server_result, sceneId, scenePath):
save_to_csv(csv_path, results)

# Step 1: Group results by tag
timespan = results[1]['frame_index'] - results[0]['frame_index']
log.debug(f"Server returned results every {timespan}s")
tag_timestamps = {}
for result in results:
for action in result['actions']:
Expand All @@ -244,10 +246,13 @@ def process_server_video_result(server_result, sceneId, scenePath):
start = timestamps[0]
total_duration = 0
for i in range(1, len(timestamps)):
if timestamps[i] - timestamps[i - 1] > max_gaps.get(tag, 0):
if timestamps[i] - timestamps[i - 1] > timespan + max_gaps.get(tag, 0):
# End of current marker, start of new one
duration = timestamps[i - 1] - start
if duration >= min_durations.get(tag, 0):

min_duration_temp = min_durations.get(tag, 0)
min_duration_temp = min_duration_temp if min_duration_temp > timespan else timespan
if duration >= min_duration_temp:
# The marker is long enough, add its duration
total_duration += duration

Expand All @@ -269,6 +274,7 @@ def process_server_video_result(server_result, sceneId, scenePath):
# stash.create_scene_marker({"scene_id": sceneId, "primary_tag_id":tagid_mappings[tag], "tag_ids": [tagid_mappings[tag]], "seconds": start, "title":tagname_mappings[tag]})
tag_durations[tag] = total_duration
scene_duration = results[-1]['frame_index']

# Step 3: Check if each tag meets the required duration

tags_to_add = [ai_tagged_tag_id]
Expand Down
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 Patreon AI models
version: 1.0
version: 1.1
url: https://github.com/stashapp/CommunityScripts/tree/main/plugins/AITagger
exec:
- python
Expand Down
72 changes: 36 additions & 36 deletions plugins/AITagger/tag_mappings.csv
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
ServerTag,StashTag,MinDuration,MaxGap,RequiredDuration
69,69_AI,5,1,20%
Anal Fucking,Anal Fucking_AI,5,1,30s
Ass Licking,Ass Licking_AI,5,1,30s
Ass Penetration,Ass Penetration_AI,5,1,30s
Ball Licking/Sucking,Ball Licking/Sucking_AI,2,1,20s
Blowjob,Blowjob_AI,5,1,30s
Cum on Person,Cum on Person_AI,3,1,15s
Cum Swapping,Cum Swapping_AI,2,1,15s
Cumshot,Cumshot_AI,1,1,10s
Deepthroat,Deepthroat_AI,1,1,30s
Double Penetration,Double Penetration_AI,5,1,30s
Fingering,Fingering_AI,5,1,30s
Fisting,Fisting_AI,3,1,30s
Footjob,Footjob_AI,3,1,30s
Gangbang,Gangbang_AI,5,1,30s
Gloryhole,Gloryhole_AI,5,1,30s
Grabbing Ass,Grabbing Ass_AI,5,1,30s
Grabbing Boobs,Grabbing Boobs_AI,5,1,30s
Grabbing Hair/Head,Grabbing Hair/Head_AI,5,1,30s
Handjob,Handjob_AI,5,1,30s
Kissing,Kissing_AI,5,1,30s
Licking Penis,Licking Penis_AI,2,1,30s
Masturbation,Masturbation_AI,5,1,30s
Pissing,Pissing_AI,2,1,30s
Pussy Licking (Clearly Visible),Pussy Licking (Clearly Visible)_AI,5,1,30s
Pussy Licking,Pussy Licking_AI,3,1,30s
Pussy Rubbing,Pussy Rubbing_AI,5,1,30s
Sucking Fingers,Sucking Fingers_AI,1,1,30s
Sucking Toy/Dildo,Sucking Toy/Dildo_AI,1,1,30s
Wet (Genitals),Wet (Genitals)_AI,3,1,30s
Titjob,Titjob_AI,5,1,30s
Tribbing/Scissoring,Tribbing/Scissoring_AI,3,1,30s
Undressing,Undressing_AI,3,1,30s
Vaginal Penetration,Vaginal Penetration_AI,5,1,30s
Vaginal Fucking,Vaginal Fucking_AI,5,1,30s
Vibrating,Vibrating_AI,5,1,30s
69,69_AI,5,2,20s
Anal Fucking,Anal Fucking_AI,5,2,20s
Ass Licking,Ass Licking_AI,5,2,20s
Ass Penetration,Ass Penetration_AI,5,2,20s
Ball Licking/Sucking,Ball Licking/Sucking_AI,2,2,20s
Blowjob,Blowjob_AI,5,2,20s
Cum on Person,Cum on Person_AI,3,2,15s
Cum Swapping,Cum Swapping_AI,2,2,15s
Cumshot,Cumshot_AI,1,2,10s
Deepthroat,Deepthroat_AI,1,2,20s
Double Penetration,Double Penetration_AI,5,2,20s
Fingering,Fingering_AI,5,2,20s
Fisting,Fisting_AI,3,2,20s
Footjob,Footjob_AI,3,2,20s
Gangbang,Gangbang_AI,5,2,20s
Gloryhole,Gloryhole_AI,5,2,20s
Grabbing Ass,Grabbing Ass_AI,5,2,20s
Grabbing Boobs,Grabbing Boobs_AI,5,2,20s
Grabbing Hair/Head,Grabbing Hair/Head_AI,5,2,20s
Handjob,Handjob_AI,5,2,20s
Kissing,Kissing_AI,5,2,20s
Licking Penis,Licking Penis_AI,2,2,20s
Masturbation,Masturbation_AI,5,2,20s
Pissing,Pissing_AI,2,2,20s
Pussy Licking (Clearly Visible),Pussy Licking (Clearly Visible)_AI,5,2,20s
Pussy Licking,Pussy Licking_AI,3,2,20s
Pussy Rubbing,Pussy Rubbing_AI,5,2,20s
Sucking Fingers,Sucking Fingers_AI,1,2,20s
Sucking Toy/Dildo,Sucking Toy/Dildo_AI,1,2,20s
Wet (Genitals),Wet (Genitals)_AI,3,2,20s
Titjob,Titjob_AI,5,2,20s
Tribbing/Scissoring,Tribbing/Scissoring_AI,3,2,20s
Undressing,Undressing_AI,3,2,20s
Vaginal Penetration,Vaginal Penetration_AI,5,2,20s
Vaginal Fucking,Vaginal Fucking_AI,5,2,20s
Vibrating,Vibrating_AI,5,2,20s

0 comments on commit bdf1f04

Please sign in to comment.