diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/live/player.js | 6 | ||||
| -rw-r--r-- | app/client/modules/module.reducer.js | 2 | ||||
| -rw-r--r-- | app/client/modules/pix2pix/pix2pix.actions.js | 1 | ||||
| -rw-r--r-- | app/client/modules/pix2pix/views/pix2pix.live.js | 79 | ||||
| -rw-r--r-- | app/client/system/system.reducer.js | 4 |
5 files changed, 54 insertions, 38 deletions
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} /> <Select name='sequence_name' @@ -267,17 +267,29 @@ class Pix2PixLive extends Component { } if (! this.props.opt.processing) { return ( - <Button - title={'Not processing'} - onClick={this.togglePlaying} - >Restart</Button> + <div> + <Button + title={'Not processing'} + onClick={this.togglePlaying} + >Restart</Button> + <Button + title={'GPU Busy'} + onClick={() => this.interrupt()} + >Interrupt</Button> + </div> ) } return ( - <Button - title={'Processing'} - onClick={this.togglePlaying} - >Pause</Button> + <div> + <Button + title={'Processing'} + onClick={this.togglePlaying} + >Pause</Button> + <Button + title={'GPU Busy'} + onClick={() => this.interrupt()} + >Interrupt</Button> + </div> ) } } @@ -295,9 +307,12 @@ const mapStateToProps = state => ({ }) const mapDispatchToProps = (dispatch, ownProps) => ({ - actions: bindActionCreators(liveActions, dispatch), - pix2pixActions: bindActionCreators(pix2pixActions, dispatch), - pix2pixTasks: bindActionCreators(pix2pixTasks, dispatch),s + actions: { + live: bindActionCreators(liveActions, dispatch), + queue: bindActionCreators(queueActions, dispatch), + pix2pix: bindActionCreators(pix2pixActions, dispatch), + tasks: bindActionCreators(pix2pixTasks, dispatch),s + } }) export default connect(mapStateToProps, mapDispatchToProps)(Pix2PixLive) diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index a0cfb8c..b1a12c0 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -10,7 +10,7 @@ const systemInitialState = { name: 'loading', }, app: { - tool: 'samplernn', + tool: 'pix2pix', }, server: { connected: false, @@ -43,7 +43,7 @@ const systemInitialState = { stderr: "", } -const modules = ['samplernn','pix2pix','pix2wav'].reduce((a,b) => (a[b]=b,a),{}) +const modules = ['pix2pix','samplernn','pix2wav'].reduce((a,b) => (a[b]=b,a),{}) const systemReducer = (state = systemInitialState, action) => { let processor = null |
