mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-16 18:16:44 +03:00
Add basic classification model wizard
This commit is contained in:
parent
cac2adde31
commit
bec64dbeb3
@ -49,5 +49,9 @@
|
|||||||
"new": "Create New Class"
|
"new": "Create New Class"
|
||||||
},
|
},
|
||||||
"categorizeImageAs": "Classify Image As:",
|
"categorizeImageAs": "Classify Image As:",
|
||||||
"categorizeImage": "Classify Image"
|
"categorizeImage": "Classify Image",
|
||||||
|
"wizard": {
|
||||||
|
"title": "Create New Classification",
|
||||||
|
"description": "Create a new state or object classification model."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,66 @@
|
|||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import StepIndicator from "../indicators/StepIndicator";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "../ui/dialog";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const STEPS = [
|
||||||
|
"classificationWizard.steps.nameAndDefine",
|
||||||
|
"classificationWizard.steps.stateArea",
|
||||||
|
"classificationWizard.steps.chooseExamples",
|
||||||
|
"classificationWizard.steps.train",
|
||||||
|
];
|
||||||
|
|
||||||
|
type ClassificationModelWizardDialogProps = {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
export default function ClassificationModelWizardDialog({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
}: ClassificationModelWizardDialogProps) {
|
||||||
|
const { t } = useTranslation(["views/classificationModel"]);
|
||||||
|
|
||||||
|
// step management
|
||||||
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
onClose;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogContent
|
||||||
|
className="max-h-[90dvh] max-w-4xl overflow-y-auto"
|
||||||
|
onInteractOutside={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StepIndicator
|
||||||
|
steps={STEPS}
|
||||||
|
currentStep={currentStep}
|
||||||
|
variant="dots"
|
||||||
|
className="mb-4 justify-start"
|
||||||
|
/>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{t("wizard.title")}</DialogTitle>
|
||||||
|
{currentStep === 0 && (
|
||||||
|
<DialogDescription>{t("wizard.description")}</DialogDescription>
|
||||||
|
)}
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<div className="pb-4">
|
||||||
|
<div className="size-full"></div>
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -304,10 +304,10 @@ export type CustomClassificationModelConfig = {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
threshold: number;
|
threshold: number;
|
||||||
object_config: null | {
|
object_config?: {
|
||||||
objects: string[];
|
objects: string[];
|
||||||
};
|
};
|
||||||
state_config: null | {
|
state_config?: {
|
||||||
cameras: {
|
cameras: {
|
||||||
[cameraName: string]: {
|
[cameraName: string]: {
|
||||||
crop: [number, number, number, number];
|
crop: [number, number, number, number];
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { baseUrl } from "@/api/baseUrl";
|
import { baseUrl } from "@/api/baseUrl";
|
||||||
|
import ClassificationModelWizardDialog from "@/components/classification/ClassificationModelWizardDialog";
|
||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||||
@ -52,6 +53,10 @@ export default function ModelSelectionView({
|
|||||||
});
|
});
|
||||||
}, [config, pageToggle]);
|
}, [config, pageToggle]);
|
||||||
|
|
||||||
|
// new model wizard
|
||||||
|
|
||||||
|
const [newModel, setNewModel] = useState(false);
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
@ -62,6 +67,11 @@ export default function ModelSelectionView({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex size-full flex-col p-2">
|
<div className="flex size-full flex-col p-2">
|
||||||
|
<ClassificationModelWizardDialog
|
||||||
|
open={newModel}
|
||||||
|
onClose={() => setNewModel(false)}
|
||||||
|
/>
|
||||||
|
|
||||||
<div className="flex h-12 w-full items-center justify-between">
|
<div className="flex h-12 w-full items-center justify-between">
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<ToggleGroup
|
<ToggleGroup
|
||||||
@ -93,7 +103,11 @@ export default function ModelSelectionView({
|
|||||||
</ToggleGroup>
|
</ToggleGroup>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<Button className="flex flex-row items-center gap-2" variant="select">
|
<Button
|
||||||
|
className="flex flex-row items-center gap-2"
|
||||||
|
variant="select"
|
||||||
|
onClick={() => setNewModel(true)}
|
||||||
|
>
|
||||||
<FaFolderPlus />
|
<FaFolderPlus />
|
||||||
Add Classification
|
Add Classification
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user