public void StartWriteText() { string NeuroNetFile = ""; NeuroNet neuroNet; OpenFileDialog NeuroNetDialog = new OpenFileDialog { Title = "Выбор нейросети", Filter = "Neuronet files|*.NN|All files|*.*" }; if (NeuroNetDialog.ShowDialog() == DialogResult.OK) { NeuroNetFile = NeuroNetDialog.FileName; } else { return; } neuroNet = NeuroNet.LoadNeuronet(NeuroNetFile); NormalizePhoto(); FindAllLines(); DebugLines(); FindAllLetters(); PreparationWriteTextPass(); int k = 0; while (WriteTextPass(neuroNet) && k < 200000) { k++; } Debug.Log("Расшифровка изображения завершена"); SaveFileDialog SaveTextDialog = new SaveFileDialog { Title = "SaveTextDialog", Filter = "Text|*.txt|All files|*.*" }; if (SaveTextDialog.ShowDialog() == DialogResult.OK) { FileWork.SaveText(final_massage, SaveTextDialog.FileName); } //FileWork.SaveText(final_massage, @"C:\Users\Admin\Desktop\Letter\ForComplete\text.txt"); Debug.Log("Текст скопирован в буфер обмена"); Clipboard.SetText(final_massage); }
void StartLearningThread() { Debug.Log("начало обучения"); Bitmap LetterImage; char letter; int count = 100000; float[] start_signals; float[] ideal_signals; //neuroNet = NeuroNet.CreateNeuroNet(new int[] {offset * offset, 42, 255 }, new NeuroData(1, 0.0002f)); int load_neuroNet = 10800;//34500; neuroNet = NeuroNet.LoadNeuronet(@"C:\Users\Admin\Desktop\Letter\forNeuronet\NN" + load_neuroNet + ".NN"); Debug.SetMaxValueProgressBar(count); for (int j = load_neuroNet + 1; j < count; j++) { neuroNet.ZeroingErrorOfEra(); for (int i = 0; i < 1030; i++) { StreamReader TextReader = new StreamReader(@"C:\Users\Admin\Desktop\ForText\" + i + ".txt"); LetterImage = new Bitmap(@"C:\Users\Admin\Desktop\ForText\" + i + ".jpg"); letter = TextReader.ReadLine()[0]; start_signals = GetNormalisedStartSignalsFromImage(LetterImage); ideal_signals = GetNormalisedIdealSignals(letter); neuroNet.Pass(start_signals, ideal_signals); } if (j % 50 == 0) { if (j != 0) { neuroNet.SaveNeuronet(@"C:\Users\Admin\Desktop\Letter\forNeuronet\NN" + j + ".NN"); Debug.Log("завершено на " + (j * 100f / count) + "%"); } else { neuroNet.SaveNeuronet(@"C:\Users\Admin\Desktop\Letter\forNeuronet\NN" + 0 + ".NN"); } Debug.Log("error of era = " + neuroNet.ShowErrorOfEra()); //neuroNet.edukationK *= 0.99f; } //Debug.Log("error of era = " + neuroNet.ShowErrorOfEra()); Debug.SetCurrentValueProgressBar(j); } neuroNet.SaveNeuronet(@"C:\Users\Admin\Desktop\Letter\forNeuronet\NN" + count + ".NN"); Debug.Log("обучение завершено"); }