summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/client/modules/biggan/biggan.actions.js12
-rw-r--r--app/client/modules/biggan/biggan.module.js7
-rw-r--r--app/client/modules/biggan/biggan.reducer.js43
-rw-r--r--app/client/modules/biggan/biggan.tasks.js20
-rw-r--r--app/client/modules/biggan/index.js37
-rw-r--r--app/client/modules/biggan/views/biggan.live.js180
-rw-r--r--app/client/modules/index.js3
-rw-r--r--app/client/modules/module.reducer.js2
-rw-r--r--app/client/modules/pix2pixhd/views/pix2pixhd.live.js2
-rw-r--r--app/client/types.js3
-rw-r--r--app/relay/modules/biggan.js21
-rw-r--r--app/relay/modules/index.js2
12 files changed, 330 insertions, 2 deletions
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 (
+ <section>
+ <Route exact path='/biggan/live/' component={BigGANLive} />
+ </section>
+ )
+ }
+}
+
+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 <Loading progress={biggan.progress} />
+ // }
+ return (
+ <div className='app live centered'>
+ <div className='row'>
+ <div className='column'>
+ <Player width={512} height={512} fullscreen={this.props.fullscreen} />
+ </div>
+ <div className='params column audioParams'>
+ <Group>
+ {this.renderRestartButton()}
+ </Group>
+
+ <ParamGroup
+ title={"Latent"}
+ name='latent'
+ >
+ <Button
+ title={"Shuffle"}
+ onClick={() => {}}
+ >{"Latent"}</Button>
+ <Slider live
+ name='latent_update_speed'
+ title={"Update Speed"}
+ min={0} max={1} type='float'
+ />
+ </ParamGroup>
+
+ <ParamGroup
+ title={"Label"}
+ name='label'
+ >
+ <Slider live
+ name='label_class_count'
+ title={"Classes"}
+ min={1} max={10} type='int'
+ />
+ <Button
+ title={"Shuffle"}
+ onClick={() => {}}
+ >{"Label"}</Button>
+ <Slider live
+ name='label_lerp_speed'
+ title={"Interpolation Speed"}
+ min={0} max={1} type='float'
+ />
+ </ParamGroup>
+
+ <ParamGroup
+ title={"Orbit"}
+ name='orbit'
+ >
+ <Slider live
+ name='orbit_speed'
+ title={"Orbit speed"}
+ min={0} max={1} type='float'
+ />
+ <Slider live
+ name='orbit_scale'
+ title={"Radius"}
+ min={0} max={0.25} type='float'
+ />
+ <Button
+ title={"Noise"}
+ onClick={() => {}}
+ >{"Spin"}</Button>
+ <Slider live
+ name='orbit_update_speed'
+ title={"Update Speed"}
+ min={0} max={1} type='float'
+ />
+ </ParamGroup>
+
+ </div>
+ </div>
+ </div>
+ )
+ }
+ renderRestartButton(){
+ // console.log(this.props.runner.gpu)
+ const { i18n } = this.props
+ if (this.props.runner.gpu.status === 'IDLE') {
+ return (
+ <Button
+ title={i18n.gpu.idle}
+ onClick={() => this.start()}
+ >{i18n.gpu.start}</Button>
+ )
+ }
+ if (this.props.runner.gpu.task.module !== 'pix2pixhd') {
+ return (
+ <Button
+ title={i18n.gpu.busy}
+ onClick={() => this.interrupt()}
+ >{i18n.gpu.interrupt}</Button>
+ )
+ }
+ if (! this.props.opt.processing) {
+ return (
+ <div>
+ <Button
+ title={i18n.gpu.not_processing}
+ onClick={this.togglePlaying}
+ >{i18n.gpu.restart}</Button>
+ <Button
+ title={i18n.gpu.busy}
+ onClick={() => this.interrupt()}
+ >{i18n.gpu.interrupt}</Button>
+ </div>
+ )
+ }
+ return (
+ <div>
+ <Button
+ title={i18n.gpu.processing}
+ onClick={this.togglePlaying}
+ >{i18n.gpu.stop}</Button>
+ <Button
+ title={i18n.gpu.busy}
+ onClick={() => this.interrupt()}
+ >{i18n.gpu.interrupt}</Button>
+ </div>
+ )
+ }
+}
+
+
+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),
}
})
diff --git a/app/client/types.js b/app/client/types.js
index cd82334..f25067b 100644
--- a/app/client/types.js
+++ b/app/client/types.js
@@ -116,6 +116,9 @@ export default {
// reset checkpoint settings
// queue new checkpoint
},
+ biggan: with_type('biggan', [
+ 'init', 'set_folder', 'load_results',
+ ]),
pix2pix: with_type('pix2pix', [
'init', 'set_folder'
]),
diff --git a/app/relay/modules/biggan.js b/app/relay/modules/biggan.js
new file mode 100644
index 0000000..4a03117
--- /dev/null
+++ b/app/relay/modules/biggan.js
@@ -0,0 +1,21 @@
+import path from 'path'
+import fs from 'fs'
+
+const name = 'biggan'
+const cwd = process.env.BIGGAN_CWD || path.join(process.env.HOME, 'code/' + name + '/')
+const live = {
+ type: 'pytorch',
+ script: 'live.py',
+ params: (task) => {
+ console.log(task)
+ const opt = task.opt || {}
+ return []
+ }
+}
+
+export default {
+ name, cwd, env,
+ activities: {
+ live,
+ }
+}
diff --git a/app/relay/modules/index.js b/app/relay/modules/index.js
index 2cbd08a..57b144e 100644
--- a/app/relay/modules/index.js
+++ b/app/relay/modules/index.js
@@ -1,3 +1,4 @@
+import biggan from './biggan'
import morph from './morph'
import pix2pix from './pix2pix'
import pix2pixhd from './pix2pixhd'
@@ -7,6 +8,7 @@ import test from './test'
// audio style transfer
// cyclegan
export default {
+ biggan,
morph,
pix2pix,
pix2wav: pix2pix,