Improve scene tagger prioritization (#4618)

This commit is contained in:
InfiniteStash 2024-02-27 22:29:49 +01:00 committed by GitHub
parent fcf249e5f6
commit 98c428ba4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 11 deletions

View file

@ -188,11 +188,20 @@ export const Tagger: React.FC<ITaggerProps> = ({ scenes, queue }) => {
const [nbPhashMatchSceneB, ratioPhashMatchSceneB] =
calculatePhashComparisonScore(stashScene, sceneB);
if (nbPhashMatchSceneA != nbPhashMatchSceneB) {
// If only one scene has matching phash, prefer that scene
if (
(nbPhashMatchSceneA != nbPhashMatchSceneB && nbPhashMatchSceneA === 0) ||
nbPhashMatchSceneB === 0
) {
return nbPhashMatchSceneB - nbPhashMatchSceneA;
}
// Same number of phash matches, check duration
// Prefer scene with highest ratio of phash matches
if (ratioPhashMatchSceneA !== ratioPhashMatchSceneB) {
return ratioPhashMatchSceneB - ratioPhashMatchSceneA;
}
// Same ratio of phash matches, check duration
const [
nbDurationMatchSceneA,
ratioDurationMatchSceneA,
@ -213,11 +222,6 @@ export const Tagger: React.FC<ITaggerProps> = ({ scenes, queue }) => {
return ratioDurationMatchSceneB - ratioDurationMatchSceneA;
}
// Damn this is close... Check phash ratio
if (ratioPhashMatchSceneA !== ratioPhashMatchSceneB) {
return ratioPhashMatchSceneB - ratioPhashMatchSceneA;
}
// fall back to duration difference - less is better
return minDurationDiffSceneA - minDurationDiffSceneB;
}

View file

@ -5,12 +5,18 @@ import { FormattedMessage, useIntl } from "react-intl";
import uniq from "lodash-es/uniq";
import { blobToBase64 } from "base64-blob";
import { distance } from "src/utils/hamming";
import { faCheckCircle } from "@fortawesome/free-regular-svg-icons";
import {
faPlus,
faTriangleExclamation,
faXmark,
} from "@fortawesome/free-solid-svg-icons";
import * as GQL from "src/core/generated-graphql";
import { HoverPopover } from "src/components/Shared/HoverPopover";
import { Icon } from "src/components/Shared/Icon";
import { LoadingIndicator } from "src/components/Shared/LoadingIndicator";
import { SuccessIcon } from "src/components/Shared/SuccessIcon";
import { LoadingIndicator } from "src/components/Shared/LoadingIndicator";
import { TagSelect } from "src/components/Shared/Select";
import { TruncatedText } from "src/components/Shared/TruncatedText";
import { OperationButton } from "src/components/Shared/OperationButton";
@ -22,10 +28,25 @@ import { SceneTaggerModalsState } from "./sceneTaggerModals";
import PerformerResult from "./PerformerResult";
import StudioResult from "./StudioResult";
import { useInitialState } from "src/hooks/state";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { getStashboxBase } from "src/utils/stashbox";
import { ExternalLink } from "src/components/Shared/ExternalLink";
const getDurationIcon = (matchPercentage: number) => {
if (matchPercentage > 65)
return (
<Icon className="SceneTaggerIcon text-success" icon={faCheckCircle} />
);
if (matchPercentage > 35)
return (
<Icon
className="SceneTaggerIcon text-warn"
icon={faTriangleExclamation}
/>
);
return <Icon className="SceneTaggerIcon text-danger" icon={faXmark} />;
};
const getDurationStatus = (
scene: IScrapedScene,
stashDuration: number | undefined | null
@ -52,10 +73,12 @@ const getDurationStatus = (
else if (scene.duration && Math.abs(scene.duration - stashDuration) < 5)
match = <FormattedMessage id="component_tagger.results.fp_matches" />;
const matchPercentage = (matchCount / durations.length) * 100;
if (match)
return (
<div className="font-weight-bold">
<SuccessIcon className="mr-2" />
{getDurationIcon(matchPercentage)}
{match}
</div>
);
@ -146,7 +169,7 @@ const getFingerprintStatus = (
<div>
{phashMatches.length > 0 && (
<div className="font-weight-bold">
<SuccessIcon className="mr-2" />
<SuccessIcon className="SceneTaggerIcon" />
<HoverPopover
placement="bottom"
content={phashList}

View file

@ -76,6 +76,12 @@
background-color: #137cbd;
}
}
.SceneTaggerIcon {
margin-left: 0.25em;
margin-right: 10px;
width: var(--fa-fw-width, 1.25em);
}
}
.selected-result {