/// <summary> /// Executes a new analysis and generates new spaces /// </summary> public void RunAnalysisCreateNewSpaces(bool saveImages = false) { //Stopwatch aiStopwatch = new Stopwatch(); //aiStopwatch.Start(); Boundaries = new List <Voxel>(); var gridImage = GetStateImage256(); var analysisResult = _pix2pix.GeneratePrediction(gridImage); var resultTexture = ProcessAnalysisResult(analysisResult); if (saveImages) { string folderIN = @"D:\GitRepo\PublicParts\PP_AI_Studies\temp_en\IN\"; string folderOUT = @"D:\GitRepo\PublicParts\PP_AI_Studies\temp_en\OUT\"; ImageReadWrite.SaveImage2Path(gridImage, folderIN + "Iteration_" + _iterationCounter.ToString("D4")); ImageReadWrite.SaveImage2Path(resultTexture, folderOUT + "Iteration_" + _iterationCounter.ToString("D4")); _iterationCounter++; } PassBoundaryToList(resultTexture); DestroySpaces(); Spaces = GenerateSpaces(); SetSpacesToConfigurableParts(); //aiStopwatch.Stop(); //var t = aiStopwatch.ElapsedMilliseconds; }
/// <summary> /// Condensed method to populate the grid with configurable parts and analyse it with /// the Pix2Pix model /// </summary> void PopulateAndAnalyseGrid() { //Clean the boundaries _boundaries = new List <Voxel>(); //populate configurables int componentCount = _grid.ActiveVoxelsAsList().Count(v => !v.IsOccupied) / 120; //Populate grid and get resulting texture, already upscaled var gridImage = PopulateRandomConfigurableGetImage(componentCount); //Analyse grid with Pix2pix var analysisResult = _pix2pix.GeneratePrediction(gridImage); //Post-process the analysis result texture var resultTexture = ProcessAnalysisResult(analysisResult); //Assign result pixels to voxel data, populating the boundaries list PassBoundaryToList(resultTexture); _activityLog = $"AI Message: Generated {componentCount} components"; }