summaryrefslogtreecommitdiff
path: root/app/client/modules/pix2pixhd
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-09-22 10:47:50 -0400
committerJules <jules@asdf.us>2018-09-22 10:47:50 -0400
commit7e39114e27520e382f26368ae8f4d08ae7f3071b (patch)
tree01e7f210b0c3a119622e92d56d01f5c7951ad631 /app/client/modules/pix2pixhd
parent46889933fd9c36c527014410823e88a7d838d239 (diff)
parent8d1c19852fcce52e369978dfc195d5da4f12180a (diff)
merge
Diffstat (limited to 'app/client/modules/pix2pixhd')
-rw-r--r--app/client/modules/pix2pixhd/pix2pixhd.actions.js6
-rw-r--r--app/client/modules/pix2pixhd/views/pix2pixhd.train.js24
-rw-r--r--app/client/modules/pix2pixhd/views/sequence.editor.js177
3 files changed, 143 insertions, 64 deletions
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js
index a17eeab..2c72f06 100644
--- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js
+++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js
@@ -205,7 +205,7 @@ export const list_epochs = (checkpoint_name) => (dispatch) => {
export const count_dataset = (checkpoint_name) => (dispatch) => {
const module = pix2pixhdModule.name
util.allProgress([
- actions.socket.count_directory({ module, dir: 'sequences/' + checkpoint_name + '/' }),
+ actions.socket.list_directory({ module, dir: 'sequences/' + checkpoint_name + '/' }),
actions.socket.count_directory({ module, dir: 'datasets/' + checkpoint_name + '/train_A/' }),
], (percent, i, n) => {
console.log('pix2pixhd load progress', i, n)
@@ -215,12 +215,14 @@ export const count_dataset = (checkpoint_name) => (dispatch) => {
data: { module: 'pix2pixhd' },
})
}).then(res => {
- const [sequenceCount, datasetCount] = res //, datasets, results, output, datasetUsage, lossReport] = res
+ const [sequence, datasetCount] = res //, datasets, results, output, datasetUsage, lossReport] = res
+ const sequenceCount = sequence.length
console.log(sequenceCount, datasetCount)
dispatch({
type: types.pix2pixhd.load_dataset_count,
data: {
name: checkpoint_name,
+ sequence,
sequenceCount,
datasetCount,
}
diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js
index 957b068..6aade36 100644
--- a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js
+++ b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js
@@ -19,6 +19,7 @@ import NewDatasetForm from '../../../dataset/dataset.new'
import UploadStatus from '../../../dataset/upload.status'
import DatasetComponent from '../../../dataset/dataset.component'
+import SequenceEditor from './sequence.editor'
import pix2pixhdModule from '../pix2pixhd.module'
@@ -34,9 +35,10 @@ class Pix2PixHDTrain extends Component {
augment_make: 20,
}
}
- componentWillMount(){
+ componentDidMount(){
const id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id')
- console.log('load dataset:', id)
+ const dataset = localStorage.getItem('pix2pixhd.last_dataset')
+ console.log('load dataset:', id, dataset)
const { match, pix2pixhd, actions } = this.props
if (id === 'new') return
if (id) {
@@ -47,9 +49,13 @@ class Pix2PixHDTrain extends Component {
} else {
this.props.history.push('/pix2pixhd/new/')
}
+ if (dataset) {
+ this.setState({ checkpoint_name: dataset })
+ }
}
componentDidUpdate(prevProps, prevState){
if (prevState.checkpoint_name !== this.state.checkpoint_name) {
+ localStorage.setItem('pix2pixhd.last_dataset', this.state.checkpoint_name)
this.setState({ epoch: 'latest' })
this.props.actions.list_epochs(this.state.checkpoint_name)
this.props.actions.count_dataset(this.state.checkpoint_name)
@@ -114,6 +120,18 @@ class Pix2PixHDTrain extends Component {
value={this.state.epoch}
/>
</Group>
+ </div>
+ </div>
+ <div>
+ <Group title='Sequence Editor'>
+ <SequenceEditor
+ module={pix2pixhdModule}
+ checkpoint={this.props.pix2pixhd.checkpoint}
+ />
+ </Group>
+ </div>
+ <div className='columns'>
+ <div className='column'>
<Group title='Augmentation Grid'>
<AugmentationGrid
checkpoint={this.props.pix2pixhd.checkpoint}
@@ -132,7 +150,7 @@ class Pix2PixHDTrain extends Component {
this.props.remote.augment_task(this.state.checkpoint_name, {
...this.state,
augment_take: 10,
- augment_make: 150,
+ augment_make: 149,
no_symlinks: true,
mov: true,
folder_id: this.props.pix2pixhd.data.resultsFolder.id
diff --git a/app/client/modules/pix2pixhd/views/sequence.editor.js b/app/client/modules/pix2pixhd/views/sequence.editor.js
index 9693805..6a5da39 100644
--- a/app/client/modules/pix2pixhd/views/sequence.editor.js
+++ b/app/client/modules/pix2pixhd/views/sequence.editor.js
@@ -3,78 +3,137 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Route, Link } from 'react-router-dom'
-import { Loading, FileList, FileViewer } from '../../common'
+import { Loading, FileList, FileViewer } from '../../../common'
-import actions from '../actions'
+import actions from '../../../actions'
+
+const initialState = {
+ dir: '/',
+ frameA: null,
+ frameB: null,
+ selection: null,
+ loading: true
+}
+
+/*
+ when the sequence editor loads,
+ reset the selection
+ reset the two frames
+ set the two frames to the beginning and end of the video
+ when mousing over the video
+ ideally you would see a tiny thumbnail preview of the frame :)
+ - click to start a selection, drag over, mouseup to end the selection
+ this should update the start/end frame
+ ...
+ so there are two things you could do with this
+ 1) create an entirely new dataset
+ 2) add frames to an existing dataset
+ ...
+ method 1)
+ - requires minimal setup, just a server script which..
+ - creates the new sequence folder
+ - symlinks the frames
+ - runs build_dataset
+ - create appropriate file object, using parent dataset's folder_id
+ - enqueue initial training
+ ---> we can then train on basic subsets, with more control, like we do already...
+ - tell parent dataset thing the new sequence name
+ ...
+ method 2)
+ - requires sequence editor to be aware of its own dataset
+ - requires sequence editor to know whether a sequence is original or not
+*/
class SequenceEditor extends Component {
- state = {
- dir: '/',
- files: [],
- loading: true
+ state = { ...initialState }
+
+ constructor() {
+ super()
+ this.handleMouseDown = this.handleMouseDown.bind(this)
+ this.handleMouseMove = this.handleMouseMove.bind(this)
+ this.handleMouseEnter = this.handleMouseEnter.bind(this)
+ this.handleMouseLeave = this.handleMouseLeave.bind(this)
+ this.handleMouseUp = this.handleMouseUp.bind(this)
}
+
componentDidMount() {
- this.fetch(this.state.dir)
+ const { checkpoint } = this.props
+ window.addEventListener('mousemove', this.handleMouseMove)
+ window.addEventListener('mouseup', this.handleMouseUp)
+ if (checkpoint && checkpoint.sequence) {
+ console.log(checkpoint)
+ const frameA = checkpoint.sequence[0]
+ const frameB = checkpoint.sequence[checkpoint.sequence.length-1]
+ this.setState({
+ ...initialState,
+ frameA,
+ frameB,
+ })
+ }
}
- handlePick(file) {
- console.log(file)
- if (file.dir) {
- this.fetch([this.state.dir, file.name].join('/').replace('//','/'))
- } else {
- this.fetchFile([this.state.dir, file.name].join('/').replace('//','/'))
+
+ componentDidUpdate(prevProps) {
+ const { checkpoint } = this.props
+ if (checkpoint !== prevProps.checkpoint) {
+ console.log(checkpoint)
+ const frameA = checkpoint.sequence[0]
+ const frameB = checkpoint.sequence[checkpoint.sequence.length-1]
+ this.setState({
+ ...initialState,
+ frameA,
+ frameB,
+ })
}
}
- fetch(dir) {
- console.log('fetch', dir)
- const { tool: module } = this.props.app
- this.setState({ dir, file: null, loading: true })
- actions.socket.list_directory({ module, dir }).then(files => {
- console.log(files)
- this.setState({ dir, files, loading: false })
- })
+
+ componentWillUnmount(){
+ window.removeEventListener('mouseup', this.handleMouseUp)
+ window.removeEventListener('mousemove', this.handleMouseMove)
+ }
+
+ handleMouseDown(e) {
+ this.setState({ dragging: true })
+ }
+ handleMouseMove(e) {
+ }
+ handleMouseEnter(e) {
+ }
+ handleMouseLeave(e) {
}
- fetchFile(fn) {
- console.log('fetch file', fn)
- const { tool: module } = this.props.app
- this.setState({ file: null, loadingFile: true })
- actions.socket.read_file({ module, fn }).then(file => {
- console.log(file)
- this.setState({ file, loadingFile: false })
- })
+ handleMouseUp(e) {
+ this.setState({ dragging: false })
}
+
+ handlePick(file) {
+ console.log(file)
+ // this.setState({ dir, file: null, loading: true })
+ }
+
render() {
- const { app } = this.props
+ const { app, checkpoint } = this.props
const {
- loading, dir, files,
- loadingFile, file,
+ loading,
+ selection,
+ frameA, frameB,
} = this.state
- console.log(this.props, this.state)
- // return (
- // <div className='app browser'>
- // <h1>{dir}{dir[dir.length-1] !== '/' && '/'}</h1>
- // {app.tool}<br/>
- // {loading && <Loading />}
- // <FileList
- // files={files}
- // groupDirectories
- // parentDirectory={dir !== '/'}
- // orderBy='name asc'
- // fields={'name datetime size'}
- // onClick={(file, e) => {
- // e.preventDefault()
- // e.stopPropagation()
- // console.log('picked a result', file)
- // this.handlePick(file)
- // }}
- // onClickParent={e => {
- // console.log('navigate up')
- // this.fetch(this.state.dir.split('/').slice(0, -1).join('/') || '/')
- // }}
- // />
- // {loadingFile && <Loading />}
- // {file && <FileViewer file={file} />}
- // </div>
- // )
+ // console.log(this.props, this.state)
+ const width = 200
+ const path = "sequences/" + checkpoint.name
+ return (
+ <div className='sequenceEditor'>
+ <div
+ className='timeline'
+ style={{ width }}
+ mouseDown={this.handleSelectionStart}
+ mouseEnter={this.handleMouseEnter}
+ mouseLeave={this.handleMouseLeave}
+ >
+ {selection && <div className='selection' style={selection}></div>}
+ </div>
+ <FileViewer path={path} file={this.state.frameA} />
+ <FileViewer path={path} file={this.state.frameB} />
+ </div>
+ )
}
}