Refactor: 변경된 api에 맞게 변경
This commit is contained in:
parent
f8ea99a78c
commit
7d310367d2
@ -1,12 +1,20 @@
|
|||||||
import api from '@/api/axiosConfig';
|
import api from '@/api/axiosConfig';
|
||||||
import { ModelRequest, ModelResponse, ProjectModelsResponse, ModelCategoryResponse } from '@/types';
|
import {
|
||||||
|
ModelRequest,
|
||||||
|
ModelResponse,
|
||||||
|
ProjectModelsResponse,
|
||||||
|
ModelCategoryResponse,
|
||||||
|
ModelTrainRequest,
|
||||||
|
ResultResponse,
|
||||||
|
ReportResponse,
|
||||||
|
} from '@/types';
|
||||||
|
|
||||||
export async function updateModelName(projectId: number, modelId: number, modelData: ModelRequest) {
|
export async function updateModelName(projectId: number, modelId: number, modelData: ModelRequest) {
|
||||||
return api.put<ModelResponse>(`/projects/${projectId}/models/${modelId}`, modelData).then(({ data }) => data);
|
return api.put<ModelResponse>(`/projects/${projectId}/models/${modelId}`, modelData).then(({ data }) => data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function trainModel(projectId: number) {
|
export async function trainModel(projectId: number, trainData: ModelTrainRequest) {
|
||||||
return api.post(`/projects/${projectId}/train`).then(({ data }) => data);
|
return api.post(`/projects/${projectId}/train`, trainData).then(({ data }) => data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProjectModels(projectId: number) {
|
export async function getProjectModels(projectId: number) {
|
||||||
@ -20,3 +28,11 @@ export async function addProjectModel(projectId: number, modelData: ModelRequest
|
|||||||
export async function getModelCategories(modelId: number) {
|
export async function getModelCategories(modelId: number) {
|
||||||
return api.get<ModelCategoryResponse[]>(`/models/${modelId}/categories`).then(({ data }) => data);
|
return api.get<ModelCategoryResponse[]>(`/models/${modelId}/categories`).then(({ data }) => data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getModelResults(modelId: number) {
|
||||||
|
return api.get<ResultResponse[]>(`/results/model/${modelId}`).then(({ data }) => data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getModelReports(projectId: number, modelId: number) {
|
||||||
|
return api.get<ReportResponse[]>(`/projects/${projectId}/reports/model/${modelId}`).then(({ data }) => data);
|
||||||
|
}
|
||||||
|
10
frontend/src/queries/models/useModelReportsQuery.ts
Normal file
10
frontend/src/queries/models/useModelReportsQuery.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||||
|
import { getModelReports } from '@/api/modelApi';
|
||||||
|
import { ReportResponse } from '@/types';
|
||||||
|
|
||||||
|
export default function useModelReportsQuery(projectId: number, modelId: number) {
|
||||||
|
return useSuspenseQuery<ReportResponse[]>({
|
||||||
|
queryKey: ['modelReports', projectId, modelId],
|
||||||
|
queryFn: () => getModelReports(projectId, modelId),
|
||||||
|
});
|
||||||
|
}
|
10
frontend/src/queries/models/useModelResultsQuery.ts
Normal file
10
frontend/src/queries/models/useModelResultsQuery.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||||
|
import { getModelResults } from '@/api/modelApi';
|
||||||
|
import { ResultResponse } from '@/types';
|
||||||
|
|
||||||
|
export default function useModelResultsQuery(modelId: number) {
|
||||||
|
return useSuspenseQuery<ResultResponse[]>({
|
||||||
|
queryKey: ['modelResults', modelId],
|
||||||
|
queryFn: () => getModelResults(modelId),
|
||||||
|
});
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
import { trainModel } from '@/api/modelApi';
|
import { trainModel } from '@/api/modelApi';
|
||||||
|
import { ModelTrainRequest } from '@/types';
|
||||||
|
|
||||||
export default function useTrainModelQuery(projectId: number) {
|
export default function useTrainModelQuery(projectId: number) {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: () => trainModel(projectId),
|
mutationFn: (trainData: ModelTrainRequest) => trainModel(projectId, trainData),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -280,6 +280,25 @@ export interface ImageFolderRequest {
|
|||||||
parentId: number;
|
parentId: number;
|
||||||
files: File[];
|
files: File[];
|
||||||
}
|
}
|
||||||
|
export interface LabelCategoryResponse {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
// 카테고리 요청 DTO
|
||||||
|
export interface LabelCategoryRequest {
|
||||||
|
labelCategoryList: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 카테고리 응답 DTO
|
||||||
|
export interface LabelCategoryResponse {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
// 모델 카테고리 응답 DTO
|
||||||
|
export interface ModelCategoryResponse {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
// 모델 요청 DTO (API로 전달할 데이터 타입)
|
// 모델 요청 DTO (API로 전달할 데이터 타입)
|
||||||
export interface ModelRequest {
|
export interface ModelRequest {
|
||||||
@ -292,22 +311,41 @@ export interface ModelResponse {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 모델 카테고리 응답 DTO
|
|
||||||
export interface ModelCategoryResponse {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 프로젝트 모델 리스트 응답 DTO
|
// 프로젝트 모델 리스트 응답 DTO
|
||||||
export interface ProjectModelsResponse extends Array<ModelResponse> {}
|
export interface ProjectModelsResponse extends Array<ModelResponse> {}
|
||||||
|
// 모델 훈련 요청 DTO
|
||||||
// 카테고리 요청 DTO
|
export interface ModelTrainRequest {
|
||||||
export interface LabelCategoryRequest {
|
modelId: number;
|
||||||
labelCategoryList: number[];
|
ratio: number;
|
||||||
|
epochs: number;
|
||||||
|
batch: number;
|
||||||
|
lr0: number;
|
||||||
|
lrf: number;
|
||||||
|
optimizer: 'AUTO' | 'SGD' | 'ADAM' | 'ADAMW' | 'NADAM' | 'RADAM' | 'RMSPROP';
|
||||||
}
|
}
|
||||||
|
export interface ResultResponse {
|
||||||
// 카테고리 응답 DTO
|
|
||||||
export interface LabelCategoryResponse {
|
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
precision: number;
|
||||||
|
recall: number;
|
||||||
|
fitness: number;
|
||||||
|
ratio: number;
|
||||||
|
epochs: number;
|
||||||
|
batch: number;
|
||||||
|
lr0: number;
|
||||||
|
lrf: number;
|
||||||
|
optimizer: 'AUTO' | 'SGD' | 'ADAM' | 'ADAMW' | 'NADAM' | 'RADAM' | 'RMSPROP';
|
||||||
|
map50: number;
|
||||||
|
map5095: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportResponse {
|
||||||
|
modelId: number;
|
||||||
|
totalEpochs: number;
|
||||||
|
epoch: number;
|
||||||
|
boxLoss: number;
|
||||||
|
clsLoss: number;
|
||||||
|
dflLoss: number;
|
||||||
|
fitness: number;
|
||||||
|
epochTime: number;
|
||||||
|
leftSecond: number;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user