From fe8ab6133a31284d94944f5d75da9d6ad2b2bdb9 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 18 Dec 2019 21:13:05 +0100 Subject: adding biggan --- app/client/modules/biggan/biggan.actions.js | 12 ++ app/client/modules/biggan/biggan.module.js | 7 + app/client/modules/biggan/biggan.reducer.js | 43 +++++ app/client/modules/biggan/biggan.tasks.js | 20 +++ app/client/modules/biggan/index.js | 37 +++++ app/client/modules/biggan/views/biggan.live.js | 180 +++++++++++++++++++++ app/client/modules/index.js | 3 +- app/client/modules/module.reducer.js | 2 + .../modules/pix2pixhd/views/pix2pixhd.live.js | 2 +- 9 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 app/client/modules/biggan/biggan.actions.js create mode 100644 app/client/modules/biggan/biggan.module.js create mode 100644 app/client/modules/biggan/biggan.reducer.js create mode 100644 app/client/modules/biggan/biggan.tasks.js create mode 100644 app/client/modules/biggan/index.js create mode 100644 app/client/modules/biggan/views/biggan.live.js (limited to 'app/client/modules') diff --git a/app/client/modules/biggan/biggan.actions.js b/app/client/modules/biggan/biggan.actions.js new file mode 100644 index 0000000..188a0d8 --- /dev/null +++ b/app/client/modules/biggan/biggan.actions.js @@ -0,0 +1,12 @@ +import uuidv1 from 'uuid/v1' + +import socket from '../../socket' +import types from '../../types' + +import * as datasetLoader from '../../dataset/dataset.loader' + +import actions from '../../actions' + +import util from '../../util' + +import bigganModule from './biggan.module' diff --git a/app/client/modules/biggan/biggan.module.js b/app/client/modules/biggan/biggan.module.js new file mode 100644 index 0000000..6407f61 --- /dev/null +++ b/app/client/modules/biggan/biggan.module.js @@ -0,0 +1,7 @@ +const bigganModule = { + name: 'biggan', + displayName: 'BigGAN', + datatype: 'video', +} + +export default bigganModule diff --git a/app/client/modules/biggan/biggan.reducer.js b/app/client/modules/biggan/biggan.reducer.js new file mode 100644 index 0000000..a0c9842 --- /dev/null +++ b/app/client/modules/biggan/biggan.reducer.js @@ -0,0 +1,43 @@ +import types from '../../types' +import datasetReducer from '../../dataset/dataset.reducer' + +const bigganInitialState = { + loading: true, + progress: { i: 0, n: 0 }, + error: null, + folder_id: 0, + data: null, + results: null, + checkpoint: { + name: '', + sequenceCount: 0, + datasetCount: 0, + } +} + +const bigganReducer = (state = bigganInitialState, action) => { + if (action.data && action.data.module === 'biggan') { + state = datasetReducer(state, action) + } + + switch (action.type) { + case types.biggan.load_results: + return { + ...state, + results: action.results, + } + case types.file.destroy: + console.log('file destroy', state.results) + return { + ...state, + results: { + ...state.results, + files: state.results.files.filter(f => f.id !== action.data.id) + } + } + default: + return state + } +} + +export default bigganReducer diff --git a/app/client/modules/biggan/biggan.tasks.js b/app/client/modules/biggan/biggan.tasks.js new file mode 100644 index 0000000..827add5 --- /dev/null +++ b/app/client/modules/biggan/biggan.tasks.js @@ -0,0 +1,20 @@ +import uuidv1 from 'uuid/v1' + +import socket from '../../socket' +import types from '../../types' + +import actions from '../../actions' + +import module from './biggan.module' + +export const live_task = (opt) => dispatch => { + const task = { + module: module.name, + activity: 'live', + dataset: 'biggan', + opt + } + console.log(task) + console.log('add live task') + return actions.queue.add_task(task) +} diff --git a/app/client/modules/biggan/index.js b/app/client/modules/biggan/index.js new file mode 100644 index 0000000..6c94008 --- /dev/null +++ b/app/client/modules/biggan/index.js @@ -0,0 +1,37 @@ +import { h, Component } from 'preact' +import { Route, Link } from 'react-router-dom' + +import actions from '../../actions' + +import util from '../../util' + +import BigGANLive from './views/biggan.live' + +class router { + componentWillMount(){ + actions.system.changeTool('biggan') + document.body.style.backgroundImage = 'linear-gradient(' + (util.randint(40)+40) + 'deg, #dfe, #def)' + } + componentWillReceiveProps(){ + actions.system.changeTool('biggan') + document.body.style.backgroundImage = 'linear-gradient(' + (util.randint(40)+40) + 'deg, #dfe, #def)' + } + render(){ + return ( +
+ +
+ ) + } +} + +function links(){ + return [ + { url: '/biggan/live/', name: 'live' }, + ] +} + +export default { + name: 'biggan', + router, links, +} diff --git a/app/client/modules/biggan/views/biggan.live.js b/app/client/modules/biggan/views/biggan.live.js new file mode 100644 index 0000000..ba96ff2 --- /dev/null +++ b/app/client/modules/biggan/views/biggan.live.js @@ -0,0 +1,180 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import { + ParamGroup, Param, Player, Group, + Slider, SelectGroup, Select, TextInput, Button, Loading +} from '../../../common/' + +import { startRecording, stopRecording, saveFrame, toggleFPS } from '../../../live/player' + +import * as liveActions from '../../../live/live.actions' +import * as queueActions from '../../../queue/queue.actions' +import * as bigganTasks from '../biggan.tasks' +import * as bigganActions from '../biggan.actions' + +class BigGANLive extends Component { + constructor(props) { + super() + } + start(){ + console.log(this.props.opt) + console.log('starting up!') + this.props.actions.tasks.live_task({ + folder_id: this.props.biggan.data.resultsFolder.id, + }) + } + interrupt(){ + this.props.actions.queue.stop_task('gpu') + } + render() { + const { biggan } = this.props + // if (biggan.loading) { + // return + // } + return ( +
+
+
+ +
+
+ + {this.renderRestartButton()} + + + + + + + + + + + + + + + + + + + + +
+
+
+ ) + } + renderRestartButton(){ + // console.log(this.props.runner.gpu) + const { i18n } = this.props + if (this.props.runner.gpu.status === 'IDLE') { + return ( + + ) + } + if (this.props.runner.gpu.task.module !== 'pix2pixhd') { + return ( + + ) + } + if (! this.props.opt.processing) { + return ( +
+ + +
+ ) + } + return ( +
+ + +
+ ) + } +} + + +const mapStateToProps = state => ({ + last_message: state.live.last_message, + fullscreen: state.live.fullscreen, + opt: state.live.opt, + frame: state.live.frame, + runner: state.system.runner, + i18n: state.system.i18n.strings, + biggan: state.module.biggan, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: { + live: bindActionCreators(liveActions, dispatch), + queue: bindActionCreators(queueActions, dispatch), + biggan: bindActionCreators(bigganActions, dispatch), + tasks: bindActionCreators(bigganTasks, dispatch), + } +}) + +export default connect(mapStateToProps, mapDispatchToProps)(BigGANLive) diff --git a/app/client/modules/index.js b/app/client/modules/index.js index 14a2333..ad574bb 100644 --- a/app/client/modules/index.js +++ b/app/client/modules/index.js @@ -1,3 +1,4 @@ +import biggan from './biggan' import morph from './morph' import pix2pix from './pix2pix' import pix2pixhd from './pix2pixhd' @@ -5,5 +6,5 @@ import pix2wav from './pix2wav' import samplernn from './samplernn' export default { - morph, pix2pix, pix2pixhd, pix2wav, samplernn + biggan, morph, pix2pix, pix2pixhd, pix2wav, samplernn } diff --git a/app/client/modules/module.reducer.js b/app/client/modules/module.reducer.js index ff977ce..979c70a 100644 --- a/app/client/modules/module.reducer.js +++ b/app/client/modules/module.reducer.js @@ -1,5 +1,6 @@ import { combineReducers } from 'redux' +import bigganReducer from './biggan/biggan.reducer' import morphReducer from './morph/morph.reducer' import pix2pixReducer from './pix2pix/pix2pix.reducer' import pix2pixhdReducer from './pix2pixhd/pix2pixhd.reducer' @@ -7,6 +8,7 @@ import pix2wavReducer from './pix2wav/pix2wav.reducer' import samplernnReducer from './samplernn/samplernn.reducer' export const moduleReducer = combineReducers({ + biggan: bigganReducer, morph: morphReducer, pix2pix: pix2pixReducer, pix2pixhd: pix2pixhdReducer, diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js index ee7ece7..2216cf7 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js @@ -496,7 +496,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({ live: bindActionCreators(liveActions, dispatch), queue: bindActionCreators(queueActions, dispatch), pix2pixhd: bindActionCreators(pix2pixhdActions, dispatch), - tasks: bindActionCreators(pix2pixhdTasks, dispatch),s + tasks: bindActionCreators(pix2pixhdTasks, dispatch), } }) -- cgit v1.2.3-70-g09d2