diff options
| author | Jules <jules@asdf.us> | 2019-03-29 14:47:24 -0400 |
|---|---|---|
| committer | Jules <jules@asdf.us> | 2019-03-29 14:47:24 -0400 |
| commit | cb3d4041bf9e0c2a3ae9cc147c21afce06773a90 (patch) | |
| tree | 3ee1167d1182570d34c854c543098321ca51b4e3 /app | |
| parent | 2ceb9a945233f4bcb27607a97c69a5031d4f2046 (diff) | |
| parent | 99b426636d2e645053a86d433f76875b81e2ba2d (diff) | |
Merge branch 'master' of asdf.us:live-cortex
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/common/fileList.component.js | 8 | ||||
| -rw-r--r-- | app/client/common/header.component.js | 17 | ||||
| -rw-r--r-- | app/client/dataset/dataset.actions.js | 2 | ||||
| -rw-r--r-- | app/client/i18n/i18n.en.js | 103 | ||||
| -rw-r--r-- | app/client/i18n/i18n.pyro.js | 104 | ||||
| -rw-r--r-- | app/client/i18n/index.js | 15 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/index.js | 3 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.actions.js | 35 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.reducer.js | 5 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.tasks.js | 18 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.live.js | 107 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js | 115 | ||||
| -rw-r--r-- | app/client/system/system.actions.js | 5 | ||||
| -rw-r--r-- | app/client/system/system.component.js | 9 | ||||
| -rw-r--r-- | app/client/system/system.reducer.js | 17 | ||||
| -rw-r--r-- | app/client/types.js | 3 | ||||
| -rw-r--r-- | app/relay/modules/pix2pixhd.js | 30 | ||||
| -rw-r--r-- | app/server/proxy.js | 2 | ||||
| -rw-r--r-- | app/server/site.js | 2 |
19 files changed, 539 insertions, 61 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 12f6865..c4da4d7 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -17,7 +17,8 @@ export const FileList = props => { orderBy='name asc', className='', fileListClassName='filelist', - rowClassName='row file' + rowClassName='row file', + options, } = props const { mapFn, sortFn } = util.sort.orderByFn(orderBy) let sortedFiles = (files || []) @@ -36,6 +37,7 @@ export const FileList = props => { linkFiles={linkFiles} onDelete={onDelete} onClick={onClick} + options={options} /> }) if (!fileList || !fileList.length) { @@ -73,7 +75,7 @@ export const FileList = props => { } export const FileRow = props => { - const { file, linkFiles, onDelete, onClick, className='row file', username='' } = props + const { file, linkFiles, onDelete, onClick, className='row file', username='', options } = props const fields = fieldSet(props.fields) const size = util.hush_size(file.size) @@ -146,7 +148,7 @@ export const FileRow = props => { {fields.has('delete') && onDelete && file.id && <div className='destroy' onClick={(e) => onDelete(file)}>x</div> } - {props.options && props.options(file)} + {options && props.options(file)} </div> ) } diff --git a/app/client/common/header.component.js b/app/client/common/header.component.js index 8450e8a..6b0c89b 100644 --- a/app/client/common/header.component.js +++ b/app/client/common/header.component.js @@ -18,20 +18,24 @@ function NavLink(props){ } function Header(props){ - const { site, app, fps, playing, actions, location, history } = props + const { site, app, fps, playing, actions, location, history, i18n } = props const tool_list = Object.keys(modules).map((name, i) => { const label = name.replace(/_/, " ") - return <option value={name} key={i}>{label}</option> + return <option value={name} key={i}>{i18n.header[label] || label}</option> }) const tool = modules[app.tool] const links = tool.links().map((link,i) => { return ( - <NavLink key={i} location={location} to={link.url}>{link.name}</NavLink> + <NavLink key={i} location={location} to={link.url}>{i18n.header[link.name] || link.name}</NavLink> ) }) + const site_title = i18n.header.site_name || (site.name + " cortex") + document.querySelector('title').innerHTML = site_title + document.body.parentNode.setAttribute('lang', i18n.language) + document.body.setAttribute('section', location.pathname.replace(/[0-9]/g, '').replace(/\//g, '_').replace(/^_/, '').replace(/_$/, '')) return ( <header> - <span><b>{site.name} cortex</b></span> + <span><b>{site_title}</b></span> <span> <select onChange={e => { let path = window.location.pathname.split("/") @@ -45,8 +49,8 @@ function Header(props){ {tool_list} </select> </span> - <NavLink location={location} to="/system">system</NavLink> - <NavLink location={location} to="/dashboard">dashboard</NavLink> + <NavLink location={location} to="/system">{i18n.header.system}</NavLink> + <NavLink location={location} to="/dashboard">{i18n.header.dashboard}</NavLink> <span>{links}</span> {playing && <span>{fps} fps</span>} </header> @@ -58,6 +62,7 @@ const mapStateToProps = state => ({ app: state.system.app, fps: state.live.fps, playing: state.live.playing, + i18n: state.system.i18n.strings, }) const mapDispatchToProps = (dispatch, ownProps) => ({ diff --git a/app/client/dataset/dataset.actions.js b/app/client/dataset/dataset.actions.js index 1d28910..a7be863 100644 --- a/app/client/dataset/dataset.actions.js +++ b/app/client/dataset/dataset.actions.js @@ -59,13 +59,13 @@ export const fetchURL = (module, folder, url) => dispatch => { } parser.parse(url, media => { if (!media) return + media.title = media.title.replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '').trim() // strip emoji console.log('media', media) actions.file.create({ folder_id: folder.id, name: (media.title || "") .replace(/\.[^.]+$/g, '') .replace(/[^a-zA-Z0-9_]/g, '_') - .replace(/\s+/g, '_') .replace(/_+/g, '_'), module: module.name, dataset: media.token, diff --git a/app/client/i18n/i18n.en.js b/app/client/i18n/i18n.en.js new file mode 100644 index 0000000..3003014 --- /dev/null +++ b/app/client/i18n/i18n.en.js @@ -0,0 +1,103 @@ +export default { + language: 'en', + header: { + system: "system", + dashboard: "dashboard", + folders: "folders", + sequences: "sequences", + checkpoints: "checkpoints", + results: "results", + uprez: "uprez", + live: "live", + pix2pixhd: "pix2pixhd", + pix2pix: "pix2pix", + pix2wav: "pix2wav", + samplernn: "samplernn", + morph: "morph", + }, + gpu: { + idle: "GPU Idle", + busy: "GPU Busy", + start: "Start", + restart: "Restart", + stop: "Stop", + interrupt: "Interrupt", + not_processing: "Not Processing", + processing: "Processing", + }, + system: { + + }, + pix2pixhd: { + live: { + network: { + title: "Network", + view_mode: "view mode", + sequence: "sequence", + checkpoint: "checkpoint", + epoch: "epoch", + }, + playback: { + title: "Playback", + position: "position", + playback_rate: "playback rate", + skip_frames: "skip frames", + fade_sequence: "fade sequence", + frame_delay: "frame delay", + }, + record: { + save_frame: "Save frame", + save: "Save", + record_video: "Record video", + video_name: "Video name", + }, + transition: { + title: "Transition", + period: "period", + min: "min", + max: "max", + }, + recursion: { + title: "Recursion", + frac: "recursive amount", + roll: "roll amount", + axis: "roll axis", + }, + sequence: { + title: "Sequence", + frac: "sequence frac", + process_frac: "process frac", + }, + transform: { + title: "Transform", + rotate: "rotate", + scale: "scale", + }, + clahe: { + title: "Clahe", + clip_limit: "clip limit", + }, + posterize: { + title: "Posterize", + spatial_window: "spatial window", + color_window: "color window", + }, + blur: { + title: "Blur", + radius: "radius", + sigma: "sigma", + }, + canny: { + title: "Canny Edge Detection", + lo: "lower bound", + hi: "upper bound", + }, + hsl: { + title: "Hue / Saturation", + hue: "hue", + saturation: "saturation", + luminosity: "luminosity", + } + } + } +} diff --git a/app/client/i18n/i18n.pyro.js b/app/client/i18n/i18n.pyro.js new file mode 100644 index 0000000..f32343c --- /dev/null +++ b/app/client/i18n/i18n.pyro.js @@ -0,0 +1,104 @@ +export default { + language: 'pyro', + header: { + site_name: "political", + system: "random wrecking ball", + dashboard: "out of control buttons", + folders: "spam", + sequences: "YangGang offlimits sector", + checkpoints: "ideological filters", + results: "history", + uprez: "resolution", + live: "burning love", + pix2pixhd: "PYROMANCER", + pix2pix: "pyromancer lite", + pix2wav: "hierophant", + samplernn: "echo chamber", + morph: "time travel", + }, + gpu: { + idle: "Pyromancer is idle", + busy: "Pyromancer is working...", + start: "Start", + restart: "Restart", + stop: "Stop", + interrupt: "Interrupt", + not_processing: "Preparing", + processing: "Processing", + }, + system: { + + }, + pix2pixhd: { + live: { + network: { + title: "Mumbo Jumbo", + view_mode: "bollocks", + sequence: "mess", + checkpoint: "skew", + epoch: "reactionary regression", + }, + playback: { + title: "Divination", + position: "accelerationism", + playback_rate: "apocalypticism", + skip_frames: "emergent phenomena", + fade_sequence: "glossolalia", + frame_delay: "babble", + }, + record: { + save_frame: "PYROMANCER DISCOUNT", + save: "Save", + record_video: "PYROMANCER PREMIUM", + video_name: "Video name", + }, + transition: { + title: "Enlightenment", + period: "endarkenment", + min: "montecarlocasino", + max: "random stumble", + }, + recursion: { + title: "Proprietary button", + frac: "pay $5M to change this", + roll: "waste $5M", + axis: "When will I die?", + }, + sequence: { + title: "Political thermometer", + frac: "ignition", + process_frac: "wealth coeff.", + }, + transform: { + title: "Hate", + rotate: "0,14 factor", + scale: "Ariernachweis", + }, + clahe: { + title: "Loss function", + clip_limit: "sadness", + }, + posterize: { + title: "Depression", + spatial_window: "breakdown", + color_window: "burnout", + }, + blur: { + title: "Blur", + radius: "pressure", + sigma: "distortion", + }, + canny: { + title: "Future production", + lo: "conjuration", + hi: "self-fulfilling prophecy", + }, + hsl: { + title: "Generative future", + hue: "figure it out", + saturation: "make possibility appear", + luminosity: "glow", + } + } + } +} diff --git a/app/client/i18n/index.js b/app/client/i18n/index.js new file mode 100644 index 0000000..8f252ae --- /dev/null +++ b/app/client/i18n/index.js @@ -0,0 +1,15 @@ +import en from './i18n.en' +import pyro from './i18n.pyro' + +const strings = lang => { + switch (lang) { + case 'pyro': + return pyro + default: + return en + } +} + +const languages = ['en', 'pyro'] + +export { strings, languages } diff --git a/app/client/modules/pix2pixhd/index.js b/app/client/modules/pix2pixhd/index.js index cbd3136..511f4a0 100644 --- a/app/client/modules/pix2pixhd/index.js +++ b/app/client/modules/pix2pixhd/index.js @@ -8,6 +8,7 @@ import util from '../../util' import Pix2PixHDNew from './views/pix2pixhd.new' import Pix2PixHDShow from './views/pix2pixhd.show' import Pix2PixHDResults from './views/pix2pixhd.results' +import Pix2PixHDUprez from './views/pix2pixhd.uprez' import Pix2PixHDTrain from './views/pix2pixhd.train' import Pix2PixHDLive from './views/pix2pixhd.live' @@ -28,6 +29,7 @@ class router { <Route exact path='/pix2pixhd/sequences/:id/' component={Pix2PixHDShow} /> <Route exact path='/pix2pixhd/train/' component={Pix2PixHDTrain} /> <Route exact path='/pix2pixhd/results/' component={Pix2PixHDResults} /> + <Route exact path='/pix2pixhd/uprez/' component={Pix2PixHDUprez} /> <Route exact path='/pix2pixhd/live/' component={Pix2PixHDLive} /> </section> ) @@ -40,6 +42,7 @@ function links(){ { url: '/pix2pixhd/sequences/', name: 'sequences' }, { url: '/pix2pixhd/train/', name: 'checkpoints' }, { url: '/pix2pixhd/results/', name: 'results' }, + { url: '/pix2pixhd/uprez/', name: 'uprez' }, { url: '/pix2pixhd/live/', name: 'live' }, ] } diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js index 68119e1..5ee6759 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js @@ -156,9 +156,9 @@ export const load_results = (id) => (dispatch) => { const module = pix2pixhdModule.name util.allProgress([ actions.folder.index({ name: 'results' }), - actions.file.index({ module, generated: 1 }), - actions.socket.list_sequences({ module, dir: 'results' }), + actions.file.index({ module, generated: 1, limit: 250 }), actions.socket.list_directory({ module, dir: 'renders' }), + actions.socket.list_sequences({ module, dir: 'results' }), ], (percent, i, n) => { console.log('pix2pixhd load progress', i, n) dispatch({ @@ -167,15 +167,42 @@ export const load_results = (id) => (dispatch) => { data: { module: 'pix2pixhd' }, }) }).then(res => { - const [folders, files, results, renders] = res //, datasets, results, output, datasetUsage, lossReport] = res + const [folders, files, renders, results] = res //, datasets, results, output, datasetUsage, lossReport] = res // console.log(files, results, renders) dispatch({ type: types.pix2pixhd.load_results, results: { resultsFolder: folders[0], files, - results, renders, + results, + } + }) + }) +} + +export const load_uprez = (id) => (dispatch) => { + const module = pix2pixhdModule.name + util.allProgress([ + actions.folder.index({ name: 'results' }), + actions.socket.list_sequences({ module, dir: 'results' }), + actions.file.index({ module, activity: 'uprez' }), + ], (percent, i, n) => { + console.log('pix2pixhd load progress', i, n) + dispatch({ + type: types.app.load_progress, + progress: { i, n }, + data: { module: 'pix2pixhd' }, + }) + }).then(res => { + const [folders, results, files,] = res //, datasets, results, output, datasetUsage, lossReport] = res + // console.log(files, results, renders) + dispatch({ + type: types.pix2pixhd.load_uprez, + uprez: { + resultsFolder: folders[0], + results, + files, } }) }) diff --git a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js index 5a2afc0..7d6f6f3 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js @@ -26,6 +26,11 @@ const pix2pixhdReducer = (state = pix2pixhdInitialState, action) => { ...state, results: action.results, } + case types.pix2pixhd.load_uprez: + return { + ...state, + uprez: action.uprez, + } case types.pix2pixhd.load_dataset_count: return { ...state, diff --git a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js index 36c0f36..ec864e3 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js @@ -89,4 +89,20 @@ export const splice_task = (opt) => dispatch => { console.log(task) console.log('add splice task') return actions.queue.add_task(task) -}
\ No newline at end of file +} + +export const uprez_task = (opt) => dispatch => { + const task = { + module: module.name, + activity: 'uprez', + dataset: opt.dataset, + folder_id: opt.folder_id, + opt: { + ...opt, + } + } + console.log(task) + console.log('add uprez task') + return actions.queue.add_task(task) +} + diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js index 52b4b61..ee7ece7 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js @@ -14,6 +14,8 @@ import * as queueActions from '../../../queue/queue.actions' import * as pix2pixhdTasks from '../pix2pixhd.tasks' import * as pix2pixhdActions from '../pix2pixhd.actions' +import i18n from '../../../i18n' + class Pix2PixHDLive extends Component { constructor(props){ super() @@ -99,10 +101,11 @@ class Pix2PixHDLive extends Component { } render(){ // console.log(this.props) - if (this.props.pix2pixhd.loading) { - return <Loading progress={this.props.pix2pixhd.progress} /> + const { pix2pixhd, i18n } = this.props + if (pix2pixhd.loading) { + return <Loading progress={pix2pixhd.progress} /> } - const { folderLookup, datasetLookup, sequences } = this.props.pix2pixhd.data + const { folderLookup, datasetLookup, sequences } = pix2pixhd.data const sequenceLookup = sequences.reduce((a,b) => { a[b.name] = true @@ -110,7 +113,7 @@ class Pix2PixHDLive extends Component { }, {}) const sequenceGroups = Object.keys(folderLookup).map(id => { - const folder = this.props.pix2pixhd.data.folderLookup[id] + const folder = folderLookup[id] if (folder.name === 'results') return const datasets = folder.datasets.map(name => { const sequence = sequenceLookup[name] @@ -126,7 +129,7 @@ class Pix2PixHDLive extends Component { }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) const checkpointGroups = Object.keys(folderLookup).map(id => { - const folder = this.props.pix2pixhd.data.folderLookup[id] + const folder = folderLookup[id] if (folder.name === 'results') return const datasets = folder.datasets.map(name => { const dataset = datasetLookup[name] @@ -147,61 +150,62 @@ class Pix2PixHDLive extends Component { <div className='params row'> <div className='column'> <ParamGroup - title='Network' + title={i18n.pix2pixhd.live.network.title} noToggle > <Select live name='send_image' - title='view mode' + title={i18n.pix2pixhd.live.network.view_mode} options={['a','b','sequence','recursive']} onChange={this.props.actions.live.set_param} /> <SelectGroup live name='sequence_name' - title='sequence' + title={i18n.pix2pixhd.live.network.sequence} options={sequenceGroups} onChange={this.changeSequence} /> <SelectGroup live name='checkpoint_name' - title='checkpoint' + title={i18n.pix2pixhd.live.network.checkpoint} options={checkpointGroups} onChange={this.changeCheckpoint} /> <Select live name='epoch' - title='epoch' + title={i18n.pix2pixhd.live.network.epoch} options={this.props.epochs} onChange={this.changeEpoch} /> </ParamGroup> <div> <ParamGroup - title='Playback' + title={i18n.pix2pixhd.live.playback.title} name='sequence_playing' > <Slider - name='position' + name={i18n.pix2pixhd.live.playback.position} min={0.0} max={1.0} type='float' value={(this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1)} onChange={this.seek} /> <Slider live - title='playback rate' + title={i18n.pix2pixhd.live.playback.playback_rate} name='sequence_step' min={-4.0} max={4.0} type='float' /> <Slider live - title='skip frames' + title={i18n.pix2pixhd.live.playback.skip_frames} name='sequence_skip' min={0} max={1000} type='int' /> <Slider live - title='fade sequence' + title={i18n.pix2pixhd.live.playback.fade_sequence} name='fade_sequence' min={0} max={4.0} type='float' /> <Slider live + title={i18n.pix2pixhd.live.playback.frame_delay} name='frame_delay' min={0.0} max={2.0} type='float' /> @@ -217,64 +221,74 @@ class Pix2PixHDLive extends Component { </div> <div className='column'> <ParamGroup - title='Transition' + title={i18n.pix2pixhd.live.transition.title} name='transition' > <Slider live name='transition_period' + title={i18n.pix2pixhd.live.transition.period} min={10} max={5000} type='int' /> <Slider live name='transition_min' + title={i18n.pix2pixhd.live.transition.min} min={0.001} max={0.2} type='float' /> <Slider live name='transition_max' + title={i18n.pix2pixhd.live.transition.max} min={0.1} max={1.0} type='float' /> </ParamGroup> <ParamGroup - title='Recursion' + title={i18n.pix2pixhd.live.recursion.title} name='recursive' > <Slider live + title={i18n.pix2pixhd.live.recursion.frac} name='recursive_frac' min={0.0} max={0.5} type='float' /> <Slider live + title={i18n.pix2pixhd.live.recursion.roll} name='recurse_roll' min={-64} max={64} type='int' /> <Slider live + title={i18n.pix2pixhd.live.recursion.axis} name='recurse_roll_axis' min={0} max={1} type='int' /> </ParamGroup> <ParamGroup - title='Sequence' + title={i18n.pix2pixhd.live.sequence.title} name='sequence' > <Slider live + title={i18n.pix2pixhd.live.sequence.frac} name='sequence_frac' min={0.0} max={1.0} type='float' /> <Slider live + title={i18n.pix2pixhd.live.sequence.process_frac} name='process_frac' min={0} max={1} type='float' /> </ParamGroup> <ParamGroup - title='Transform' + title={i18n.pix2pixhd.live.transform.title} name='transform' > <Slider live + title={i18n.pix2pixhd.live.transform.rotate} name='rotate' min={-1} max={1} type='float' /> <Slider live + title={i18n.pix2pixhd.live.transform.scale} name='scale' min={0.9} max={1.1} type='float' /> @@ -283,70 +297,80 @@ class Pix2PixHDLive extends Component { <div className='column'> <ParamGroup - title='Clahe' + title={i18n.pix2pixhd.live.clahe.title} name='clahe' > <Slider live + title={i18n.pix2pixhd.live.clahe.clip_limit} name='clip_limit' min={1.0} max={4.0} type='float' /> </ParamGroup> <ParamGroup - title='Posterize' + title={i18n.pix2pixhd.live.posterize.title} name='posterize' > <Slider live + title={i18n.pix2pixhd.live.posterize.spatial_window} name='spatial_window' min={2} max={128} type='int' /> <Slider live + title={i18n.pix2pixhd.live.posterize.color_window} name='color_window' min={2} max={128} type='int' /> </ParamGroup> <ParamGroup - title='Blur' + title={i18n.pix2pixhd.live.blur.title} name='blur' > <Slider live + title={i18n.pix2pixhd.live.blur.radius} name='blur_radius' min={3} max={7} type='odd' /> <Slider live + title={i18n.pix2pixhd.live.blur.sigma} name='blur_sigma' min={0} max={2} type='float' /> </ParamGroup> <ParamGroup - title='Canny Edge Detection' + title={i18n.pix2pixhd.live.canny.title} name='canny' > <Slider live + title={i18n.pix2pixhd.live.canny.lo} name='canny_lo' min={10} max={200} type='int' /> <Slider live + title={i18n.pix2pixhd.live.canny.hi} name='canny_hi' min={10} max={200} type='int' /> </ParamGroup> <ParamGroup - title='Hue / Saturation' + title={i18n.pix2pixhd.live.hsl.title} name='hsl' > <Slider live + title={i18n.pix2pixhd.live.hsl.hue} name='hue' min={-127} max={127} type='int' /> <Slider live + title={i18n.pix2pixhd.live.hsl.saturation} name='saturation' min={-255} max={255} type='int' /> <Slider live + title={i18n.pix2pixhd.live.hsl.luminosity} name='luminosity' min={-255} max={255} type='int' /> @@ -359,46 +383,47 @@ class Pix2PixHDLive extends Component { } renderRestartButton(){ // console.log(this.props.runner.gpu) + const { i18n } = this.props if (this.props.runner.gpu.status === 'IDLE') { return ( <Button - title={'GPU Idle'} + title={i18n.gpu.idle} onClick={() => this.start()} - >Start</Button> + >{i18n.gpu.start}</Button> ) } if (this.props.runner.gpu.task.module !== 'pix2pixhd') { return ( <Button - title={'GPU Busy'} + title={i18n.gpu.busy} onClick={() => this.interrupt()} - >Interrupt</Button> + >{i18n.gpu.interrupt}</Button> ) } if (! this.props.opt.processing) { return ( <div> <Button - title={'Not processing'} + title={i18n.gpu.not_processing} onClick={this.togglePlaying} - >Restart</Button> + >{i18n.gpu.restart}</Button> <Button - title={'GPU Busy'} + title={i18n.gpu.busy} onClick={() => this.interrupt()} - >Interrupt</Button> + >{i18n.gpu.interrupt}</Button> </div> ) } return ( <div> <Button - title={'Processing'} + title={i18n.gpu.processing} onClick={this.togglePlaying} - >Stop</Button> + >{i18n.gpu.stop}</Button> <Button - title={'GPU Busy'} + title={i18n.gpu.busy} onClick={() => this.interrupt()} - >Interrupt</Button> + >{i18n.gpu.interrupt}</Button> </div> ) } @@ -420,16 +445,17 @@ class Pix2PixHDLive extends Component { // ) } renderLiveButtons(){ + const { i18n } = this.props return ( <div> <Button - title={'Save frame'} + title={i18n.pix2pixhd.live.record.save_frame} onClick={saveFrame} > - Save + {i18n.pix2pixhd.live.record.save} </Button> <ParamGroup - title='Record video' + title={i18n.pix2pixhd.live.record.record_video} name='store_b' noDim onToggle={(value) => { @@ -437,7 +463,7 @@ class Pix2PixHDLive extends Component { }} > <TextInput - title='Video name' + title={i18n.pix2pixhd.live.record.video_name} name='final_tag' value={this.props.opt.final_tag} onSave={value => { @@ -461,6 +487,7 @@ const mapStateToProps = state => ({ epochs: state.live.epochs, sequences: state.live.sequences, runner: state.system.runner, + i18n: state.system.i18n.strings, pix2pixhd: state.module.pix2pixhd, }) diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js b/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js new file mode 100644 index 0000000..982a1fc --- /dev/null +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.uprez.js @@ -0,0 +1,115 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { Link } from 'react-router-dom'; +import { connect } from 'react-redux' +import util from '../../../util' + +import actions from '../../../actions' + +import * as pix2pixhdActions from '../pix2pixhd.actions' +import * as pix2pixhdTasks from '../pix2pixhd.tasks' + +import Loading from '../../../common/loading.component' +import { FileList, FileRow } from '../../../common/fileList.component' + +let yes_count = 0 + +class Pix2pixHDUprez extends Component { + constructor(props){ + super() + if (!props.pix2pixhd.uprez) props.actions.load_uprez() + } + componentDidMount(){ + yes_count = 0 + } + render(){ + if (! this.props.pix2pixhd.uprez) return <Loading progress={this.props.pix2pixhd.progress} /> + + const { resultsFolder, results, renders, files } = this.props.pix2pixhd.uprez + // console.log(resultsFolder, results) + + return ( + <div className='app pix2pixhd'> + <div className='heading row middle'> + <h1>Pix2PixHD Uprez</h1> + </div> + <div class='rows params renders'> + + <h3>folders on server</h3> + <FileList + files={results} + orderBy='date desc' + fields={'name date count'} + onClick={(file, e) => { + e.preventDefault() + e.stopPropagation() + console.log('picked a result', file) + this.handlePick(file) + }} + options={file => { + console.log(file) + // create uprez task + return ( + <div> + {' ~ '} + <a href='#' onClick={() => this.handleUprez(file, { end: 250 })}>Uprez 10 seconds</a> + {' ~ '} + <a href='#' onClick={() => this.handleUprez(file, { end: 1500 })}>Uprez 1 minute</a> + {' ~ '} + <a href='#' onClick={() => this.handleUprez(file)}>Uprez whole thing</a> + </div> + ) + }} + /> + <br /> + + <h3>uprezzed videos</h3> + <FileList + linkFiles + files={files} + orderBy='date desc' + fields={'name date size delete'} + onDelete={file => { + let yes; + if (yes_count < 3) { + yes = confirm('Are you sure you want to delete this file?') + } else { + yes = true + } + if (yes) { + yes_count += 1 + console.log('delete: confirmed') + actions.file.destroy(file) + } + }} + /> + + </div> + </div> + ) + } + handlePick(file){ + // this.props.audioPlayer.play(file) + } + handleUprez(file, opt){ + console.log(file) + this.props.remote.uprez_task({ + is_result: true, + dataset: file.name, + folder_id: 1, + ...opt + }) + } +} + +const mapStateToProps = state => ({ + pix2pixhd: state.module.pix2pixhd, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(pix2pixhdActions, dispatch), + remote: bindActionCreators(pix2pixhdTasks, dispatch), + // audioPlayer: bindActionCreators(audioPlayerActions, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(Pix2pixHDUprez) diff --git a/app/client/system/system.actions.js b/app/client/system/system.actions.js index ccd9acd..73cea28 100644 --- a/app/client/system/system.actions.js +++ b/app/client/system/system.actions.js @@ -41,6 +41,11 @@ export const changeTool = (tool) => { return { type: types.app.change_tool, tool } } +export const changeLanguage = (language) => { + localStorage.setItem('cortex.i18n.language', language) + return { type: types.system.change_language, language } +} + export const enqueue_test_task = (dataset) => dispatch => { const task = { module: 'test', diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js index 3783862..69a6270 100644 --- a/app/client/system/system.component.js +++ b/app/client/system/system.component.js @@ -10,6 +10,8 @@ import * as liveActions from '../live/live.actions' import * as queueActions from '../queue/queue.actions' import * as authActions from '../auth/auth.actions' +import * as i18n from '../i18n' + const cpu_test_task = { activity: 'cpu', module: 'test', @@ -122,6 +124,13 @@ class System extends Component { <button onClick={() => actions.queue.start_task(wait_test_task, { preempt: true, watch: true })}>Wait and Buzz</button> </Param> </Group> + <Group title="Internationalization"> + <Param title="Language"> + {i18n.languages.map(language => ( + <button onClick={() => actions.system.changeLanguage(language)}>{language}</button> + ))} + </Param> + </Group> </div> {this.renderCommandOutput()} </div> diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index 5f9e4ac..f232da3 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -1,7 +1,11 @@ import types from '../types' import moment from 'moment/min/moment.min' +import * as i18n from '../i18n' + let FileSaver = require('file-saver') +const initialLanguage = localStorage.getItem('cortex.i18n.language') || process.env.I18N_LANGUAGE || 'en' + const systemInitialState = { loading: false, error: null, @@ -14,6 +18,10 @@ const systemInitialState = { production: process.env.NODE_ENV === 'production', development: process.env.NODE_ENV !== 'production', }, + i18n: { + language: initialLanguage, + strings: i18n.strings(initialLanguage), + }, app: { tool: localStorage.getItem('system.last_tool') || 'pix2pixhd', }, @@ -246,6 +254,15 @@ const systemReducer = (state = systemInitialState, action) => { last_message: action.data.data, stderr: state.stderr + action.data.data, } + case types.system.change_language: + return { + ...state, + i18n: { + language: action.language, + strings: i18n.strings(action.language), + } + } + default: return state } diff --git a/app/client/types.js b/app/client/types.js index cfb590a..cd82334 100644 --- a/app/client/types.js +++ b/app/client/types.js @@ -15,6 +15,7 @@ export default { counting_directory: 'SYSTEM_COUNTING_DIRECTORY', stdout: 'SYSTEM_STDOUT', stderr: 'SYSTEM_STDERR', + change_language: 'SYSTEM_CHANGE_LANGUAGE', }, app: { change_tool: "APP_CHANGE_TOOL", @@ -119,7 +120,7 @@ export default { 'init', 'set_folder' ]), pix2pixhd: with_type('pix2pixhd', [ - 'init', 'set_folder', 'load_results', 'load_dataset_count' + 'init', 'set_folder', 'load_results', 'load_dataset_count', 'load_uprez' ]), pix2wav: with_type('pix2wav', [ 'init', 'set_folder' diff --git a/app/relay/modules/pix2pixhd.js b/app/relay/modules/pix2pixhd.js index a01e321..43f839e 100644 --- a/app/relay/modules/pix2pixhd.js +++ b/app/relay/modules/pix2pixhd.js @@ -4,7 +4,7 @@ import fs from 'fs' const name = 'pix2pixhd' const cwd = process.env.PIX2PIXHD_CWD || path.join(process.env.HOME, 'code/' + name + '/') const env = { - LD_LIBRARY_PATH: '/usr/local/cuda/lib64:' + process.env.HOME + '/Downloads/TensorRT-4.0.0.3/lib', + LD_LIBRARY_PATH: '/usr/local/cuda/lib64:' + process.env.TENSORRT_LIB_PATH, } const fetch = { @@ -49,8 +49,9 @@ const train = { const datasets_path = path.join(cwd, 'datasets', dataset) const checkpoints_path = path.join(cwd, 'checkpoints', dataset) const iter_txt = path.join(checkpoints_path, 'iter.txt') + const checkpoint_path = path.join(checkpoints_path, 'latest_net_G.pth') console.log(dataset, iter_txt) - if (fs.existsSync(iter_txt)) { + if (fs.existsSync(iter_txt) && fs.existsSync(checkpoint_path)) { const iter = fs.readFileSync(iter_txt).toString().split('\n'); console.log(iter) epoch = iter[0] || 0 @@ -234,7 +235,7 @@ const render_recursive = { } } const splice = { - type: 'perl_gpu', + type: 'perl', script: 'splice.pl', params: (task) => { console.log(task.opt.selection) @@ -250,6 +251,28 @@ const splice = { }, after: 'train' } +const uprez = { + type: 'pytorch', + script: 'uprez.py', + params: task => { + console.log(task) + /* + set folder based on whether the file is a result or recursive mp4 + */ + let folder + if (task.opt.is_result) { + folder = './results/' + task.dataset + } else if (task.opt.is_recursive) { + folder = './recursive/' + task.dataset + '/' + task.opt.name + '/' + } + return [ + '--folder', folder, + '--folder_id', task.opt.folder_id, + '--dataset', task.dataset, + '--out_fn', task.dataset + "_" + Date.now(), + ] + } +} function pad(num, size) { if (isNaN(parseInt(num))) return num; @@ -270,5 +293,6 @@ export default { render, render_recursive, splice, + uprez, } } diff --git a/app/server/proxy.js b/app/server/proxy.js index 7526f01..290dba0 100644 --- a/app/server/proxy.js +++ b/app/server/proxy.js @@ -138,7 +138,7 @@ function get_headers (h){ // return // } -// var file = path.resolve('./StoneIsland/www/' + url) +// var file = path.resolve('./public/www/' + url) // fs.stat(file, function(err, stats) { // if (! stats) { // // console.log(404) diff --git a/app/server/site.js b/app/server/site.js index 36e2e75..90e30de 100644 --- a/app/server/site.js +++ b/app/server/site.js @@ -38,7 +38,7 @@ var sessionSettings = { } if (!process.env.SESSIONS_IN_MEMORY) { sessionSettings.store = new MongoStore({ - url: 'mongodb://127.0.0.1:28108/cortexSessionDb' + url: process.env.MONGODB_URL, // type: 'mongodb', // host: 'localhost', // port: 27017, |
