Feat: train용 store 제작, 추후 수정 필요

This commit is contained in:
정현조 2024-09-24 16:28:08 +09:00
parent 8931bd323a
commit c3838c40c9

View File

@ -0,0 +1,40 @@
import { create } from 'zustand';
interface TrainingData {
epoch: number;
total_epochs: number;
box_loss: number;
cls_loss: number;
dfl_loss: number;
fitness: number;
epoch_time: number;
left_second: number;
}
interface StoreState {
trainingDataByProject: { [projectId: string]: TrainingData[] };
addTrainingData: (projectId: string, data: TrainingData) => void;
resetTrainingData: (projectId: string) => void;
}
const useTrainStore = create<StoreState>((set) => ({
trainingDataByProject: {},
addTrainingData: (projectId: string, data: TrainingData) =>
set((state) => ({
trainingDataByProject: {
...state.trainingDataByProject,
[projectId]: [...(state.trainingDataByProject[projectId] || []), data],
},
})),
resetTrainingData: (projectId: string) =>
set((state) => ({
trainingDataByProject: {
...state.trainingDataByProject,
[projectId]: [],
},
})),
}));
export default useTrainStore;