Skip to content

Stash Plugin Guide

skier233 edited this page Jan 1, 2025 · 23 revisions

Prerequisites

  • Stash is installed with images or scenes registered with it.
  • Python is installed in the same environment as Stash (directly on the computer, Docker, virtualenv, etc).
  • The AI Server is up and running. See the AI Quickstart Guide.

Installation

  1. In Stash, go to Settings -> Plugins -> Available Plugins -> Community (stable).
  2. Search for AI Tagger at the top.
  3. Select AI Tagger and hit Install.
  4. Ensure the AI server is running.
  5. Navigate to Settings -> Tasks.
  6. Scroll down to the bottom to find Plugin Tasks.
  7. Select AI Tagger -> Tag Scenes.
  8. Run this task twice to install necessary dependencies and set up required tags in Stash for the plugin.
    • If you encounter any errors in the Stash logs during installation, navigate to the plugin directory <your-stash-directory>/plugins/community/ai_tagger and run pip install -r requirements.txt.

Docker Installation (For when running stash inside docker)

  1. In Stash, go to Settings -> Plugins -> Available Plugins -> Community (stable).
  2. Search for AI Tagger at the top.
  3. Select AI Tagger and hit Install.
  4. Launch a shell on your computer (outside docker)
  5. Create a new python virtual environment: python -m venv ./stash_venv. Save this path for later <stash-venv-path>
  6. Activate the virtual environment: source /root/.stash/venv/bin/activate You should see the (stash_venv) prefix in your shell
  7. Install the AI Tagger Dependencies: pip install -r <stashfolder>/plugins/community/ai_tagger/requirements.txt
  8. Open Stash -> Settings -> System
  9. Edit Python Executable Path: <stash-venv-path>/bin/python
  10. In Stash click Settings -> Plugins -> Reload Plugins

Using the Plugin

  1. Marking for AI Tagging:

    • To mark scenes or images for AI tagging, add the AI_TagMe tag to those scenes or images in Stash.
    • You can tag large batches, selecting thousands of scenes or images for AI processing.
  2. Running the AI Tagger:

    • Navigate to Settings -> Tasks -> AI Tagger.
    • Choose Tag Images to tag images with the AI_TagMe tag or Tag Scenes to tag scenes with the AI_TagMe tag.

After tagging, the scenes or images will be updated as follows:

  • Successfully tagged items will have the AI_Tagged tag and any other applied tags.
  • Items that encountered errors or were unreadable will have the AI_Errored tag.

Updating Previously Tagged Scenes

Scenes previously tagged by the AI server can be updated in Stash to generate different markers or scene tags with new settings without reprocessing the entire scene in the AI server.

To update a scene:

  1. Add the AI_TagMe tag to a scene that was already tagged and has the AI_Tagged tag.
  2. The existing markers and scene tags will be replaced with ones generated from the stored AI results using the new settings.

Exceptions:

  • If the active AI model on the server is a more accurate/newer version from the one used previously.
  • If the frame_interval in config.py (which defines how often frames in the scene should be processed by the AI) is lower than when the scene was originally tagged.

In these cases, the AI will reprocess the scene.

Customizing the Plugin (Optional)

To customize the plugin, navigate to the plugin directory located at <your-stash-directory>/plugins/community/ai_tagger. Inside this folder, you can customize the config.py:

config.py:

  • Contains FRAME_INTERVAL which is the interval, in seconds, that the AI will process frames from the video. The default is 2 seconds which means the AI will process a frame at every 2s interval from the video. Lowering this value to 1 or 0.5s will make markers have more accurate start and end times at the cost of longer AI processing. Raising this value will decrease the AI processing time which could be helpful for underpowered computers.
  • Contains the link to the AI server (if changed).
  • Contains path_mutation which allows mutation of paths when sent from the Stash plugin to the AI Server. If your stash server and ai server are on different computers or in Docker you may likely need this. This works by replacing any instances of the first path with the second path for each item in path_mutation.