summaryrefslogtreecommitdiff
path: root/app/client/common/augmentationGrid.component.js
blob: af77f6c5e8e0ce60fae9fff2f744d8ee569e0d37 (plain)
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
import { h, Component } from 'preact'

import Group from './group.component'
import Param from './param.component'
import Button from './button.component'
import ButtonGrid from './buttonGrid.component'

export default class AugmentationGrid extends Component {
  state = {
    x: 0, y: 0, sum: 0,
  }
  render() {
    let {
      make, take, checkpoint,
      onTrain, onAugment,
    } = this.props
    let {
      x, y, sum
    } = this.state
    let rows = []
    return (
      <Group className='augmentationGrid'>
        <ButtonGrid 
          x={make}
          y={take}
          max={5000}
          onHover={(x, y) => this.setState({ x, y })}
          onClick={(x, y) => {
            this.setState({ sum: sum + x * y })
            onAugment(y, x)
          }}
        />
        <Param title='Name'>{checkpoint.name}</Param>
        <Param title='Take'>{y}</Param>
        <Param title='Make'>{x}</Param>
        <Param title='Will add to dataset'>{x * y}</Param>
        <Param title='Total added this epoch'>{sum}</Param>
        <Param title='Sequence length'>{checkpoint.sequenceCount}</Param>
        <Param title='Dataset size'>{checkpoint.datasetCount}</Param>
        <Button onClick={() => {
          this.setState({ sum: 0 })
          onTrain()
        }}>Train</Button>
      </Group>
    )
  }
}