import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import util from '../../../util' import * as pix2pixhdActions from '../pix2pixhd.actions' import * as pix2pixhdTasks from '../pix2pixhd.tasks' import { Loading, FileList, FileRow, Select, SelectGroup, Group, Param, Button, TextInput, NumberInput, CurrentTask, TaskList } from '../../../common' import DatasetForm from '../../../dataset/dataset.form' import NewDatasetForm from '../../../dataset/dataset.new' import UploadStatus from '../../../dataset/upload.status' import DatasetComponent from '../../../dataset/dataset.component' import pix2pixhdModule from '../pix2pixhd.module' class Pix2PixHDTrain extends Component { constructor(props){ super(props) this.handleChange = this.handleChange.bind(this) this.state = { checkpoint_name: 'PLACEHOLDER', epoch: 'latest', augment_name: '', augment_take: 100, augment_make: 20, } this.short_presets = [ { augment_take: 100, augment_make: 5 }, { augment_take: 200, augment_make: 5 }, { augment_take: 200, augment_make: 3 }, { augment_take: 50, augment_make: 10 }, { augment_take: 100, augment_make: 10 }, { augment_take: 1000, augment_make: 1 }, ] this.medium_presets = [ { augment_take: 30, augment_make: 20 }, { augment_take: 20, augment_make: 30 }, { augment_take: 30, augment_make: 30 }, { augment_take: 50, augment_make: 20 }, { augment_take: 20, augment_make: 50 }, { augment_take: 15, augment_make: 70 }, ] this.long_presets = [ { augment_take: 2, augment_make: 100 }, { augment_take: 2, augment_make: 200 }, { augment_take: 5, augment_make: 100 }, { augment_take: 5, augment_make: 200 }, { augment_take: 10, augment_make: 100 }, { augment_take: 10, augment_make: 200 }, ] } componentWillMount(){ const id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id') console.log('load dataset:', id) const { match, pix2pixhd, actions } = this.props if (id === 'new') return if (id) { if (parseInt(id)) localStorage.setItem('pix2pixhd.last_id', id) if (! pix2pixhd.folder || pix2pixhd.folder.id !== id) { actions.load_directories(id) } } else { this.props.history.push('/pix2pixhd/new/') } } componentDidUpdate(prevProps, prevState){ if (prevState.checkpoint_name !== this.state.checkpoint_name) { this.setState({ epoch: 'latest' }) this.props.actions.list_epochs(this.state.checkpoint_name) } } handleChange(name, value){ console.log('name', name, 'value', value) this.setState({ [name]: value }) } interrupt(){ this.props.actions.queue.stop_task('gpu') } render(){ if (this.props.pix2pixhd.loading) { return } const { pix2pixhd, match, history, queue } = this.props const { folderLookup, datasetLookup } = (pix2pixhd.data || {}) const folder = (folderLookup || {})[pix2pixhd.folder_id] || {} // console.log(pix2pixhd) const checkpointGroups = Object.keys(folderLookup).map(id => { const folder = this.props.pix2pixhd.data.folderLookup[id] if (folder.name === 'results') return const datasets = folder.datasets.map(name => { const dataset = datasetLookup[name] if (dataset.checkpoints.length) { return name } return null }).filter(n => !!n) return { name: folder.name, options: datasets.sort(), } }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) // console.log('state', this.props.pix2pixhd.data.epochs) // console.log(this.state.checkpoint_name, this.state.epoch) // console.log(queue) return (

pix2pixhd training