Newer
Older
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
import React, { useState, useEffect } from "react";
import { Grid, RadioGroup, FormControlLabel, FormControl, FormLabel, Radio, Card, CardContent, Typography, AlertTitle } from '@mui/material';
import {Button, TextField, Checkbox, Alert} from '@mui/material';
import { useForm, Controller} from "react-hook-form";
import SendIcon from '@mui/icons-material/Send';
import { CardActions, Collapse, IconButton } from "@mui/material";
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { styled } from '@mui/material/styles';
import {useNavigate, Route} from "react-router-dom";
const ExpandMore = styled((props) => {
const { expand, ...other } = props;
return <IconButton {...other} />;
})(({ theme, expand }) => ({
transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)',
marginLeft: 'auto',
transition: theme.transitions.create('transform', {
duration: theme.transitions.duration.shortest,
}),
}));
export default function Home() {
const [selectAction, setSelectAction] = useState([]);
// for form submission
const {register, control, handleSubmit, setValue, watch, formState: { errors, dirtyFields}} = useForm();
const watchFileds = watch(['select_dataset', 'select_network']);
let navigate = useNavigate();
const onSubmit = async (data) => {
console.log('data', data);
const formData = new FormData();
formData.append("ds_upload", data.ds_upload[0]);
formData.append("network_upload", data.network_upload[0]);
formData.append("batch_size", data.batch_size)
formData.append("toy_size", data.toy_size)
formData.append("iterations", data.iterations)
formData.append("learning_rate", data.learning_rate)
formData.append("select_action", data.select_action)
formData.append("select_dataset", data.select_dataset)
formData.append("select_learner", data.select_learner)
formData.append("select_network", data.select_network)
console.log('>>> this is the user input in formData')
for (var key of formData.entries()) {
console.log(key[0] + ', ' + key[1])}
var responseClone
const res = await fetch('/home', {
method: 'POST',
body: formData
}).then((response) => response.json());
console.log('sent data')
const check = fetch('/home').then(
response => response.json()
).then(data => {
if ('error' in data){navigate('/error', data)} else {navigate('/confirm', {replace:true})}
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
};
// handling action selection
const handleActionSelect = (value) => {
const isPresent = selectAction.indexOf(value);
if (isPresent !== -1) {
const remaining = selectAction.filter((item) => item !== value);
setSelectAction(remaining);
} else {
setSelectAction((prevItems) => [...prevItems, value]);
}
};
useEffect(() => {
setValue('select_action', selectAction);
}, [selectAction]);
// collpase
const [expanded, setExpanded] = React.useState(false);
const handleExpandClick = () => {
setExpanded(!expanded);
};
return (
<div className="App" style={{padding:"60px"}}>
<Typography gutterBottom variant="h3" align="center" >
Data Auto-Augmentation
</Typography>
<Grid >
<form action="/home" method="POST" onSubmit={handleSubmit(onSubmit)}>
<Grid style={{padding:"30px 0px"}}>
<Card style={{ maxWidth: 900, padding: "10px 5px", margin: "0 auto" }}>
<CardContent>
<Typography gutterBottom variant="h5" align="left">
Dataset Uploading
</Typography>
<FormControl style={{ maxWidth: 800, padding:"20px"}} error={Boolean(errors.select_dataset)}>
<FormLabel id="select_dataset" align="left" variant="h6">
Please select the dataset you'd like to use here or select 'Other' if you would like to upload your own dataset
</FormLabel>
<Controller
name='select_dataset'
control={control}
rules={{ required: true }}
render={({field: { onChange, value }}) => (
<RadioGroup
row
aria-labelledby="select_dataset"
// defaultValue="Other"
name="select_dataset"
align="centre"
value={value ?? ""}
onChange={onChange}
>
<FormControlLabel value="MNIST" control={<Radio />} label="MNIST" />
<FormControlLabel value="KMNIST" control={<Radio />} label="KMNIST" />
<FormControlLabel value="FashionMNIST" control={<Radio />} label="FashionMNIST" />
<FormControlLabel value="CIFAR10" control={<Radio />} label="CIFAR10" />
<FormControlLabel value="CIFAR100" control={<Radio />} label="CIFAR100" />
<FormControlLabel value="Other" control={<Radio />} label="Other" />
</RadioGroup>
)}
/>
{errors.select_dataset && errors.select_dataset.type === "required" &&
<Alert severity="error">
<AlertTitle>This field is required</AlertTitle>
</Alert>}
{watchFileds[0]!=='Other' &&
<input
{...register('ds_upload')}
name="ds_upload"
type="file"
hidden
/>}
{watchFileds[0]==='Other' &&
<Button
variant="contained"
component="label"
>
Upload File
<input
{...register('ds_upload')}
name="ds_upload"
type="file"
hidden
/>
</Button>
}
{watchFileds[0]==='Other' && dirtyFields.ds_upload && <Alert severity="success" variant='outlined'>File Submitted</Alert>}
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
</FormControl>
</CardContent>
</Card>
</Grid>
<Grid style={{padding:"30px 0px"}}>
<Card style={{ maxWidth: 900, padding: "10px 5px", margin: "0 auto" }}>
<CardContent>
<Typography gutterBottom variant="h5" align="left">
Network Uploading
</Typography>
<FormControl style={{ maxWidth: 800, padding:"20px"}} error={Boolean(errors.select_network)}>
<FormLabel id="select_network" align="left" variant="h6">
Please select the network you'd like to use here or select 'Other' if you would like to upload your own network
</FormLabel>
<Controller
name='select_network'
control={control}
rules={{ required: true }}
render={({field: { onChange, value }}) => (
<RadioGroup
row
aria-labelledby="select_network"
name="select_network"
align="centre"
value={value ?? ""}
onChange={onChange}
>
<FormControlLabel value="LeNet" control={<Radio />} label="LeNet" />
<FormControlLabel value="SimpleNet" control={<Radio />} label="SimpleNet" />
<FormControlLabel value="EasyNet" control={<Radio />} label="EasyNet" />
<FormControlLabel value="Other" control={<Radio />} label="Other" />
</RadioGroup> )}
/>
{errors.select_network && errors.select_network.type === "required" &&
<Alert severity="error">
<AlertTitle>This field is required</AlertTitle>
</Alert>}
<Typography style={{ maxWidth: 750}} variant="body2" color="textSecondary" component="p" gutterBottom align="left">
The networks provided above are for demonstration purposes. The relative training time is: LeNet {'>'} SimpleNet {'>'} EasyNet.
We recommend you to choose EasyNet for a quick demonstration of how well our auto-augment agents can perform.
</Typography>
{watchFileds[1]!=='Other' &&
<input
{...register('network_upload')}
name="network_upload"
type="file"
hidden
/>}
{watchFileds[1]==='Other' &&
<Button
variant="contained"
component="label"
>
Upload File
<input
{...register('network_upload')}
name="network_upload"
type="file"
hidden
/>
</Button>
}
{watchFileds[1]==='Other' && dirtyFields.network_upload && <Alert severity="success" variant='outlined'>File Submitted</Alert>}
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
</FormControl>
</CardContent>
</Card>
</Grid>
<Grid style={{padding:"30px 0px"}}>
<Card style={{ maxWidth: 900, padding: "10px 5px", margin: "0 auto" }}>
<CardContent>
<Typography gutterBottom variant="h5" align="left">
Auto-augment Learner Selection
</Typography>
<FormControl style={{ maxWidth: 800, padding:"20px"}} error={Boolean(errors.select_learner)}>
<FormLabel id="select_learner" align="left" variant="h6">
Please select the auto-augment learners you'd like to use (multiple learners can be selected)
</FormLabel>
<Controller
name='select_learner'
control={control}
rules={{ required: true }}
render={({field: { onChange, value }}) => (
<RadioGroup
row
aria-labelledby="select_learner"
name="select_learner"
align="centre"
value={value ?? ""}
onChange={onChange}
>
<FormControlLabel value="UCB learner" control={<Radio />} label="UCB learner" />
<FormControlLabel value="Evolutionary learner" control={<Radio />} label="Evolutionary learner" />
<FormControlLabel value="Random Searcher" control={<Radio />} label="Random Searcher" />
<FormControlLabel value="GRU Learner" control={<Radio />} label="GRU Learner" />
</RadioGroup> )}
/>
{errors.select_learner && errors.select_learner.type === "required" &&
<Alert severity="error">
<AlertTitle>This field is required</AlertTitle>
</Alert>}
<Typography style={{ maxWidth: 800}} variant="body2" color="textSecondary" component="p" gutterBottom align="left">
(give user some recommendation here...)
</Typography>
</FormControl>
</CardContent>
</Card>
</Grid>
<Grid style={{padding:"30px 0px", maxWidth: 900, margin: "0 auto"}}>
<Card style={{ maxWidth: 900, padding: "10px 5px", margin: "0 auto" }}>
<CardContent>
<Typography variant="h5" align="left">
Advanced Search
</Typography>
</CardContent>
<CardActions disableSpacing>
<ExpandMore
expand={expanded}
onClick={handleExpandClick}
aria-expanded={expanded}
aria-label="show more"
>
<ExpandMoreIcon />
</ExpandMore>
</CardActions>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<Grid container
spacing={0}
direction="column"
alignItems="center"
justify="center">
<CardContent>
<Typography gutterBottom variant="subtitle1" align='left'>
Please input the hyperparameter you'd like to train your dataset with
</Typography>
<Grid container spacing={1} style={{maxWidth:800, padding:"10px 10px"}}>
<Grid xs={12} sm={6} item>
<TextField type="number" InputProps={{step:"1", inputProps: { min: 0} }} {...register("batch_size")} name="batch_size" placeholder="Batch Size" label="Batch Size" variant="outlined" fullWidth />
</Grid>
<Grid xs={12} sm={6} item>
<TextField type="number" inputProps={{step: "0.000000001",min: 0}} {...register("learning_rate")} name="learning_rate" placeholder="Learning Rate" label="Learning Rate" variant="outlined" fullWidth />
</Grid>
<Grid xs={12} sm={6} item>
<TextField type="number" InputProps={{step:"1", inputProps: { min: 0} }} {...register("iterations")} name="iterations" placeholder="Number of Iterations" label="Iterations" variant="outlined" fullWidth />
<TextField type="number" inputProps={{step: "0.0001", min: 0, max: 1}} {...register("toy_size")} name="toy_size" placeholder="Dataset Proportion" label="Dataset Proportion" variant="outlined" fullWidth />
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
</Grid>
<FormLabel variant="h8" align='centre'>
* Dataset Proportion defines the percentage of original dataset our auto-augment learner will use to find the
augmentation policy. If your dataset is large, we recommend you to set Dataset Proportion a small value (0.1-0.3).
</FormLabel>
</Grid>
<Grid style={{maxWidth:800, padding:"40px 10px"}}>
<Typography gutterBottom variant="subtitle1" align='left'>
Please select augmentation methods you'd like to exclude
</Typography>
<div>
{['ShearX', 'ShearY', 'TranslateX', 'TranslateY', 'Rotate', 'Brightness',
'Color', 'Contrast', 'Sharpness', 'Posterize', 'Solarize', 'AutoContrast',
'Equalize', 'Invert'].map((option) => {
return (
<FormControlLabel
control={
<Controller
name='select_action'
render={({}) => {
return (
<Checkbox
checked={selectAction.includes(option)}
onChange={() => handleActionSelect(option)}/> );
}}
control={control}
/>}
label={option}
key={option}
/>
);
})}
</div>
</Grid>
</CardContent>
</Grid>
</Collapse>
</Card>
</Grid>
<Button
type="submit"
variant="contained"
color='success'
size='large'
endIcon={<SendIcon />}
>
Submit Form
</Button>
{watchFileds[0]==='Other' && !dirtyFields.ds_upload &&
<Alert severity="error" variant='standard'>Please upload your dataset
zip file or select one of the dataset we have provided</Alert>}
{watchFileds[1]==='Other' && !dirtyFields.network_upload &&
<Alert severity="error" variant='standard'>Please upload your network
.pkl file or select one of the network we have provided</Alert>}
</form>
</Grid>
</div>
);
}