-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathInputSelector.js
More file actions
208 lines (199 loc) · 6.25 KB
/
InputSelector.js
File metadata and controls
208 lines (199 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import { Form, Space } from "antd";
import React, { useContext } from "react";
import { AppContext } from "../contexts/GlobalContext";
import UnifiedFileInput from "./UnifiedFileInput";
import InlineHelpChat from "./InlineHelpChat";
function InputSelector(props) {
const context = useContext(AppContext);
const { type } = props;
const projectContext =
"Biomedical image segmentation using PyTorch Connectomics.";
const taskContext =
type === "training"
? "Model training configuration — Step 1: Set Inputs."
: "Model inference configuration — Step 1: Set Inputs.";
const handleLogPathChange = (value) => {
context.setLogPath(value);
};
const handleOutputPathChange = (value) => {
context.setOutputPath(value);
};
const handleCheckpointPathChange = (value) => {
context.setCheckpointPath(value);
};
const handleImageChange = (value) => {
console.log(`selected image:`, value);
context.setInputImage(value);
};
const handleLabelChange = (value) => {
console.log(`selected label:`, value);
context.setInputLabel(value);
};
// Helper to get value for UnifiedFileInput (can be object or string)
const getValue = (val) => {
if (!val) return "";
return val;
};
return (
<div style={{ marginTop: "10px" }}>
<Form
labelCol={{
span: 5,
}}
wrapperCol={{
span: 14,
}}
>
<Form.Item
label={
<Space align="center">
<span>Input Image</span>
<InlineHelpChat
taskKey={type}
label="Input Image"
yamlKey="DATASET.INPUT_PATH"
value={context.inputImage}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
>
<UnifiedFileInput
placeholder="Please select or input image path"
onChange={handleImageChange}
value={getValue(context.inputImage)}
selectionType={
type === "training" || type === "inference"
? "fileOrDirectory"
: "file"
}
/>
</Form.Item>
<Form.Item
label={
<Space align="center">
<span>Input Label</span>
<InlineHelpChat
taskKey={type}
label="Input Label"
yamlKey="DATASET.LABEL_NAME"
value={context.inputLabel}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
>
<UnifiedFileInput
placeholder="Please select or input label path"
onChange={handleLabelChange}
value={getValue(context.inputLabel)}
selectionType={
type === "training" || type === "inference"
? "fileOrDirectory"
: "file"
}
/>
</Form.Item>
{type === "training" ? (
<Form.Item
label={
<Space align="center">
<span>Output Path</span>
<InlineHelpChat
taskKey={type}
label="Output Path"
yamlKey="DATASET.OUTPUT_PATH"
value={context.outputPath}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
>
<UnifiedFileInput
placeholder="Directory for outputs (e.g., /path/to/outputs/)"
value={context.outputPath || ""}
onChange={handleOutputPathChange}
selectionType="directory"
/>
</Form.Item>
) : (
<Form.Item
label={
<Space align="center">
<span>Output Path</span>
<InlineHelpChat
taskKey={type}
label="Output Path"
yamlKey="INFERENCE.OUTPUT_PATH"
value={context.outputPath}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
help="Directory where inference results will be saved"
>
<UnifiedFileInput
placeholder="Directory for results (e.g., /path/to/inference_output/)"
value={context.outputPath || ""}
onChange={handleOutputPathChange}
selectionType="directory"
/>
</Form.Item>
)}
{type === "training" ? (
<Form.Item
label={
<Space align="center">
<span>Log Path</span>
<InlineHelpChat
taskKey={type}
label="Log Path"
yamlKey="SOLVER.LOG_DIR"
value={context.logPath}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
>
<UnifiedFileInput
placeholder="Please type training log path"
value={context.logPath || ""}
onChange={handleLogPathChange}
selectionType="directory"
/>
</Form.Item>
) : (
<Form.Item
label={
<Space align="center">
<span>Checkpoint Path</span>
<InlineHelpChat
taskKey={type}
label="Checkpoint Path"
yamlKey="MODEL.PRE_MODEL"
value={context.checkpointPath}
projectContext={projectContext}
taskContext={taskContext}
/>
</Space>
}
help="Path to trained model file (.pth.tar)"
>
<UnifiedFileInput
placeholder="Model checkpoint file (e.g., /path/to/checkpoint_00010.pth.tar)"
value={context.checkpointPath || ""}
onChange={handleCheckpointPathChange}
selectionType="file"
/>
</Form.Item>
)}
</Form>
</div>
);
}
export default InputSelector;