public override void Execute(object parameter) { try { var builder = new StringBuilder(); builder.AppendLine( $"Training dataset: {ViewModel.DataSetModel?.Name}, info: {ViewModel.DataSetModel?.MetaData.Description}"); builder.AppendLine( $"Testing dataset: {ViewModel.TestingDataSet?.Name}, info: {ViewModel.TestingDataSet?.MetaData.Description}"); builder.AppendLine( $"Approximated training time {TimeSpan.FromMilliseconds(Enumerable.Repeat(ViewModel.MeanEpochTimeStruct, ViewModel.CurrentEpoch).Sum(t => t.TotalMilliseconds)).ToString("g", CultureInfo.InvariantCulture)}"); builder.AppendLine(string.Join(string.Empty, Enumerable.Repeat('-', 100))); builder.AppendLine("Training params overview:"); ViewModel.TrainingParams.ForEach(p => builder.AppendLine($"epoch: {p.epoch}, learning rate: {p.learningRate}, momentum: {p.momentum}")); builder.AppendLine(string.Join(string.Empty, Enumerable.Repeat('-', 100))); builder.AppendLine("Success rates:"); ViewModel.SuccessValues.ForEach(s => builder.AppendLine($"epoch: {s.X}, success: {s.Y}")).ExecuteQuery(); builder.AppendLine(string.Join(string.Empty, Enumerable.Repeat('-', 100))); builder.AppendLine("Error function values:"); ViewModel.ErrorFunctionValues.ForEach(s => builder.AppendLine($"epoch: {s.X}, error: {s.Y}")).ExecuteQuery(); var path = FilePickerHelper.AskForFilePath("txt"); File.WriteAllText(path, builder.ToString()); } catch (Exception e) { NotifyUser.NotifyUserByMessage("Something went wrong during printing report into file.", e); } }
public async void Execute(object parameter) { _isWorking = true; OnCanExecuteChanged(); var task = Task.Run(() => { try { var model = GetModel(parameter).ConfigurationModel; var json = model.ToJson(); FilePickerHelper.SaveFile(json, "json"); } catch (Exception e) { NotifyUser.NotifyUserByNotification( new Notification() { Title = "Ooooops!", Message = $"Something happend during generation of your code.", Exception = e }); } finally { _isWorking = false; } }); await task; task.Dispose(); OnCanExecuteChanged(); }
public override async void Execute(object parameter) { _isSaving = true; OnCanExecuteChanged(); var task = Task.Run(() => { try { var model = ViewModel.GetTrainedModel(); FilePickerHelper.SaveFile(model.ToJson(), "mementoModelJson"); } catch (Exception e) { NotifyUser.NotifyUserByNotification( new Notification() { Title = "SDK model to json error", Message = $"Something happend during generation of your code.", Exception = e }); } finally { _isSaving = false; App.RunInUiThread(OnCanExecuteChanged); } }); await task; task.Dispose(); }
private async void SaveFile(NetModelCreator paModelCreator) { _isSaving = true; CanExecuteChanged?.Invoke(this, EventArgs.Empty); await Task.Run(() => { try { var model = paModelCreator.GenerateModel(); var json = model.ToJson(); FilePickerHelper.SaveFile(json, ViewModels.NetBuilderViewModel.CleanNetModel); } catch (Exception e) { NotifyUser.NotifyUserByNotification(new Notification() { Title = "Something happend during saving model.", Message = $"Make sure you have all permissions to write.", Exception = e }); } }); _isSaving = false; CanExecuteChanged?.Invoke(this, EventArgs.Empty); }
//Load default Image private async void LoadDefaultImageForOcr() { ProgressVisibility = Visibility.Visible; ImageCollection = new Images(); ImageCollection = await FilePickerHelper.GetFileListWithBitmapImages(null, true, new List <string>() { "ms-appx:///Assets/introtext.jpg" }); if (ImageCollection.ListImageDisplay.Count > 0 && ImageCollection.ListImageDisplay[0].Count > 0) { ImageDisplay = ImageCollection.ListImageDisplay[0].FirstOrDefault(); IsOpen = true; } else { } ProgressVisibility = Visibility.Collapsed; }
private async void ExecutePdfCommand(object obj) { ProgressVisibility = Visibility.Visible; ImageCollection = new Images(); List <string> fileTypes = new List <string>(); fileTypes.Add(".pdf"); ImageCollection = await FilePickerHelper.GetFileListWithBitmapImages(fileTypes); if (ImageCollection.ListImageDisplay.Count > 0 && ImageCollection.ListImageDisplay[0].Count > 0) { ImageDisplay = ImageCollection.ListImageDisplay[0].FirstOrDefault();//List<ImageSource> IsOpen = true; } else { } ProgressVisibility = Visibility.Collapsed; }
private async void OnBrowsePictures() { try { var file = await FilePickerHelper.PickSingleFile(); if (file != null) { _navigationFacade.NavigateToCropView(file); } } catch (InvalidImageDimensionsException) { var resourceLoader = ResourceLoader.GetForCurrentView(); var message = string.Format(resourceLoader.GetString("InvalidImageSize_Message"), PhotoTypeContract.Standard.ToSideLength()); var title = resourceLoader.GetString("InvalidImageSize_Title"); await _dialogService.ShowNotification(message, title, false); } }
public override async void Execute(object parameter) { _isSaving = true; var task = Task.Run(() => { try { var model = ViewModel.GetTrainedModel(); if (model == null) { return; } var trainedModel = new TrainedNetModel((MementoConfigurationModel)model.Clone()) { ModelName = ViewModel.Model.ModelName, DataSetMetaData = ViewModel.DataSetModel.MetaData }; FilePickerHelper.SaveFile(trainedModel.ToJson(), NetBuilderViewModel.DirtyNetModel); } catch (Exception e) { NotifyUser.NotifyUserByNotification( new Notification() { Title = "Ooooops!", Message = $"Something happend during generation of your code.", Exception = e }); } finally { _isSaving = false; App.RunInUiThread(OnCanExecuteChanged); } }); await task; task.Dispose(); }
public override void Execute(object parameter) { try { var model = ViewModel.GetTrainedModel(); if (model == null) { return; } var generator = new CplusPlusCodeGenerator(model); generator.GenerateCode(); FilePickerHelper.SaveFile(generator.Result, "h"); } catch (Exception e) { NotifyUser.NotifyUserByNotification( new Notification() { Title = "Ooooops!", Message = $"Something happend during generation of your code.", Exception = e }); } }