From 46fbedf0ad7b167a28daf2030e06f34480576394 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 3 Jun 2018 02:25:34 +0200 Subject: add results page --- app/client/modules/samplernn/samplernn.results.js | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 app/client/modules/samplernn/samplernn.results.js (limited to 'app/client/modules/samplernn/samplernn.results.js') diff --git a/app/client/modules/samplernn/samplernn.results.js b/app/client/modules/samplernn/samplernn.results.js new file mode 100644 index 0000000..518864b --- /dev/null +++ b/app/client/modules/samplernn/samplernn.results.js @@ -0,0 +1,108 @@ +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 Dataset from '../../dataset/dataset.component' + +import Group from '../../common/group.component' +import Slider from '../../common/slider.component' +import Select from '../../common/select.component' +import Button from '../../common/button.component' +import { FileList, FileRow } from '../../common/fileList.component' +import TextInput from '../../common/textInput.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 ( +
+ fetching... +
+ ) + } else { + return ( +
this.fetchURL(file.url)}> + fetch +
+ ) + } + } + return ( +
+
this.train(file)}>train
+ {file.epoch == 0 &&
{file.epochs} ep.
} +
+ ) + } + render(){ + if (this.props.samplernn.loading) return Loading + 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 ( +
+

{key}

+ {!!bestRenders.length && + + } +
+ ) + }) + + return ( +
+
+

SampleRNN

+
+
+ {renders} +
+
+ ) + } +} + +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) -- cgit v1.2.3-70-g09d2