diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-04 13:53:30 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-04 13:53:30 +0200 |
| commit | 25815ab4916dc8c9e3256cbfe53bea0535930f30 (patch) | |
| tree | 4d87860e82ede57780497c6016e54bf1af68ca91 /app/client | |
| parent | 56619248e5032b644ec7a8e215bd59aecad86c73 (diff) | |
fix loading bars
Diffstat (limited to 'app/client')
| -rw-r--r-- | app/client/common/index.js | 4 | ||||
| -rw-r--r-- | app/client/common/numberInput.component.js | 49 | ||||
| -rw-r--r-- | app/client/common/textInput.component.js | 7 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.actions.js | 6 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.component.js | 12 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.reducer.js | 10 | ||||
| -rw-r--r-- | app/client/dashboard/dashboardHeader.component.js | 1 | ||||
| -rw-r--r-- | app/client/dataset/dataset.reducer.js | 1 | ||||
| -rw-r--r-- | app/client/modules/morph/morph.actions.js | 6 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/index.js | 1 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.actions.js | 12 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.tasks.js | 32 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.live.js | 3 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.train.js | 156 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 12 |
15 files changed, 296 insertions, 16 deletions
diff --git a/app/client/common/index.js b/app/client/common/index.js index 025b56c..eeb8bfc 100644 --- a/app/client/common/index.js +++ b/app/client/common/index.js @@ -8,6 +8,7 @@ import Gallery from './gallery.component' import Group from './group.component' import Header from './header.component' import Loading from './loading.component' +import NumberInput from './numberInput.component' import Param from './param.component' import ParamGroup from './paramGroup.component' import Player from './player.component' @@ -24,6 +25,7 @@ export { FolderList, FileList, FileRow, FileUpload, Gallery, Player, Group, ParamGroup, Param, - TextInput, Slider, Select, SelectGroup, Button, Checkbox, + TextInput, NumberInput, + Slider, Select, SelectGroup, Button, Checkbox, CurrentTask, }
\ No newline at end of file diff --git a/app/client/common/numberInput.component.js b/app/client/common/numberInput.component.js new file mode 100644 index 0000000..c3ad24c --- /dev/null +++ b/app/client/common/numberInput.component.js @@ -0,0 +1,49 @@ +import { h, Component } from 'preact' + +class NumberInput extends Component { + constructor(props){ + super(props) + this.state = { value: null, changed: false } + this.handleInput = this.handleInput.bind(this) + this.handleKeydown = this.handleKeydown.bind(this) + } + handleInput(e){ + this.setState({ + value: e.target.value, + changed: true, + }) + this.props.onInput && this.props.onInput(e.target.value, e.target.name) + } + handleKeydown(e){ + if (e.keyCode === 13) { + this.setState({ + value: e.target.value, + changed: false, + }) + this.props.onSave && this.props.onSave(e.target.value, e.target.name) + } + } + render() { + return ( + <div className='numberInput param'> + <label> + <span>{this.props.title}</span> + <input + type={'number'} + name={this.props.name || 'number'} + value={this.state.changed ? this.state.value : this.props.value} + onInput={this.handleInput} + onKeydown={this.handleKeydown} + placeholder={this.props.placeholder} + autofocus={this.props.autofocus} + min={this.props.min} + max={this.props.max} + step={this.props.step || this.props.type === 'int' ? 1 : 0.01} + /> + </label> + </div> + ) + } +} + +export default NumberInput diff --git a/app/client/common/textInput.component.js b/app/client/common/textInput.component.js index a3739d4..44e1349 100644 --- a/app/client/common/textInput.component.js +++ b/app/client/common/textInput.component.js @@ -12,7 +12,7 @@ class TextInput extends Component { value: e.target.value, changed: true, }) - this.props.onInput && this.props.onInput(e.target.value) + this.props.onInput && this.props.onInput(e.target.value, e.target.name) } handleKeydown(e){ if (e.keyCode === 13) { @@ -20,7 +20,7 @@ class TextInput extends Component { value: e.target.value, changed: false, }) - this.props.onSave && this.props.onSave(e.target.value) + this.props.onSave && this.props.onSave(e.target.value, e.target.name) } } render() { @@ -29,7 +29,8 @@ class TextInput extends Component { <label> <span>{this.props.title}</span> <input - type='text' + type={this.props.type || 'text'} + name={this.props.name || 'text'} value={this.state.changed ? this.state.value : this.props.value} onInput={this.handleInput} onKeydown={this.handleKeydown} diff --git a/app/client/dashboard/dashboard.actions.js b/app/client/dashboard/dashboard.actions.js index 8b5502a..c428d0b 100644 --- a/app/client/dashboard/dashboard.actions.js +++ b/app/client/dashboard/dashboard.actions.js @@ -11,7 +11,11 @@ export const load = () => (dispatch) => { actions.file.index({ module: 'morph', generated: 1, limit: 15, orderBy: 'created_at desc', }), ], (percent, i, n) => { // console.log('dashboard load progress', i, n) - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'dashboard' } + }) }).then(res => { const [ tasks, folders, samplernn, pix2pixhd, morph ] = res const { mapFn, sortFn } = util.sort.orderByFn('date desc') diff --git a/app/client/dashboard/dashboard.component.js b/app/client/dashboard/dashboard.component.js index 3c9b2de..0c15f99 100644 --- a/app/client/dashboard/dashboard.component.js +++ b/app/client/dashboard/dashboard.component.js @@ -11,7 +11,7 @@ import Button from '../common/button.component' import DashboardHeader from './dashboardheader.component' import TaskList from './tasklist.component' -import { FolderList, FileList } from '../common' +import { Loading, FolderList, FileList } from '../common' import Gallery from '../common/gallery.component' import * as dashboardActions from './dashboard.actions' @@ -22,7 +22,7 @@ import actions from '../actions' class Dashboard extends Component { constructor(props){ super() - console.log(props) + // console.log(props) props.actions.load() } componentWillUpdate(nextProps) { @@ -30,9 +30,11 @@ class Dashboard extends Component { // this.props.actions.list_epochs(nextProps.opt.checkpoint_name) } render(){ - const { site, foldersByModule, renders, queue, images } = this.props + const { loading, progress, site, foldersByModule, renders, queue, images } = this.props + if (loading) { + return <Loading progress={progress} /> + } const { tasks } = queue - console.log(foldersByModule) const folders = foldersByModule && Object.keys(modules).sort().map(key => { let path = key === 'samplernn' ? '/samplernn/datasets/' : '/' + key + '/sequences/' let folder_list = (foldersByModule[key] || []).map(folder => { @@ -99,6 +101,8 @@ class Dashboard extends Component { } } const mapStateToProps = state => ({ + loading: state.dashboard.loading, + progress: state.dashboard.progress, site: state.system.site, foldersByModule: state.dashboard.data.foldersByModule, renders: state.dashboard.data.renders, diff --git a/app/client/dashboard/dashboard.reducer.js b/app/client/dashboard/dashboard.reducer.js index 812a501..f10f3fa 100644 --- a/app/client/dashboard/dashboard.reducer.js +++ b/app/client/dashboard/dashboard.reducer.js @@ -5,6 +5,7 @@ let FileSaver = require('file-saver') const dashboardInitialState = { loading: false, + progress: null, error: null, data: {}, images: [ @@ -15,6 +16,15 @@ const dashboardInitialState = { const dashboardReducer = (state = dashboardInitialState, action) => { switch(action.type) { + case types.app.load_progress: + if (!action.data || action.data.module !== 'dashboard') { + return state + } + return { + ...state, + loading: true, + progress: action.progress, + } case types.dashboard.load: return { ...state, diff --git a/app/client/dashboard/dashboardHeader.component.js b/app/client/dashboard/dashboardHeader.component.js index 5f1306c..063cd47 100644 --- a/app/client/dashboard/dashboardHeader.component.js +++ b/app/client/dashboard/dashboardHeader.component.js @@ -23,7 +23,6 @@ class DashboardHeader extends Component { ) } renderStatus(name, gpu){ - console.log(gpu) if (gpu.status === 'IDLE') { return <div>{name} idle</div> } diff --git a/app/client/dataset/dataset.reducer.js b/app/client/dataset/dataset.reducer.js index 10b4a94..065d3da 100644 --- a/app/client/dataset/dataset.reducer.js +++ b/app/client/dataset/dataset.reducer.js @@ -8,6 +8,7 @@ import types from '../types' const datasetInitialState = () => ({ loading: true, + progress: null, error: null, data: null, folder_id: 0, diff --git a/app/client/modules/morph/morph.actions.js b/app/client/modules/morph/morph.actions.js index 04f452d..6586778 100644 --- a/app/client/modules/morph/morph.actions.js +++ b/app/client/modules/morph/morph.actions.js @@ -19,7 +19,11 @@ export const load_data = (id) => (dispatch) => { actions.socket.list_directory({ module, dir: 'renders' }), ], (percent, i, n) => { console.log('morph load progress', i, n) - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'morph' }, + }) }).then(res => { const [datasetApiReport, sequences, renders] = res const { diff --git a/app/client/modules/pix2pixhd/index.js b/app/client/modules/pix2pixhd/index.js index b33ce00..cbd3136 100644 --- a/app/client/modules/pix2pixhd/index.js +++ b/app/client/modules/pix2pixhd/index.js @@ -26,6 +26,7 @@ class router { <Route exact path='/pix2pixhd/new/' component={Pix2PixHDNew} /> <Route exact path='/pix2pixhd/sequences/' component={Pix2PixHDShow} /> <Route exact path='/pix2pixhd/sequences/:id/' component={Pix2PixHDShow} /> + <Route exact path='/pix2pixhd/train/' component={Pix2PixHDTrain} /> <Route exact path='/pix2pixhd/results/' component={Pix2PixHDResults} /> <Route exact path='/pix2pixhd/live/' component={Pix2PixHDLive} /> </section> diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js index 8e481d3..6459794 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js @@ -21,7 +21,11 @@ export const load_directories = (id) => (dispatch) => { // actions.socket.disk_usage({ module, dir: 'datasets' }), ], (percent, i, n) => { console.log('pix2pixhd load progress', i, n) - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'pix2pixhd' }, + }) }).then(res => { const [datasetApiReport, sequences, datasets, checkpoints] = res //, datasets, results, output, datasetUsage, lossReport] = res const { @@ -157,7 +161,11 @@ export const load_results = (id) => (dispatch) => { actions.socket.list_directory({ module, dir: 'renders' }), ], (percent, i, n) => { console.log('pix2pixhd load progress', i, n) - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'pix2pixhd' }, + }) }).then(res => { const [folders, files, results, renders] = res //, datasets, results, output, datasetUsage, lossReport] = res console.log(files, results, renders) diff --git a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js index f3c5342..92c0ff4 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js @@ -52,3 +52,35 @@ export const live_task = (sequence, checkpoint, opt) => dispatch => { console.log('add live task') return actions.queue.add_task(task) } + +export const augment_task = (opt) => dispatch => { + const task = { + module: module.name, + activity: 'augment', + dataset: sequence, + checkpoint, + opt: { + ...opt, + poll_delay: 0.01, + } + } + console.log(task) + console.log('add live task') + return actions.queue.add_task(task) +} + +export const clear_recursive_task = (opt) => dispatch => { + const task = { + module: module.name, + activity: 'clear_recursive', + dataset: sequence, + checkpoint, + opt: { + ...opt, + } + } + console.log(task) + console.log('add live task') + return actions.queue.add_task(task) +} + diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js index 41ff7e5..52b4b61 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js @@ -100,7 +100,7 @@ class Pix2PixHDLive extends Component { render(){ // console.log(this.props) if (this.props.pix2pixhd.loading) { - return <Loading /> + return <Loading progress={this.props.pix2pixhd.progress} /> } const { folderLookup, datasetLookup, sequences } = this.props.pix2pixhd.data @@ -140,6 +140,7 @@ class Pix2PixHDLive extends Component { options: datasets.sort(), } }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) + return ( <div className='app live centered'> <Player width={424} height={256} fullscreen={this.props.fullscreen} /> diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js new file mode 100644 index 0000000..8901ee8 --- /dev/null +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js @@ -0,0 +1,156 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import util from '../../../util' + +import * as pix2pixhdActions from '../pix2pixhd.actions' +import * as pix2pixhdTasks from '../pix2pixhd.tasks' + +import { + Loading, + FileList, FileRow, + Select, SelectGroup, Group, Button, + TextInput, + CurrentTask, TaskList +} from '../../../common' +import DatasetForm from '../../../dataset/dataset.form' +import NewDatasetForm from '../../../dataset/dataset.new' +import UploadStatus from '../../../dataset/upload.status' + +import DatasetComponent from '../../../dataset/dataset.component' + +import pix2pixhdModule from '../pix2pixhd.module' + +class Pix2PixHDTrain extends Component { + constructor(props){ + super(props) + this.handleChange = this.handleChange.bind(this) + this.state = { + sequence: '', + epoch: 'latest', + augment_take: 100, + augment_make: 20, + } + } + componentWillMount(){ + const id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id') + console.log('load dataset:', id) + const { match, pix2pixhd, actions } = this.props + if (id === 'new') return + if (id) { + if (parseInt(id)) localStorage.setItem('pix2pixhd.last_id', id) + if (! pix2pixhd.folder || pix2pixhd.folder.id !== id) { + actions.load_directories(id) + } + } else { + this.props.history.push('/pix2pixhd/new/') + } + } + handleChange(value, name){ + this.setState({ [name]: value }) + } + changeCheckpoint(name){ + // this.props.actions.list_epochs('pix2pixhd', nextProps.opt.checkpoint_name) + } + render(){ + if (this.props.pix2pixhd.loading) { + return <Loading progress={this.props.pix2pixhd.progress} /> + } + const { pix2pixhd, match, history, queue } = this.props + const { folderLookup, datasetLookup } = (pix2pixhd.data || {}) + const folder = (folderLookup || {})[pix2pixhd.folder_id] || {} + console.log(pix2pixhd) + + const checkpointGroups = Object.keys(folderLookup).map(id => { + const folder = this.props.pix2pixhd.data.folderLookup[id] + if (folder.name === 'results') return + const datasets = folder.datasets.map(name => { + const dataset = datasetLookup[name] + if (dataset.checkpoints.length) { + return name + } + return null + }).filter(n => !!n) + return { + name: folder.name, + options: datasets.sort(), + } + }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) + + return ( + <div className='app pix2pixhd'> + <h1>pix2pixhd training</h1> + <div class='heading'> + <SelectGroup live + name='checkpoint_name' + title='Checkpoint' + options={checkpointGroups} + onChange={this.changeCheckpoint} + /> + <Select + title="Epoch" + value={this.state.epoch} + /> + <br/> + <Group title='Augment'> + <TextInput + type="number" + name="augment_take" + title="Pick N random frames" + value={this.state.augment_take} + onInput={this.handleChange} + /> + <TextInput + type="number" + name="augment_make" + title="Generate N recursively" + value={this.state.augment_make} + onInput={this.handleChange} + /> + <Button + title="Augment dataset" + value="Augment" + onClick={() => remote.augment_task(dataset, pix2pixhd.folder_id, 1)} + /> + </Group> + + <Group title='Train'> + <Button + title="Train one epoch" + value="Train" + onClick={() => remote.train_task(dataset, pix2pixhd.folder_id, 1)} + /> + </Group> + + <Group title='Clear'> + <Button + title="Delete recursive frames" + value="Clear" + onClick={() => remote.clear_recursive_task(dataset, pix2pixhd.folder_id, 1)} + /> + </Group> + </div> + <div> + <CurrentTask /> + {!!queue.queue.length && + <Group title='Upcoming Tasks'> + <TaskList tasks={queue.queue.map(id => queue.tasks[id])} /> + </Group> + } + </div> + </div> + ) + } +} + +const mapStateToProps = state => ({ + pix2pixhd: state.module.pix2pixhd, + queue: state.queue, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(pix2pixhdActions, dispatch), + remote: bindActionCreators(pix2pixhdTasks, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(Pix2PixHDTrain) diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index f4f7a6d..e4de1dd 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -21,7 +21,11 @@ export const load_directories = (id) => (dispatch) => { actions.socket.disk_usage({ module, dir: 'datasets' }), load_loss()(dispatch), ], (percent, i, n) => { - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'samplernn' }, + }) }).then(res => { // console.log(res) const [datasetApiReport, datasets, results, output, datasetUsage, lossReport] = res @@ -128,7 +132,11 @@ export const load_graph = () => dispatch => { load_loss()(dispatch), actions.socket.list_directory({ module, dir: 'results' }), ], (percent, i, n) => { - dispatch({ type: types.app.load_progress, progress: { i, n }}) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'samplernn' }, + }) }).then(res => { const [lossReport, results] = res dispatch({ |
