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
|
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import * as util from '../../util'
import * as samplernnActions from './samplernn.actions'
import { FileList, FileRow } from '../../common/fileList.component'
class SampleRNNResults extends Component {
constructor(props){
super()
this.fileOptions = this.fileOptions.bind(this)
this.pickFile = this.pickFile.bind(this)
let id = props.match.params.id || localStorage.getItem('samplernn.last_id')
if (!props.samplernn.data) props.actions.load_directories()
}
pickFile(file){
console.log('pick', file)
}
fileOptions(file){
if (file.activity === 'url' && !file.dataset) {
if (this.props.runner.cpu.status !== 'IDLE') {
return (
<div className='gray'>
fetching...
</div>
)
} else {
return (
<div className='link' onClick={() => this.fetchURL(file.url)}>
fetch
</div>
)
}
}
return (
<div>
<div className='link' onClick={() => this.train(file)}>train</div>
{file.epoch == 0 && <div className='epochs'>{file.epochs} ep.</div>}
</div>
)
}
render(){
if (this.props.samplernn.loading) return <span>Loading</span>
console.log(this.props.samplernn.data)
const { folderLookup } = this.props.samplernn.data
// const { folderLookup } = samplernn
console.log(this.props)
const renders = Object.keys(folderLookup).sort(util.sort.stringSort.asc).map(key => {
const folder = folderLookup[key]
let { mapFn, sortFn } = util.sort.orderByFn('epoch desc')
console.log(mapFn, sortFn)
const datasetPairs = folder.datasets.map(mapFn).sort(sortFn)
const bestRenders = datasetPairs
.map(pair => pair[1])
.filter(dataset => dataset.output.length)
.map(dataset => {
const { output } = dataset
return output.map(mapFn).sort(sortFn)[0][1]
})
console.log(bestRenders.map(r => r.epoch))
return (
<div className='col'>
<h3>{key}</h3>
{!!bestRenders.length &&
<FileList
files={bestRenders}
orderBy='date desc'
fields={'name date epoch size'}
/>
}
</div>
)
})
return (
<div className='app'>
<div className='heading'>
<h2>SampleRNN</h2>
</div>
<div class='rows params renders'>
{renders}
</div>
</div>
)
}
}
const mapStateToProps = state => ({
samplernn: state.module.samplernn,
runner: state.system.runner,
task: state.task,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: bindActionCreators(samplernnActions, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(SampleRNNResults)
|