Feat: 오토 레이블링 api 연결 - S11P21S002

This commit is contained in:
jhynsoo 2024-09-25 11:01:12 +09:00
parent 27c5dbc2b8
commit d8208b0b79
3 changed files with 16 additions and 11 deletions

View File

@ -10,14 +10,6 @@ export async function saveImageLabels(
return api.post(`/projects/${projectId}/images/${imageId}/label`, data).then(({ data }) => data); return api.post(`/projects/${projectId}/images/${imageId}/label`, data).then(({ data }) => data);
} }
export async function runAutoLabel(projectId: number, memberId: number) { export async function runAutoLabel(projectId: number, modelId = 1) {
return api return api.post(`/projects/${projectId}/auto`, { modelId }).then(({ data }) => data);
.post(
`/projects/${projectId}/label/auto`,
{},
{
params: { memberId },
}
)
.then(({ data }) => data);
} }

View File

@ -7,11 +7,13 @@ import useCanvasStore from '@/stores/useCanvasStore';
import { Button } from '../ui/button'; import { Button } from '../ui/button';
import { useEffect } from 'react'; import { useEffect } from 'react';
import WorkspaceDropdownMenu from '../WorkspaceDropdownMenu'; import WorkspaceDropdownMenu from '../WorkspaceDropdownMenu';
import useAutoLabelQuery from '@/queries/projects/useAutoLabelQuery';
export default function ProjectStructure({ project }: { project: Project }) { export default function ProjectStructure({ project }: { project: Project }) {
const setProject = useCanvasStore((state) => state.setProject); const setProject = useCanvasStore((state) => state.setProject);
const image = useCanvasStore((state) => state.image); const image = useCanvasStore((state) => state.image);
const { data: folderData, refetch } = useFolderQuery(project.id.toString(), 0); const { data: folderData, refetch } = useFolderQuery(project.id.toString(), 0);
const requestAutoLabel = useAutoLabelQuery();
useEffect(() => { useEffect(() => {
setProject(project); setProject(project);
@ -59,7 +61,9 @@ export default function ProjectStructure({ project }: { project: Project }) {
<Button <Button
variant="outlinePrimary" variant="outlinePrimary"
className="w-full" className="w-full"
onClick={() => console.log('autolabel')} onClick={() => {
requestAutoLabel.mutate({ projectId: project.id }, { onSuccess: refetch });
}}
> >
<Play <Play
size={16} size={16}

View File

@ -0,0 +1,9 @@
import { runAutoLabel } from '@/api/lablingApi';
import { useMutation } from '@tanstack/react-query';
export default function useAutoLabelQuery() {
return useMutation({
mutationFn: ({ projectId, modelId = 1 }: { projectId: number; modelId?: number }) =>
runAutoLabel(projectId, modelId),
});
}