diff --git a/front/src/api/evaluation_sets.ts b/front/src/api/evaluation_sets.ts index 3e5fe8b1..812ea07f 100644 --- a/front/src/api/evaluation_sets.ts +++ b/front/src/api/evaluation_sets.ts @@ -21,6 +21,7 @@ export type EvaluationSetFilter = z.input; export const EvaluationSetCreateSchema = z.object({ name: z.string(), description: z.string().optional(), + task: z.string(), }); export type EvaluationSetCreate = z.input; diff --git a/front/src/app/(base)/evaluation/detail/context.ts b/front/src/app/(base)/evaluation/detail/context.ts index dd8f94ef..217c6228 100644 --- a/front/src/app/(base)/evaluation/detail/context.ts +++ b/front/src/app/(base)/evaluation/detail/context.ts @@ -8,6 +8,7 @@ const EvaluationSetContext = createContext({ tags: [], uuid: "", created_on: new Date(), + task: "sound_event_detection", }); export default EvaluationSetContext; diff --git a/front/src/app/contexts.ts b/front/src/app/contexts.ts deleted file mode 100644 index 8a3d5307..00000000 --- a/front/src/app/contexts.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { createContext } from "react"; - -import { type EvaluationSetUpdate } from "@/api/evaluation_sets"; - -import type { EvaluationSet, Tag } from "@/types"; - -type EvaluationSetContextType = { - evaluationSet: EvaluationSet; - update?: (data: EvaluationSetUpdate) => Promise; - delete?: () => Promise; - addTag?: (tag: Tag) => Promise; - removeTag?: (tag: Tag) => Promise; -}; - -const EvaluationSetContext = createContext({ - evaluationSet: { - name: "", - description: "", - tags: [], - uuid: "", - created_on: new Date(), - }, -}); - -export default EvaluationSetContext; diff --git a/front/src/components/annotation_projects/AnnotationProjectActions.tsx b/front/src/components/annotation_projects/AnnotationProjectActions.tsx index 1616bbc8..d6ce33b5 100644 --- a/front/src/components/annotation_projects/AnnotationProjectActions.tsx +++ b/front/src/components/annotation_projects/AnnotationProjectActions.tsx @@ -84,7 +84,7 @@ export default function ProjectActions({ diff --git a/front/src/components/clip_evaluations/ClipEvaluationSpectrogram.tsx b/front/src/components/clip_evaluations/ClipEvaluationSpectrogram.tsx index bc8608e8..6d5fb4d2 100644 --- a/front/src/components/clip_evaluations/ClipEvaluationSpectrogram.tsx +++ b/front/src/components/clip_evaluations/ClipEvaluationSpectrogram.tsx @@ -45,8 +45,7 @@ export default function ClipEvaluationSpectrogram(props: { height: 0, }; - const { sound_event_evaluations: matches, clip_prediction: clipPrediction } = - clipEvaluation; + const { clip_prediction: clipPrediction } = clipEvaluation; const { clip } = clipPrediction; const { recording } = clip; @@ -120,6 +119,11 @@ export default function ClipEvaluationSpectrogram(props: { [clipPrediction.sound_events], ); + const matches = useMemo( + () => clipEvaluation.sound_event_evaluations || [], + [clipEvaluation.sound_event_evaluations], + ); + const drawMatches = useMatchDraw({ viewport: spectrogram.viewport, matches, diff --git a/front/src/components/evaluation_sets/EvaluationSetCreate.tsx b/front/src/components/evaluation_sets/EvaluationSetCreate.tsx index c210cac3..bb3af9a6 100644 --- a/front/src/components/evaluation_sets/EvaluationSetCreate.tsx +++ b/front/src/components/evaluation_sets/EvaluationSetCreate.tsx @@ -55,7 +55,7 @@ export default function EvaluationSetCreate({ control, formState: { errors }, register, - } = useForm({ + } = useForm({ resolver: zodResolver(EvaluationSetCreateSchema), mode: "onChange", }); diff --git a/front/src/components/evaluation_sets/EvaluationSetUpdateForm.tsx b/front/src/components/evaluation_sets/EvaluationSetUpdateForm.tsx index c4ea9775..498366c8 100644 --- a/front/src/components/evaluation_sets/EvaluationSetUpdateForm.tsx +++ b/front/src/components/evaluation_sets/EvaluationSetUpdateForm.tsx @@ -47,7 +47,9 @@ export default function EvaluationSetUpdateForm({ Description updateEvaluationSet({ description })} + onChange={(description) => + updateEvaluationSet({ description: description || undefined }) + } rows={6} Input={TextArea} autoFocus diff --git a/front/src/hooks/api/useEvaluationSet.ts b/front/src/hooks/api/useEvaluationSet.ts index 107e48bd..847f1df0 100644 --- a/front/src/hooks/api/useEvaluationSet.ts +++ b/front/src/hooks/api/useEvaluationSet.ts @@ -3,6 +3,7 @@ import { useMemo } from "react"; import api from "@/app/api"; import useObject from "@/hooks/utils/useObject"; +import type { EvaluationSetUpdate } from "@/api/evaluation_sets"; import type { EvaluationSet } from "@/types"; import type { AxiosError } from "axios"; @@ -40,7 +41,7 @@ export default function useEvaluationSet({ onError, }); - const update = useMutation({ + const update = useMutation({ mutationFn: api.evaluationSets.update, onSuccess: onUpdate, }); diff --git a/front/src/hooks/api/useModelRun.ts b/front/src/hooks/api/useModelRun.ts index 00e7adb6..ce3c7dd0 100644 --- a/front/src/hooks/api/useModelRun.ts +++ b/front/src/hooks/api/useModelRun.ts @@ -41,13 +41,7 @@ export default function useModelRun({ onSuccess: onUpdate, }); - const evaluate = useMutation< - { - evaluationSet: EvaluationSet; - task: string; - }, - Evaluation - >({ + const evaluate = useMutation({ mutationFn: api.modelRuns.evaluate, onSuccess: onEvaluate, withUpdate: false, diff --git a/front/src/utils/tags.ts b/front/src/utils/tags.ts index 27951852..426a6d1a 100644 --- a/front/src/utils/tags.ts +++ b/front/src/utils/tags.ts @@ -9,6 +9,7 @@ import type { Box, Dimensions, SoundEventAnnotation, + SoundEventPrediction, SpectrogramWindow, Tag, TimeInterval, @@ -29,7 +30,7 @@ export type Position = { }; export type TagGroup = { - annotation: SoundEventAnnotation; + annotation: SoundEventAnnotation | SoundEventPrediction; tags: TagElement[]; position: Position; active?: boolean; @@ -42,7 +43,7 @@ function getTimeIntervalLabelPosition({ window, dimensions, }: { - annotation: SoundEventAnnotation; + annotation: SoundEventAnnotation | SoundEventPrediction; window: SpectrogramWindow; dimensions: Dimensions; }): Position { @@ -105,7 +106,7 @@ function getTimeStampLabelPosition({ window, dimensions, }: { - annotation: SoundEventAnnotation; + annotation: SoundEventAnnotation | SoundEventPrediction; window: SpectrogramWindow; dimensions: Dimensions; }): Position { @@ -144,7 +145,7 @@ function getTimeStampLabelPosition({ } export function getLabelPosition( - annotation: SoundEventAnnotation, + annotation: SoundEventAnnotation | SoundEventPrediction, window: SpectrogramWindow, dimensions: Dimensions, ): Position {