Skip to content

Commit ae9a034

Browse files
Star Identifier plugin (#72)
Co-authored-by: DogmaDragon <[email protected]>
1 parent 4d6f9fd commit ae9a034

File tree

7 files changed

+811
-0
lines changed

7 files changed

+811
-0
lines changed

plugins/starIdentifier/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Star Identifier
2+
3+
https://github.com/axxeman23/star_identifier
4+
5+
## Intro
6+
7+
Star Identifier uses [facial recognition](https://github.com/ageitgey/face_recognition) to automatically identify who is in images or scene screenshots from the performers already in your [Stash](https://github.com/stashapp/stash) library.
8+
9+
## Requirements
10+
11+
### Python3
12+
__version: 3.10.x +__
13+
14+
#### Installing Python
15+
16+
1. Download Python [here](https://www.python.org/downloads/)
17+
2. Install & add to your PATH
18+
3. Configure Stash to use Python (if necessary. This can be set in the `System` tab of your `Settings` page)
19+
20+
### Libs & Dependencies
21+
22+
#### CMake
23+
24+
For Windows:
25+
26+
- You'll also need to install Microsoft Visual Studio 2015 (or newer) with C/C++ Compiler installed. [Link here](https://visualstudio.microsoft.com/downloads/)
27+
- Install and add CMake to your PATH. [Link](https://cmake.org/download/)
28+
- For more details, see [this issue](https://github.com/ageitgey/face_recognition/issues/175)
29+
30+
For Mac & Linux:
31+
`brew install cmake`
32+
33+
#### Python Libraries
34+
35+
1. numpy
36+
2. dlib
37+
3. face_recognition
38+
39+
`pip install numpy dlib face_recognition`
40+
41+
For more details, see the [Face Recognition installation instructions](https://github.com/ageitgey/face_recognition#installation).
42+
43+
### Plugin Files
44+
45+
You'll need the following in your `plugins` folder from this repo. Copy `star_identifier.yml` to the `plugins` folder, and the rest of the files to a folder called `py_plugins` inside the `plugins` folder. If you already have `log.py` in `py_plugins`, skip copying that one (it should be the same)
46+
47+
```
48+
star_identifier.yml
49+
py_plugins:
50+
| log.py
51+
| star_identifier_config.py
52+
| star_identifier_interface.py
53+
| star_identifier.py
54+
```
55+
56+
## Config
57+
58+
### Paths
59+
60+
Running the plugin will create a folder. By default, this will be created in your `plugins` folder, but you can change that in the config.
61+
62+
Face encodings will be saved to that new folder. The encodings file will be roughly 1MB per 1,000 performers.
63+
64+
### Stash Settings
65+
66+
Star Identifier uses a tag to find images or scenes you would like identified. By default, that tag is `star identifier`.
67+
68+
Since the recognition is based on a single performer image, that image needs to have a pretty clear front-facing view of the performer's face. If face_recognition fails to find a performer's face, Star Identifier will tag that performer with `star identifier performer error` by default.
69+
70+
### Star Identifier Settings
71+
72+
You can adjust the tolerance for identification here. `0.6` is default and typical, but I've found `0.5` to work well. Lower is more strict.
73+
74+
## Running
75+
76+
### Export Performers
77+
78+
This is the first step. Star Identifier loads each performer's image, encodes their facial features into a numpy array, and saves those arrays. The clearer the face of the performer, the better identification results will be. Performers whose faces are not recognized by face_recognition will be tagged for you to update as desired.
79+
80+
This only needs to be run once, or after new performers are added or have updated images.
81+
82+
### Identify Images
83+
84+
This loads all images in the stash database tagged with `star identifier` (by default), compares the recognized faces to the exported face database, and then adds all potential matches to those images as performers.
85+
86+
### Identify Scene Screenshots
87+
88+
This loads the screenshot for every scene in the stash database tagged with `star identifier` (by default), compares the recognized faces to the exported face database, and then adds all potential matches to those scenes as performers.
89+
90+
## Upcoming roadmap
91+
92+
See [issues](https://github.com/axxeman23/star_identifier/issues)

plugins/starIdentifier/log.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sys
2+
3+
4+
# Log messages sent from a plugin instance are transmitted via stderr and are
5+
# encoded with a prefix consisting of special character SOH, then the log
6+
# level (one of t, d, i, w, e, or p - corresponding to trace, debug, info,
7+
# warning, error and progress levels respectively), then special character
8+
# STX.
9+
#
10+
# The LogTrace, LogDebug, LogInfo, LogWarning, and LogError methods, and their equivalent
11+
# formatted methods are intended for use by plugin instances to transmit log
12+
# messages. The LogProgress method is also intended for sending progress data.
13+
#
14+
15+
def __prefix(level_char):
16+
start_level_char = b'\x01'
17+
end_level_char = b'\x02'
18+
19+
ret = start_level_char + level_char + end_level_char
20+
return ret.decode()
21+
22+
23+
def __log(level_char, s):
24+
if level_char == "":
25+
return
26+
27+
print(__prefix(level_char) + s + "\n", file=sys.stderr, flush=True)
28+
29+
30+
def LogTrace(s):
31+
__log(b't', s)
32+
33+
34+
def LogDebug(s):
35+
__log(b'd', s)
36+
37+
38+
def LogInfo(s):
39+
__log(b'i', s)
40+
41+
42+
def LogWarning(s):
43+
__log(b'w', s)
44+
45+
46+
def LogError(s):
47+
__log(b'e', s)
48+
49+
50+
def LogProgress(p):
51+
progress = min(max(0, p), 1)
52+
__log(b'p', str(progress))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
face_recognition
2+
numpy
3+
requests

0 commit comments

Comments
 (0)