Skip to content

Upgrading Stashai to ONNX endpoint ; Same HF Host#730

Open
Drewlius wants to merge 1 commit into
stashapp:mainfrom
Drewlius:main
Open

Upgrading Stashai to ONNX endpoint ; Same HF Host#730
Drewlius wants to merge 1 commit into
stashapp:mainfrom
Drewlius:main

Conversation

@Drewlius

Copy link
Copy Markdown

Details

Hosted by the original creator at the same HF Spaces URL This was tested and verified by hand with multiple different media formats across both Tags and Markers and is confirmed operational on my machine. Used OpenCode to help understand Gradio and how it handles API interactions as well as how that interacts with stash and base64 data URL. There is a built in retry logic loop as well as built in compatibility for older browsers. if it is not working on your end i would suggest checking the HF Spaces URL above and ensuring that it is fully online and operational before blaming the script.
Both the stashai.js and the stashai.yml must be deployed for the change to take effect and be functional. only deploying the stashai.js will result in errors and result in failure of the plugin function completely.

Post-Update

migrated from a Gradio 3 Space to a Gradio 5 Space, which meant completely rewriting how the plugin talks to the API.

After changing stashai.js you must hard refresh your browser (Ctrl + Shift + r). In the Stash App, reload plugins in plugins settings in the main Settings screen. Regular browser refresh won't pick up the changes.

Some-Context

The ONNX Space has a bigger, better model but runs on HF's free tier (2GB RAM). The 335MB model barely fits and it cold-starts, OOMs occasionally, and then HF auto-restarts it. The plugin needs retry logic to handle this.

The 335MB ONNX model takes ~30 seconds to load on HF's free tier. During that time, the Space might OOM and restart. The first request often fails, but the second or third works. This is solved by the retries with delays in the script.

AI USAGE

Opencode was used to help me understand the syntax of the API requests to the Stashai ONNX Model endpoint, the GRADIO 5 documentation was fed into it, HF API Request documentation for JS was fed in, the old stashai.js was fed in, and the contents of my IDE was fed in, this was done to query when I had questions regarding the documentation and helping to troubleshoot non 200 OK Responses from the HF API endpoint. JavaScript is also fairly new to me so it was useful and time saving for me to get help with particular JS Syntax and plain English translations of functions and definitions contained within the original .JS file. The code was all tested and verified to be functioning properly and returning both Tags and Markers and successfully attaching them to the video file and adding those Tags/Markers to the DB properly. There may be issues still present. I am not an expert at web development or Javasript and have spent most of my time in programming writing Python and bash scripts for Linux, Like i stated though the script is working and returning responses from the correct ONNX API endpoint. If you review and see something is wrong don't hesitate to point it out. I will spend the time to fix it to the best of my abilities.

Details
Hosted by the original creator at the same HF Spaces URL This was tested and verified by hand with multiple different media formats across both Tags and Markers and is confirmed operational on my machine. Used OpenCode to help understand Gradio and how it handles API interactions as well as how that interacts with stash and base64 data URL. There is a built in retry logic loop as well as built in compatibility for older browsers. if it is not working on your end i would suggest checking the HF Spaces URL above and ensuring that it is fully online and operational before blaming the script.

Both the stashai.js and the stashai.yml must be deployed for the change to take effect and be functional. only deploying the stashai.js will result in errors and result in failure of the plugin function completely.

Post-Update
migrated from a Gradio 3 Space to a Gradio 5 Space, which meant completely rewriting how the plugin talks to the API.

After changing stashai.js you must hard refresh your browser (Ctrl + Shift + r). In the Stash App, reload plugins in plugins settings in the main Settings screen. Regular browser refresh won't pick up the changes.

Some-Context
The ONNX Space has a bigger, better model but runs on HF's free tier (2GB RAM). The 335MB model barely fits and it cold-starts, OOMs occasionally, and then HF auto-restarts it. The plugin needs retry logic to handle this.

The 335MB ONNX model takes ~30 seconds to load on HF's free tier. During that time, the Space might OOM and restart. The first request often fails, but the second or third works. This is solved by the retries with delays in the script.
@Drewlius

Copy link
Copy Markdown
Author

Apologies about the original pull requests to the wrong branch of the project.

@DogmaDragon DogmaDragon added the type:plugin Plugins label Jun 19, 2026
name: Stash AI
# requires: CommunityScriptsUILibrary
description: Add Tags or Markers to a video using AI
version: 1.0.2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to bump the version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants