mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-27 22:29:02 +03:00
Compare commits
7
Commits
dev
...
cac2adde31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cac2adde31 | ||
|
|
6baf43ddca | ||
|
|
cbf78e2070 | ||
|
|
72896f4631 | ||
|
|
cb9dd09929 | ||
|
|
8aa260c5cb | ||
|
|
5064a817c2 |
@@ -35,6 +35,10 @@ except ModuleNotFoundError:
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
MAX_CLASSIFICATION_VERIFICATION_ATTEMPTS = 6
|
||||||
|
MAX_CLASSIFICATION_ATTEMPTS = 12
|
||||||
|
|
||||||
|
|
||||||
class CustomStateClassificationProcessor(RealTimeProcessorApi):
|
class CustomStateClassificationProcessor(RealTimeProcessorApi):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -264,6 +268,26 @@ class CustomObjectClassificationProcessor(RealTimeProcessorApi):
|
|||||||
if obj_data["label"] not in self.model_config.object_config.objects:
|
if obj_data["label"] not in self.model_config.object_config.objects:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if (
|
||||||
|
obj_data["id"] in self.detected_objects
|
||||||
|
and len(self.detected_objects[obj_data["id"]])
|
||||||
|
>= MAX_CLASSIFICATION_VERIFICATION_ATTEMPTS
|
||||||
|
):
|
||||||
|
# if we are at max attempts after rec and we have a rec
|
||||||
|
if obj_data.get("sub_label"):
|
||||||
|
logger.debug(
|
||||||
|
"Not processing due to hitting max attempts after true recognition."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# if we don't have a rec and are at max attempts
|
||||||
|
if (
|
||||||
|
len(self.detected_objects[obj_data["id"]])
|
||||||
|
>= MAX_CLASSIFICATION_ATTEMPTS
|
||||||
|
):
|
||||||
|
logger.debug("Not processing due to hitting max rec attempts.")
|
||||||
|
return
|
||||||
|
|
||||||
now = datetime.datetime.now().timestamp()
|
now = datetime.datetime.now().timestamp()
|
||||||
x, y, x2, y2 = calculate_region(
|
x, y, x2, y2 = calculate_region(
|
||||||
frame.shape,
|
frame.shape,
|
||||||
|
|||||||
@@ -41,8 +41,8 @@
|
|||||||
"invalidName": "Invalid name. Names can only include letters, numbers, spaces, apostrophes, underscores, and hyphens."
|
"invalidName": "Invalid name. Names can only include letters, numbers, spaces, apostrophes, underscores, and hyphens."
|
||||||
},
|
},
|
||||||
"train": {
|
"train": {
|
||||||
"title": "Train",
|
"title": "Recent Classifications",
|
||||||
"aria": "Select Train"
|
"aria": "Select Recent Classifications"
|
||||||
},
|
},
|
||||||
"categories": "Classes",
|
"categories": "Classes",
|
||||||
"createCategory": {
|
"createCategory": {
|
||||||
|
|||||||
@@ -72,59 +72,62 @@ export function ClassificationCard({
|
|||||||
}, [showArea, imageLoaded]);
|
}, [showArea, imageLoaded]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
<div
|
className={cn(
|
||||||
|
"relative flex size-48 cursor-pointer flex-col overflow-hidden rounded-lg outline outline-[3px]",
|
||||||
|
selected
|
||||||
|
? "shadow-selected outline-selected"
|
||||||
|
: "outline-transparent duration-500",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
ref={imgRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative flex cursor-pointer flex-col rounded-lg outline outline-[3px]",
|
"absolute bottom-0 left-0 right-0 top-0 size-full",
|
||||||
className,
|
imgClassName,
|
||||||
selected
|
isMobile && "w-full",
|
||||||
? "shadow-selected outline-selected"
|
|
||||||
: "outline-transparent duration-500",
|
|
||||||
)}
|
)}
|
||||||
>
|
onLoad={() => setImageLoaded(true)}
|
||||||
<div className="relative w-full select-none overflow-hidden rounded-lg">
|
src={`${baseUrl}${data.filepath}`}
|
||||||
<img
|
onClick={(e) => {
|
||||||
ref={imgRef}
|
e.stopPropagation();
|
||||||
onLoad={() => setImageLoaded(true)}
|
onClick(data, e.metaKey || e.ctrlKey);
|
||||||
className={cn("size-44", imgClassName, isMobile && "w-full")}
|
}}
|
||||||
src={`${baseUrl}${data.filepath}`}
|
/>
|
||||||
onClick={(e) => {
|
{false && imageArea != undefined && (
|
||||||
e.stopPropagation();
|
<div className="absolute bottom-1 right-1 z-10 rounded-lg bg-black/50 px-2 py-1 text-xs text-white">
|
||||||
onClick(data, e.metaKey || e.ctrlKey);
|
{t("information.pixels", { ns: "common", area: imageArea })}
|
||||||
}}
|
</div>
|
||||||
/>
|
)}
|
||||||
{imageArea != undefined && (
|
<div className="absolute bottom-0 left-0 right-0 h-[50%] bg-gradient-to-t from-black/60 to-transparent" />
|
||||||
<div className="absolute bottom-1 right-1 z-10 rounded-lg bg-black/50 px-2 py-1 text-xs text-white">
|
<div className="absolute bottom-0 flex w-full select-none flex-row items-center justify-between gap-2 p-2">
|
||||||
{t("information.pixels", { ns: "common", area: imageArea })}
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col items-start text-white",
|
||||||
|
data.score ? "text-xs" : "text-sm",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="smart-capitalize">
|
||||||
|
{data.name == "unknown" ? t("details.unknown") : data.name}
|
||||||
|
</div>
|
||||||
|
{data.score && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"",
|
||||||
|
scoreStatus == "match" && "text-success",
|
||||||
|
scoreStatus == "potential" && "text-orange-400",
|
||||||
|
scoreStatus == "unknown" && "text-danger",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{Math.round(data.score * 100)}%
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="select-none p-2">
|
<div className="flex flex-row items-start justify-end gap-5 md:gap-2">
|
||||||
<div className="flex w-full flex-row items-center justify-between gap-2">
|
{children}
|
||||||
<div className="flex flex-col items-start text-xs text-primary-variant">
|
|
||||||
<div className="smart-capitalize">
|
|
||||||
{data.name == "unknown" ? t("details.unknown") : data.name}
|
|
||||||
</div>
|
|
||||||
{data.score && (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"",
|
|
||||||
scoreStatus == "match" && "text-success",
|
|
||||||
scoreStatus == "potential" && "text-orange-400",
|
|
||||||
scoreStatus == "unknown" && "text-danger",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{Math.round(data.score * 100)}%
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row items-start justify-end gap-5 md:gap-4">
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,14 @@ import {
|
|||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from "@/components/ui/tooltip";
|
||||||
import { isDesktop, isMobile } from "react-device-detect";
|
import { isDesktop, isMobile } from "react-device-detect";
|
||||||
import { LuPlus } from "react-icons/lu";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import React, { ReactNode, useCallback, useMemo, useState } from "react";
|
import React, { ReactNode, useCallback, useMemo, useState } from "react";
|
||||||
import TextEntryDialog from "./dialog/TextEntryDialog";
|
import TextEntryDialog from "./dialog/TextEntryDialog";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { MdCategory } from "react-icons/md";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { Separator } from "../ui/separator";
|
||||||
|
|
||||||
type ClassificationSelectionDialogProps = {
|
type ClassificationSelectionDialogProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -97,7 +96,7 @@ export default function ClassificationSelectionDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className ?? ""}>
|
<div className={className ?? "flex"}>
|
||||||
{newClass && (
|
{newClass && (
|
||||||
<TextEntryDialog
|
<TextEntryDialog
|
||||||
open={true}
|
open={true}
|
||||||
@@ -128,23 +127,22 @@ export default function ClassificationSelectionDialog({
|
|||||||
isMobile && "gap-2 pb-4",
|
isMobile && "gap-2 pb-4",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<SelectorItem
|
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
|
||||||
onClick={() => setNewClass(true)}
|
|
||||||
>
|
|
||||||
<LuPlus />
|
|
||||||
{t("createCategory.new")}
|
|
||||||
</SelectorItem>
|
|
||||||
{classes.sort().map((category) => (
|
{classes.sort().map((category) => (
|
||||||
<SelectorItem
|
<SelectorItem
|
||||||
key={category}
|
key={category}
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
onClick={() => onCategorizeImage(category)}
|
onClick={() => onCategorizeImage(category)}
|
||||||
>
|
>
|
||||||
<MdCategory />
|
|
||||||
{category.replaceAll("_", " ")}
|
{category.replaceAll("_", " ")}
|
||||||
</SelectorItem>
|
</SelectorItem>
|
||||||
))}
|
))}
|
||||||
|
<Separator />
|
||||||
|
<SelectorItem
|
||||||
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
|
onClick={() => setNewClass(true)}
|
||||||
|
>
|
||||||
|
{t("createCategory.new")}
|
||||||
|
</SelectorItem>
|
||||||
</div>
|
</div>
|
||||||
</SelectorContent>
|
</SelectorContent>
|
||||||
</Selector>
|
</Selector>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default function FaceSelectionDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className ?? ""}>
|
<div className={className ?? "flex"}>
|
||||||
{newFace && (
|
{newFace && (
|
||||||
<TextEntryDialog
|
<TextEntryDialog
|
||||||
open={true}
|
open={true}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export default function TrainFilterDialog({
|
|||||||
moreFiltersSelected ? "text-white" : "text-secondary-foreground",
|
moreFiltersSelected ? "text-white" : "text-secondary-foreground",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{isDesktop && t("more")}
|
{isDesktop && t("filter")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
const content = (
|
const content = (
|
||||||
@@ -122,7 +122,7 @@ export default function TrainFilterDialog({
|
|||||||
return (
|
return (
|
||||||
<PlatformAwareSheet
|
<PlatformAwareSheet
|
||||||
trigger={trigger}
|
trigger={trigger}
|
||||||
title={t("more")}
|
title={t("filter")}
|
||||||
content={content}
|
content={content}
|
||||||
contentClassName={cn(
|
contentClassName={cn(
|
||||||
"w-auto lg:min-w-[275px] scrollbar-container h-full overflow-auto px-4",
|
"w-auto lg:min-w-[275px] scrollbar-container h-full overflow-auto px-4",
|
||||||
|
|||||||
@@ -881,12 +881,12 @@ function FaceAttemptGroup({
|
|||||||
faceNames={faceNames}
|
faceNames={faceNames}
|
||||||
onTrainAttempt={(name) => onTrainAttempt(data, name)}
|
onTrainAttempt={(name) => onTrainAttempt(data, name)}
|
||||||
>
|
>
|
||||||
<AddFaceIcon className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
<AddFaceIcon className="size-7 cursor-pointer p-1 text-gray-200 hover:rounded-full hover:bg-primary-foreground" />
|
||||||
</FaceSelectionDialog>
|
</FaceSelectionDialog>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<LuRefreshCw
|
<LuRefreshCw
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
className="size-7 cursor-pointer p-1 text-gray-200 hover:rounded-full hover:bg-primary-foreground"
|
||||||
onClick={() => onReprocess(data)}
|
onClick={() => onReprocess(data)}
|
||||||
/>
|
/>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
@@ -954,7 +954,7 @@ function FaceGrid({
|
|||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<LuTrash2
|
<LuTrash2
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
className="size-5 cursor-pointer text-gray-200 hover:text-danger"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onDelete(pageToggle, [image]);
|
onDelete(pageToggle, [image]);
|
||||||
|
|||||||
@@ -1,31 +1,56 @@
|
|||||||
import { baseUrl } from "@/api/baseUrl";
|
import { baseUrl } from "@/api/baseUrl";
|
||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||||
|
import useOptimisticState from "@/hooks/use-optimistic-state";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
CustomClassificationModelConfig,
|
CustomClassificationModelConfig,
|
||||||
FrigateConfig,
|
FrigateConfig,
|
||||||
} from "@/types/frigateConfig";
|
} from "@/types/frigateConfig";
|
||||||
import { useMemo } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { isMobile } from "react-device-detect";
|
import { isMobile } from "react-device-detect";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { FaFolderPlus } from "react-icons/fa";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
|
const allModelTypes = ["objects", "states"] as const;
|
||||||
|
type ModelType = (typeof allModelTypes)[number];
|
||||||
|
|
||||||
type ModelSelectionViewProps = {
|
type ModelSelectionViewProps = {
|
||||||
onClick: (model: CustomClassificationModelConfig) => void;
|
onClick: (model: CustomClassificationModelConfig) => void;
|
||||||
};
|
};
|
||||||
export default function ModelSelectionView({
|
export default function ModelSelectionView({
|
||||||
onClick,
|
onClick,
|
||||||
}: ModelSelectionViewProps) {
|
}: ModelSelectionViewProps) {
|
||||||
|
const { t } = useTranslation(["views/classificationModel"]);
|
||||||
|
const [page, setPage] = useState<ModelType>("objects");
|
||||||
|
const [pageToggle, setPageToggle] = useOptimisticState(page, setPage, 100);
|
||||||
const { data: config } = useSWR<FrigateConfig>("config", {
|
const { data: config } = useSWR<FrigateConfig>("config", {
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// data
|
||||||
|
|
||||||
const classificationConfigs = useMemo(() => {
|
const classificationConfigs = useMemo(() => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.values(config.classification.custom);
|
const allModels = Object.values(config.classification.custom);
|
||||||
}, [config]);
|
|
||||||
|
return allModels.filter((model) => {
|
||||||
|
if (pageToggle == "objects" && model.object_config != undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageToggle == "states" && model.state_config != undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}, [config, pageToggle]);
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
@@ -36,14 +61,53 @@ export default function ModelSelectionView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex size-full gap-2 p-2">
|
<div className="flex size-full flex-col p-2">
|
||||||
{classificationConfigs.map((config) => (
|
<div className="flex h-12 w-full items-center justify-between">
|
||||||
<ModelCard
|
<div className="flex flex-row items-center">
|
||||||
key={config.name}
|
<ToggleGroup
|
||||||
config={config}
|
className="*:rounded-md *:px-3 *:py-4"
|
||||||
onClick={() => onClick(config)}
|
type="single"
|
||||||
/>
|
size="sm"
|
||||||
))}
|
value={pageToggle}
|
||||||
|
onValueChange={(value: ModelType) => {
|
||||||
|
if (value) {
|
||||||
|
// Restrict viewer navigation
|
||||||
|
setPageToggle(value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{allModelTypes.map((item) => (
|
||||||
|
<ToggleGroupItem
|
||||||
|
key={item}
|
||||||
|
className={`flex scroll-mx-10 items-center justify-between gap-2 ${pageToggle == item ? "" : "*:text-muted-foreground"}`}
|
||||||
|
value={item}
|
||||||
|
data-nav-item={item}
|
||||||
|
aria-label={t("selectItem", {
|
||||||
|
ns: "common",
|
||||||
|
item: t("menu." + item),
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div className="smart-capitalize">{t("menu." + item)}</div>
|
||||||
|
</ToggleGroupItem>
|
||||||
|
))}
|
||||||
|
</ToggleGroup>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-row items-center">
|
||||||
|
<Button className="flex flex-row items-center gap-2" variant="select">
|
||||||
|
<FaFolderPlus />
|
||||||
|
Add Classification
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex size-full gap-2 p-2">
|
||||||
|
{classificationConfigs.map((config) => (
|
||||||
|
<ModelCard
|
||||||
|
key={config.name}
|
||||||
|
config={config}
|
||||||
|
onClick={() => onClick(config)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -57,46 +121,37 @@ function ModelCard({ config, onClick }: ModelCardProps) {
|
|||||||
[id: string]: string[];
|
[id: string]: string[];
|
||||||
}>(`classification/${config.name}/dataset`, { revalidateOnFocus: false });
|
}>(`classification/${config.name}/dataset`, { revalidateOnFocus: false });
|
||||||
|
|
||||||
const coverImages = useMemo(() => {
|
const coverImage = useMemo(() => {
|
||||||
if (!dataset) {
|
if (!dataset) {
|
||||||
return {};
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageMap: { [key: string]: string } = {};
|
const keys = Object.keys(dataset).filter((key) => key != "none");
|
||||||
|
const selectedKey = keys[0];
|
||||||
|
|
||||||
for (const [key, imageList] of Object.entries(dataset)) {
|
return {
|
||||||
if (imageList.length > 0) {
|
name: selectedKey,
|
||||||
imageMap[key] = imageList[0];
|
img: dataset[selectedKey][0],
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return imageMap;
|
|
||||||
}, [dataset]);
|
}, [dataset]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={config.name}
|
key={config.name}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-60 cursor-pointer flex-col items-center gap-2 rounded-lg bg-card p-2 outline outline-[3px]",
|
"relative size-60 cursor-pointer overflow-hidden rounded-lg",
|
||||||
"outline-transparent duration-500",
|
"outline-transparent duration-500",
|
||||||
isMobile && "w-full",
|
isMobile && "w-full",
|
||||||
)}
|
)}
|
||||||
onClick={() => onClick()}
|
onClick={() => onClick()}
|
||||||
>
|
>
|
||||||
<div
|
<img
|
||||||
className={cn("grid size-48 grid-cols-2 gap-2", isMobile && "w-full")}
|
className={cn("size-full", isMobile && "w-full")}
|
||||||
>
|
src={`${baseUrl}clips/${config.name}/dataset/${coverImage?.name}/${coverImage?.img}`}
|
||||||
{Object.entries(coverImages).map(([key, image]) => (
|
/>
|
||||||
<img
|
<div className="absolute bottom-0 h-[50%] w-full bg-gradient-to-t from-black/60 to-transparent" />
|
||||||
key={key}
|
<div className="absolute bottom-2 left-3 text-lg smart-capitalize">
|
||||||
className=""
|
{config.name}
|
||||||
src={`${baseUrl}clips/${config.name}/dataset/${key}/${image}`}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="smart-capitalize">
|
|
||||||
{config.name} ({config.state_config != null ? "State" : "Object"}{" "}
|
|
||||||
Classification)
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ import { ModelState } from "@/types/ws";
|
|||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { IoMdArrowRoundBack } from "react-icons/io";
|
import { IoMdArrowRoundBack } from "react-icons/io";
|
||||||
import { MdAutoFixHigh } from "react-icons/md";
|
|
||||||
import TrainFilterDialog from "@/components/overlay/dialog/TrainFilterDialog";
|
import TrainFilterDialog from "@/components/overlay/dialog/TrainFilterDialog";
|
||||||
import useApiFilter from "@/hooks/use-api-filter";
|
import useApiFilter from "@/hooks/use-api-filter";
|
||||||
import { ClassificationItemData, TrainFilter } from "@/types/classification";
|
import { ClassificationItemData, TrainFilter } from "@/types/classification";
|
||||||
@@ -69,6 +68,7 @@ import SearchDetailDialog, {
|
|||||||
SearchTab,
|
SearchTab,
|
||||||
} from "@/components/overlay/detail/SearchDetailDialog";
|
} from "@/components/overlay/detail/SearchDetailDialog";
|
||||||
import { SearchResult } from "@/types/search";
|
import { SearchResult } from "@/types/search";
|
||||||
|
import { HiSparkles } from "react-icons/hi";
|
||||||
|
|
||||||
type ModelTrainingViewProps = {
|
type ModelTrainingViewProps = {
|
||||||
model: CustomClassificationModelConfig;
|
model: CustomClassificationModelConfig;
|
||||||
@@ -378,12 +378,13 @@ export default function ModelTrainingView({ model }: ModelTrainingViewProps) {
|
|||||||
<Button
|
<Button
|
||||||
className="flex justify-center gap-2"
|
className="flex justify-center gap-2"
|
||||||
onClick={trainModel}
|
onClick={trainModel}
|
||||||
|
variant="select"
|
||||||
disabled={modelState != "complete"}
|
disabled={modelState != "complete"}
|
||||||
>
|
>
|
||||||
{modelState == "training" ? (
|
{modelState == "training" ? (
|
||||||
<ActivityIndicator size={20} />
|
<ActivityIndicator size={20} />
|
||||||
) : (
|
) : (
|
||||||
<MdAutoFixHigh className="text-secondary-foreground" />
|
<HiSparkles className="text-white" />
|
||||||
)}
|
)}
|
||||||
{isDesktop && t("button.trainModel")}
|
{isDesktop && t("button.trainModel")}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -650,7 +651,7 @@ function DatasetGrid({
|
|||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<LuTrash2
|
<LuTrash2
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
className="size-5 cursor-pointer text-primary-variant hover:text-danger"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onDelete([image]);
|
onDelete([image]);
|
||||||
@@ -757,7 +758,6 @@ function TrainGrid({
|
|||||||
selectedImages={selectedImages}
|
selectedImages={selectedImages}
|
||||||
onClickImages={onClickImages}
|
onClickImages={onClickImages}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
onDelete={onDelete}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -780,10 +780,7 @@ function StateTrainGrid({
|
|||||||
selectedImages,
|
selectedImages,
|
||||||
onClickImages,
|
onClickImages,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
onDelete,
|
|
||||||
}: StateTrainGridProps) {
|
}: StateTrainGridProps) {
|
||||||
const { t } = useTranslation(["views/classificationModel"]);
|
|
||||||
|
|
||||||
const threshold = useMemo(() => {
|
const threshold = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
recognition: model.threshold,
|
recognition: model.threshold,
|
||||||
@@ -817,22 +814,8 @@ function StateTrainGrid({
|
|||||||
image={data.filename}
|
image={data.filename}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
>
|
>
|
||||||
<TbCategoryPlus className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
<TbCategoryPlus className="size-7 cursor-pointer p-1 text-gray-200 hover:rounded-full hover:bg-primary-foreground" />
|
||||||
</ClassificationSelectionDialog>
|
</ClassificationSelectionDialog>
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<LuTrash2
|
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onDelete([data.filename]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
{t("button.deleteClassificationAttempts")}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</ClassificationCard>
|
</ClassificationCard>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -847,7 +830,6 @@ type ObjectTrainGridProps = {
|
|||||||
selectedImages: string[];
|
selectedImages: string[];
|
||||||
onClickImages: (images: string[], ctrl: boolean) => void;
|
onClickImages: (images: string[], ctrl: boolean) => void;
|
||||||
onRefresh: () => void;
|
onRefresh: () => void;
|
||||||
onDelete: (ids: string[]) => void;
|
|
||||||
};
|
};
|
||||||
function ObjectTrainGrid({
|
function ObjectTrainGrid({
|
||||||
model,
|
model,
|
||||||
@@ -857,10 +839,7 @@ function ObjectTrainGrid({
|
|||||||
selectedImages,
|
selectedImages,
|
||||||
onClickImages,
|
onClickImages,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
onDelete,
|
|
||||||
}: ObjectTrainGridProps) {
|
}: ObjectTrainGridProps) {
|
||||||
const { t } = useTranslation(["views/classificationModel"]);
|
|
||||||
|
|
||||||
// item data
|
// item data
|
||||||
|
|
||||||
const groups = useMemo(() => {
|
const groups = useMemo(() => {
|
||||||
@@ -980,22 +959,8 @@ function ObjectTrainGrid({
|
|||||||
image={data.filename}
|
image={data.filename}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
>
|
>
|
||||||
<TbCategoryPlus className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
<TbCategoryPlus className="size-7 cursor-pointer p-1 text-gray-200 hover:rounded-full hover:bg-primary-foreground" />
|
||||||
</ClassificationSelectionDialog>
|
</ClassificationSelectionDialog>
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<LuTrash2
|
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onDelete([data.filename]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
{t("button.deleteClassificationAttempts")}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</GroupedClassificationCard>
|
</GroupedClassificationCard>
|
||||||
|
|||||||
Reference in New Issue
Block a user