summaryrefslogtreecommitdiff
path: root/app/client/modules/biggan/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/modules/biggan/views')
-rw-r--r--app/client/modules/biggan/views/biggan.live.js180
1 files changed, 180 insertions, 0 deletions
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)