From 47d9658375fc2003a69d51c663b182c3baf8a9c6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 7 Jun 2018 10:13:27 +0200 Subject: switching epochs working again --- app/client/live/player.js | 6 +- app/client/modules/module.reducer.js | 2 +- app/client/modules/pix2pix/pix2pix.actions.js | 1 + app/client/modules/pix2pix/views/pix2pix.live.js | 79 ++++++++++++++---------- app/client/system/system.reducer.js | 4 +- 5 files changed, 54 insertions(+), 38 deletions(-) (limited to 'app/client') diff --git a/app/client/live/player.js b/app/client/live/player.js index 37f7cab..facd032 100644 --- a/app/client/live/player.js +++ b/app/client/live/player.js @@ -37,13 +37,13 @@ export function onFrame (data) { const blob = new Blob([data.frame], { type: 'image/jpg' }) const url = URL.createObjectURL(blob) const img = new Image () + let canvas = document.querySelector('.player canvas') + if (! canvas) return console.error('no canvas for frame') img.onload = () => { img.onload = null last_frame = data.meta URL.revokeObjectURL(url) - let canvas = document.querySelector('.player canvas') - if (! canvas) return console.error('no canvas for frame') - const ctx = canvas.getContext('2d') + const ctx = canvas.getContext('2d-lodpi') ctx.drawImage(img, 0, 0, canvas.width, canvas.height) if (recording) { console.log('record frame') diff --git a/app/client/modules/module.reducer.js b/app/client/modules/module.reducer.js index 0ee6d75..a232372 100644 --- a/app/client/modules/module.reducer.js +++ b/app/client/modules/module.reducer.js @@ -5,7 +5,7 @@ import pix2wavReducer from './pix2wav/pix2wav.reducer' import samplernnReducer from './samplernn/samplernn.reducer' export const moduleReducer = combineReducers({ - pix2wav: pix2wavReducer, pix2pix: pix2pixReducer, + pix2wav: pix2wavReducer, samplernn: samplernnReducer }) diff --git a/app/client/modules/pix2pix/pix2pix.actions.js b/app/client/modules/pix2pix/pix2pix.actions.js index d8fde65..69572ea 100644 --- a/app/client/modules/pix2pix/pix2pix.actions.js +++ b/app/client/modules/pix2pix/pix2pix.actions.js @@ -20,6 +20,7 @@ export const load_directories = (id) => (dispatch) => { actions.socket.list_directory({ module, dir: 'checkpoints/pix2pix/' }), // actions.socket.disk_usage({ module, dir: 'datasets' }), ], (percent, i, n) => { + console.log('pix2pix load progress', i, n) dispatch({ type: types.app.load_progress, progress: { i, n }}) }).then(res => { // console.log(res) diff --git a/app/client/modules/pix2pix/views/pix2pix.live.js b/app/client/modules/pix2pix/views/pix2pix.live.js index 52fe055..ae68307 100644 --- a/app/client/modules/pix2pix/views/pix2pix.live.js +++ b/app/client/modules/pix2pix/views/pix2pix.live.js @@ -10,18 +10,19 @@ import { import { startRecording, stopRecording, saveFrame } from '../../../live/player' import * as liveActions from '../../../live/live.actions' +import * as queueActions from '../../../queue/queue.actions' import * as pix2pixTasks from '../pix2pix.tasks' import * as pix2pixActions from '../pix2pix.actions' class Pix2PixLive extends Component { constructor(props){ super() - if (! props.pix2pix || ! props.pix2pix.data) { - props.pix2pixActions.load_directories() - } - props.actions.get_params() - props.actions.list_checkpoints('pix2pix') - props.actions.list_sequences('pix2pix') + // if (! props.pix2pix || ! props.pix2pix.data) { + props.actions.pix2pix.load_directories() + // } + props.actions.live.get_params() + props.actions.live.list_checkpoints('pix2pix') + props.actions.live.list_sequences('pix2pix') this.changeCheckpoint = this.changeCheckpoint.bind(this) this.changeEpoch = this.changeEpoch.bind(this) this.changeSequence = this.changeSequence.bind(this) @@ -31,45 +32,44 @@ class Pix2PixLive extends Component { } componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { - this.props.actions.list_epochs('pix2pix', nextProps.opt.checkpoint_name) + this.props.actions.live.list_epochs('pix2pix', nextProps.opt.checkpoint_name) } } - changeCheckpoint(checkpoint_name){ - this.props.actions.load_epoch(checkpoint_name, 'latest') + changeCheckpoint(field, checkpoint_name){ + this.props.actions.live.load_epoch(checkpoint_name, 'latest') } - changeEpoch(epoch_name){ - this.props.actions.load_epoch(this.props.opt.checkpoint_name, epoch_name) + changeEpoch(field, epoch_name){ + this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name) } - changeSequence(sequence){ + changeSequence(field, sequence){ console.log('got sequence', sequence) - this.props.actions.load_sequence(sequence) + this.props.actions.live.load_sequence(sequence) } seek(percentage){ const frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1) - this.props.actions.seek(frame) + this.props.actions.live.seek(frame) } start(){ // console.log(this.props) const sequence = this.props.pix2pix.data.sequences[0].name const checkpoint = this.props.pix2pix.data.checkpoints[0].name console.log('starting up!', sequence, checkpoint) - this.props.pix2pixTasks.live_task(sequence, checkpoint) + this.props.actions.tasks.live_task(sequence, checkpoint) } interrupt(){ - // + this.props.actions.queue.stop_task('gpu') } togglePlaying(){ - console.log('are we..........', this.props.opt.processing) if (this.props.opt.processing) { - this.props.actions.pause() + this.props.actions.live.pause() } else { - this.props.actions.play() + this.props.actions.live.play() } } toggleRecording(){ if (this.props.opt.recording){ stopRecording() - this.props.actions.pause() + this.props.actions.live.pause() } else { startRecording() } @@ -92,7 +92,7 @@ class Pix2PixLive extends Component { name='send_image' title='view mode' options={['a','b','sequence','recursive']} - onChange={this.props.actions.set_param} + onChange={this.props.actions.live.set_param} />