From 0717df361a510e0ce02a4e8cb00796a4b897f02f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 24 Sep 2018 00:36:21 +0200 Subject: check if dataset is generated --- app/client/modules/pix2pixhd/pix2pixhd.actions.js | 8 +-- .../modules/pix2pixhd/views/pix2pixhd.train.js | 66 ++++++++++++++-------- .../modules/pix2pixhd/views/sequence.editor.js | 29 +++------- 3 files changed, 54 insertions(+), 49 deletions(-) (limited to 'app') diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js index 44a42c4..d067017 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js @@ -202,11 +202,11 @@ export const list_epochs = (checkpoint_name) => (dispatch) => { }) } -export const count_dataset = (checkpoint_name) => (dispatch) => { +export const count_dataset = (dataset) => (dispatch) => { const module = pix2pixhdModule.name util.allProgress([ - actions.socket.list_directory({ module, dir: 'sequences/' + checkpoint_name + '/' }), - actions.socket.count_directory({ module, dir: 'datasets/' + checkpoint_name + '/train_A/' }), + actions.socket.list_directory({ module, dir: 'sequences/' + dataset + '/' }), + actions.socket.count_directory({ module, dir: 'datasets/' + dataset + '/train_A/' }), ], (percent, i, n) => { console.log('pix2pixhd load progress', i, n) // dispatch({ @@ -221,7 +221,7 @@ export const count_dataset = (checkpoint_name) => (dispatch) => { dispatch({ type: types.pix2pixhd.load_dataset_count, data: { - name: checkpoint_name, + name: dataset, sequence, sequenceCount, datasetCount, diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js index c5e8e67..de32fcd 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js @@ -24,16 +24,17 @@ import SequenceEditor from './sequence.editor' import pix2pixhdModule from '../pix2pixhd.module' class Pix2PixHDTrain extends Component { + state = { + dataset: 'PLACEHOLDER', + epoch: 'latest', + augment_name: '', + augment_take: 100, + augment_make: 20, + generated: false, + } constructor(props){ super(props) this.handleChange = this.handleChange.bind(this) - this.state = { - checkpoint_name: 'PLACEHOLDER', - epoch: 'latest', - augment_name: '', - augment_take: 100, - augment_make: 20, - } } componentDidMount(){ const id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id') @@ -50,15 +51,30 @@ class Pix2PixHDTrain extends Component { this.props.history.push('/pix2pixhd/new/') } if (dataset) { - this.setState({ checkpoint_name: dataset }) + this.setState({ dataset }) } } componentDidUpdate(prevProps, prevState){ - if (prevState.checkpoint_name !== this.state.checkpoint_name) { - localStorage.setItem('pix2pixhd.last_dataset', this.state.checkpoint_name) - this.setState({ epoch: 'latest' }) - this.props.actions.list_epochs(this.state.checkpoint_name) - this.props.actions.count_dataset(this.state.checkpoint_name) + if ((!prevProps.pix2pixhd.data && this.props.pix2pixhd.data) + || (prevProps.pix2pixhd.data && prevState.dataset !== this.state.dataset)) { + const dataset = this.props.pix2pixhd.data.datasetLookup[this.state.dataset] + if (dataset) { + const generated = dataset.input + .map(f => this.props.pix2pixhd.data.fileLookup[f]) + .reduce((a,b) => { + return b.generated || a + }, false) + dataset.generated = generated + this.setState({ generated }) + } + } + if (prevState.dataset !== this.state.dataset) { + localStorage.setItem('pix2pixhd.last_dataset', this.state.dataset) + this.setState({ + epoch: 'latest', + }) + this.props.actions.list_epochs(this.state.dataset) + this.props.actions.count_dataset(this.state.dataset) } } handleChange(name, value){ @@ -78,7 +94,7 @@ class Pix2PixHDTrain extends Component { const { checkpoint } = pix2pixhd // console.log(pix2pixhd) - const checkpointGroups = Object.keys(folderLookup).map(id => { + const sequenceGroups = Object.keys(folderLookup).map(id => { const folder = this.props.pix2pixhd.data.folderLookup[id] if (folder.name === 'results') return const datasets = folder.datasets.map(name => { @@ -95,7 +111,7 @@ class Pix2PixHDTrain extends Component { }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) // console.log('state', this.props.pix2pixhd.data.epochs) - // console.log(this.state.checkpoint_name, this.state.epoch) + // console.log(this.state.dataset, this.state.epoch) // console.log(queue) return (
@@ -106,12 +122,12 @@ class Pix2PixHDTrain extends Component {