コード例 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string strModel      = cmbModel.Text;
            string strSolverType = cmbSolver.Text;
            int    nIterations;
            int    nIntermediateIterations = 0;
            double dfLr;
            double dfTvLoss      = 0;
            int    nMaxImageSize = 640;

            if (!int.TryParse(edtIterations.Text, out nIterations) || nIterations < 1)
            {
                MessageBox.Show("The 'Iterations' value is invalid - enter a positive integer greater than one.", "Invalid Iterations", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                edtIterations.Focus();
                return;
            }

            if (!BaseParameter.TryParse(edtLearningRate.Text, out dfLr) || dfLr <= 0)
            {
                MessageBox.Show("The 'Learning Rate' value is invalid - enter a positive real value greater than one.", "Invalid Learning Rate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                edtLearningRate.Focus();
                return;
            }

            if (!int.TryParse(edtMaxImageSize.Text, out nMaxImageSize) || nMaxImageSize < 64 || nMaxImageSize > 2048)
            {
                MessageBox.Show("The 'Max Image Size' value is invalid - enter a positive integer within the range [64, 2048].", "Invalid Max Image Size", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                edtMaxImageSize.Focus();
                return;
            }

            if (!Directory.Exists(edtResultPath.Text))
            {
                MessageBox.Show("The 'Result Path' is invalid, please enter the path to an existing folder.", "Invalid Result Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                btnBrowseResultPath.Focus();
                return;
            }

            if (chkIntermediateOutput.Checked)
            {
                if (!int.TryParse(edtIntermediateIterations.Text, out nIntermediateIterations) || nIntermediateIterations < 0 || nIntermediateIterations > nIterations)
                {
                    MessageBox.Show("The 'Intermediate Iterations' value is invalid - enter a positive integer within the range [1," + nIterations.ToString() + "].", "Invalid Intermediate Iterations", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DialogResult = DialogResult.None;
                    edtIntermediateIterations.Focus();
                    return;
                }
            }

            if (chkEnableTvLoss.Checked)
            {
                if (!BaseParameter.TryParse(edtTvLoss.Text, out dfTvLoss) || dfTvLoss < 0 || dfTvLoss > 0.1)
                {
                    MessageBox.Show("The 'TV-Loss' value is invalid - enter a real value within the range [0,0.1].", "Invalid TV-Loss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DialogResult = DialogResult.None;
                    edtTvLoss.Focus();
                    return;
                }
            }

            if (!File.Exists(edtContentImageFile.Text))
            {
                MessageBox.Show("Could not find the content file '" + edtContentImageFile.Text + "'!", "Invalid Content File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                btnBrowseContent.Focus();
                return;
            }

            if (!File.Exists(edtStyleImageFile.Text))
            {
                MessageBox.Show("Could not find the style file '" + edtStyleImageFile.Text + "'!", "Invalid Style File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                btnBrowseStyle.Focus();
                return;
            }

            m_info = new NeuralStyleInfo(edtStyleImageFile.Text, edtContentImageFile.Text, nIterations, strModel.ToLower(), strSolverType, dfLr, edtResultPath.Text, nIntermediateIterations, dfTvLoss, nMaxImageSize);
        }
コード例 #2
0
 public FormNeuralStyle(string strStyleFile, string strContentFile, int nIterations, string strModelName, string strSolverType, double dfLr, string strResultPath, int nIntermediateIterations, double dfTvLoss, int nMaxImageSize)
 {
     m_info = new NeuralStyleInfo(strStyleFile, strContentFile, nIterations, strModelName, strSolverType, dfLr, strResultPath, nIntermediateIterations, dfTvLoss, nMaxImageSize);
     InitializeComponent();
 }