diff --git a/plugins/AITagger/ai_tagger.py b/plugins/AITagger/ai_tagger.py index fd54d40..8d06e60 100644 --- a/plugins/AITagger/ai_tagger.py +++ b/plugins/AITagger/ai_tagger.py @@ -200,14 +200,34 @@ async def __tag_scene(scene): log.error(f"Failed to load AI results from file: {e}") elif os.path.exists(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__vid_giddy__1.0.csv")): ai_video_result = AIVideoResult.from_csv_file(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__vid_giddy__1.0.csv"), scene_id=sceneId, phash=phash, duration=duration) - log.info(f"Loading AI results from CSV file for scene {scenePath}: {ai_video_result}") + log.info(f"Loading AI results from CSV file for scene {scenePath}") current_pipeline_video = await ai_server.get_current_video_pipeline() if ai_video_result.already_contains_model(current_pipeline_video): - log.info(f"Skipping running AI for scene {scenePath} as it has already been processed with the same pipeline version and configuration. Updating tags and markers instead.") - ai_video_result.to_json_file(ai_file_path) - ai_video_result.update_stash_tags() - ai_video_result.update_stash_markers() - return + log.info(f"Skipping running AI for scene {scenePath} as it has already been processed with the same pipeline version and configuration. Updating tags and markers instead.") + ai_video_result.to_json_file(ai_file_path) + ai_video_result.update_stash_tags() + ai_video_result.update_stash_markers() + return + elif os.path.exists(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__actiondetection__1.0.csv")): + ai_video_result = AIVideoResult.from_csv_file(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__actiondetection__1.0.csv"), scene_id=sceneId, phash=phash, duration=duration, version=1.0) + log.info(f"Loading AI results from CSV file for scene {scenePath}") + current_pipeline_video = await ai_server.get_current_video_pipeline() + if ai_video_result.already_contains_model(current_pipeline_video): + log.info(f"Skipping running AI for scene {scenePath} as it has already been processed with the same pipeline version and configuration. Updating tags and markers instead.") + ai_video_result.to_json_file(ai_file_path) + ai_video_result.update_stash_tags() + ai_video_result.update_stash_markers() + return + elif os.path.exists(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__actiondetection__2.0.csv")): + ai_video_result = AIVideoResult.from_csv_file(os.path.join(os.path.dirname(scenePath), os.path.splitext(os.path.basename(scenePath))[0] + f"__actiondetection__2.0.csv"), scene_id=sceneId, phash=phash, duration=duration, version=2.0) + log.info(f"Loading AI results from CSV file for scene {scenePath}") + current_pipeline_video = await ai_server.get_current_video_pipeline() + if ai_video_result.already_contains_model(current_pipeline_video): + log.info(f"Skipping running AI for scene {scenePath} as it has already been processed with the same pipeline version and configuration. Updating tags and markers instead.") + ai_video_result.to_json_file(ai_file_path) + ai_video_result.update_stash_tags() + ai_video_result.update_stash_markers() + return else: log.warning(f"Scene {scenePath} is already tagged but has no AI results file. Running AI again.") vr_video = media_handler.is_vr_scene(scene.get('tags')) diff --git a/plugins/AITagger/ai_video_result.py b/plugins/AITagger/ai_video_result.py index 2af228c..26e0d33 100644 --- a/plugins/AITagger/ai_video_result.py +++ b/plugins/AITagger/ai_video_result.py @@ -112,7 +112,7 @@ class AIVideoResult(BaseModel): last_time_frame.end = time_frame.end or time_frame.start else: merged_time_frames.append(deepcopy(time_frame)) - merged_time_frames = [tf for tf in merged_time_frames if (tf.end or tf.start) - tf.start + frame_interval >= min_duration] + merged_time_frames = [tf for tf in merged_time_frames if (tf.end - tf.start + frame_interval if tf.end else frame_interval) >= min_duration] media_handler.add_markers_to_video(self.video_metadata.video_id, tag_id, tag_name, merged_time_frames) def already_contains_model(self, model_config): @@ -171,7 +171,7 @@ class AIVideoResult(BaseModel): return cls.model_validate_json(f.read()) @classmethod - def from_csv_file(cls, csv_file, scene_id, phash, duration): + def from_csv_file(cls, csv_file, scene_id, phash, duration, version=1.0): server_results = [] frame_interval = None last_frame_index = None @@ -187,6 +187,6 @@ class AIVideoResult(BaseModel): server_results.append({"frame_index": frame_index, "actions": [(tag_name, 1.0)]}) last_frame_index = frame_index tags = cls.__mutate_server_result_tags(server_results, "actiondetection", frame_interval) - model_info = ModelInfo(version=1.0, ai_model_config=ModelConfig(frame_interval=frame_interval, threshold=0.3)) + model_info = ModelInfo(version=version, ai_model_config=ModelConfig(frame_interval=frame_interval, threshold=0.3)) video_metadata = VideoMetadata(video_id=scene_id, phash=phash, models={"actiondetection" : model_info}, duration=duration) return cls(video_metadata=video_metadata, tags=tags) \ No newline at end of file diff --git a/plugins/AITagger/tag_mappings.csv b/plugins/AITagger/tag_mappings.csv index b86e061..a984ba1 100644 --- a/plugins/AITagger/tag_mappings.csv +++ b/plugins/AITagger/tag_mappings.csv @@ -1,37 +1,37 @@ ServerTag,StashTag,MinMarkerDuration,MaxGap,RequiredDuration,TagThreshold -69,69_AI,5,2,20s,0.5 -Anal Fucking,Anal Fucking_AI,5,2,20s,0.5 -Ass Licking,Ass Licking_AI,5,2,20s,0.5 -Ass Penetration,Ass Penetration_AI,5,2,20s,0.5 -Ball Licking/Sucking,Ball Licking/Sucking_AI,2,2,20s,0.5 -Blowjob,Blowjob_AI,5,2,20s,0.5 -Cum on Person,Cum on Person_AI,3,2,15s,0.5 -Cum Swapping,Cum Swapping_AI,2,2,15s,0.5 -Cumshot,Cumshot_AI,1,2,10s,0.5 -Deepthroat,Deepthroat_AI,1,2,20s,0.5 -Double Penetration,Double Penetration_AI,5,2,20s,0.5 -Fingering,Fingering_AI,5,2,20s,0.5 -Fisting,Fisting_AI,3,2,20s,0.5 -Footjob,Footjob_AI,3,2,20s,0.5 -Gangbang,Gangbang_AI,5,2,20s,0.5 -Gloryhole,Gloryhole_AI,5,2,20s,0.5 -Grabbing Ass,Grabbing Ass_AI,5,2,20s,0.5 -Grabbing Boobs,Grabbing Boobs_AI,5,2,20s,0.5 -Grabbing Hair/Head,Grabbing Hair/Head_AI,5,2,20s,0.5 -Handjob,Handjob_AI,5,2,20s,0.5 -Kissing,Kissing_AI,5,2,20s,0.5 -Licking Penis,Licking Penis_AI,2,2,20s,0.5 -Masturbation,Masturbation_AI,5,2,20s,0.5 -Pissing,Pissing_AI,2,2,20s,0.5 -Pussy Licking (Clearly Visible),Pussy Licking (Clearly Visible)_AI,5,2,20s,0.5 -Pussy Licking,Pussy Licking_AI,3,2,20s,0.5 -Pussy Rubbing,Pussy Rubbing_AI,5,2,20s,0.5 -Sucking Fingers,Sucking Fingers_AI,1,2,20s,0.5 -Sucking Toy/Dildo,Sucking Toy/Dildo_AI,1,2,20s,0.5 -Wet (Genitals),Wet (Genitals)_AI,3,2,20s,0.5 -Titjob,Titjob_AI,5,2,20s,0.5 -Tribbing/Scissoring,Tribbing/Scissoring_AI,3,2,20s,0.5 -Undressing,Undressing_AI,3,2,20s,0.5 -Vaginal Penetration,Vaginal Penetration_AI,5,2,20s,0.5 -Vaginal Fucking,Vaginal Fucking_AI,5,2,20s,0.5 -Vibrating,Vibrating_AI,5,2,20s,0.5 +69,69_AI,15,6,20s,0.5 +Anal Fucking,Anal Fucking_AI,15,6,20s,0.5 +Ass Licking,Ass Licking_AI,15,6,20s,0.5 +Ass Penetration,Ass Penetration_AI,15,6,20s,0.5 +Ball Licking/Sucking,Ball Licking/Sucking_AI,5,4,20s,0.5 +Blowjob,Blowjob_AI,15,6,20s,0.5 +Cum on Person,Cum on Person_AI,5,4,15s,0.5 +Cum Swapping,Cum Swapping_AI,5,4,15s,0.5 +Cumshot,Cumshot_AI,4,4,10s,0.5 +Deepthroat,Deepthroat_AI,5,4,20s,0.5 +Double Penetration,Double Penetration_AI,10,4,20s,0.5 +Fingering,Fingering_AI,15,6,20s,0.5 +Fisting,Fisting_AI,15,6,20s,0.5 +Footjob,Footjob_AI,15,6,20s,0.5 +Gangbang,Gangbang_AI,15,6,20s,0.5 +Gloryhole,Gloryhole_AI,15,8,20s,0.5 +Grabbing Ass,Grabbing Ass_AI,10,8,20s,0.5 +Grabbing Boobs,Grabbing Boobs_AI,6,6,20s,0.5 +Grabbing Hair/Head,Grabbing Hair/Head_AI,6,6,20s,0.5 +Handjob,Handjob_AI,15,6,20s,0.5 +Kissing,Kissing_AI,10,4,20s,0.5 +Licking Penis,Licking Penis_AI,6,4,20s,0.5 +Masturbation,Masturbation_AI,15,10,20s,0.5 +Pissing,Pissing_AI,5,4,20s,0.5 +Pussy Licking (Clearly Visible),Pussy Licking (Clearly Visible)_AI,10,4,20s,0.5 +Pussy Licking,Pussy Licking_AI,15,6,20s,0.5 +Pussy Rubbing,Pussy Rubbing_AI,15,6,20s,0.5 +Sucking Fingers,Sucking Fingers_AI,5,4,20s,0.5 +Sucking Toy/Dildo,Sucking Toy/Dildo_AI,5,4,20s,0.5 +Wet (Genitals),Wet (Genitals)_AI,15,6,20s,0.5 +Titjob,Titjob_AI,10,4,20s,0.5 +Tribbing/Scissoring,Tribbing/Scissoring_AI,15,6,20s,0.5 +Undressing,Undressing_AI,15,6,20s,0.5 +Vaginal Penetration,Vaginal Penetration_AI,15,6,20s,0.5 +Vaginal Fucking,Vaginal Fucking_AI,15,6,20s,0.5 +Vibrating,Vibrating_AI,10,6,20s,0.5