Пример #1
0
        public static StringBuilder GetCurrentPythonVersion()
        {
            var parentKey           = Registry.LocalMachine.OpenSubKey(_windowsRegistryInstall);
            var nameList            = parentKey.GetSubKeyNames();
            var pythonInstallations = new StringBuilder();

            for (int i = 0; i < nameList.Length; i++)
            {
                var regKey = parentKey.OpenSubKey(nameList[i]);
                try
                {
                    var registryDisplayName = (string)regKey.GetValue("DisplayName");
                    var installationPath    = (string)regKey.GetValue("InstallSource");
                    var version             = (string)regKey.GetValue("DisplayVersion");

                    if (!string.IsNullOrEmpty(registryDisplayName) && registryDisplayName.Contains(_python))
                    {
                        pythonInstallations.AppendLine(registryDisplayName);
                    }
                }
                catch (Exception ex)
                {
                    _exceptionLogging.LogException(ex.ToString());
                }
            }
            return(pythonInstallations);
        }
        public void Recognise(string fileName)
        {
            FileSource    = BitmapFrame.Create(new Uri(fileName));
            ImageFileName = fileName;

            try
            {
                using (_inceptionGraph = new Inception())
                {
                    _fileName = fileName;
                    _inceptionGraph.OnDownloadCompleted += OnDownloadComplete;
                    if (!string.IsNullOrEmpty(DownloadURL) &&
                        !string.IsNullOrEmpty(InceptionGraphFileName) &&
                        !string.IsNullOrEmpty(OutputLabelsFileName))
                    {
                        _inceptionGraph.Init(new string[] { InceptionGraphFileName, OutputLabelsFileName }, DownloadURL);
                    }
                    else
                    {
                        _inceptionGraph.Init();
                    }
                }
            }
            catch (Exception ex)
            {
                _exceptionLogDataAccess.LogException(ex.ToString());
                IsModalVisible = false;
            }
        }
Пример #3
0
 public static void SerialiseAndWriteObject(string filePath, object parameter, Type type)
 {
     try
     {
         using (var writer = new StreamWriter(filePath))
         {
             var serialiser = new XmlSerializer(type);
             serialiser.Serialize(writer, parameter);
         }
     }
     catch (Exception ex)
     {
         _exceptionLogging.LogException(ex.ToString());
     }
 }
        private void OnVisualiseColumnn()
        {
            if (SelectedVisualisationColumnIndex >= 0 && ColumnsDictionary.Any())
            {
                try
                {
                    SelectedColumnItemsCount = new ObservableCollection <KeyValuePair <string, int> >();
                    var selectedColumnKey   = ColumnsDictionary.ElementAt(SelectedVisualisationColumnIndex).Key;
                    var visualiseColumnData = CleanDataItems.SelectMany(x => x.Data).Where(c => c.Key == selectedColumnKey);

                    foreach (var visualColumnData in visualiseColumnData.Select(x => x.Value).Distinct())
                    {
                        Application.Current.Dispatcher.Invoke(() => SelectedColumnItemsCount.Add(new KeyValuePair <string, int>(visualColumnData,
                                                                                                                                visualiseColumnData.Select(x => x).Where(c => string.Equals(c.Value, visualColumnData, StringComparison.OrdinalIgnoreCase)).Count())));
                    }
                }
                catch (Exception ex)
                {
                    _exceptionLogDataAccess.LogException(ex.ToString());
                }
            }
        }
Пример #5
0
 public static void Main()
 {
     try
     {
         var application = new App();
         application.InitializeComponent();
         application.Run();
     }
     catch (Exception ex)
     {
         _exceptionLogging.LogException(ex.ToString());
     }
 }
 public void GetPredictions()
 {
     try
     {
         var predictions = new ObservableCollection <CensusBaseEntity>();
         using (var reader = new StreamReader(CurrentDirectory.GetPythonAssetsDirectory(@"WideDeep\Prediction.csv")))
         {
             var line = reader.ReadLine();
             while (!reader.EndOfStream)
             {
                 line = reader.ReadLine();
                 var values = line.Split(',');
                 predictions.Add(new CensusBaseEntity()
                 {
                     Age             = Convert.ToInt32(values[0]),
                     WorkClass       = values[1],
                     Fnlwgt          = Convert.ToInt32(values[2]),
                     Education       = values[3],
                     EducationNumber = Convert.ToInt32(values[4]),
                     MartialStatus   = values[5],
                     Occupation      = values[6],
                     Relationship    = values[7],
                     Race            = values[8],
                     Gender          = values[9],
                     CapitalGain     = Convert.ToInt32(values[10]),
                     CapticalLoss    = Convert.ToInt32(values[11]),
                     HoursPerWeek    = Convert.ToInt32(values[12]),
                     Country         = values[13]
                 });
             }
         }
         PredictionInputValues = predictions;
     }
     catch (Exception ex)
     {
         _exceptionLogging.LogException(ex.ToString());
     }
 }
Пример #7
0
        private void ReadMNISTDataset()
        {
            try
            {
                var directories = GetDirectories();
                var ifsLabels   = new FileStream(directories.LabelsFileDir, FileMode.Open);
                var ifsImages   = new FileStream(directories.ImagesFileDir, FileMode.Open);
                ifsLabels.Seek(_labelPosition, SeekOrigin.Begin);
                ifsImages.Seek(_datasetPosition, SeekOrigin.Begin);
                var brLabels  = new BinaryReader(ifsLabels);
                var brImages  = new BinaryReader(ifsImages);
                int magic1    = brImages.ReadInt32();
                int numImages = brImages.ReadInt32();
                int numRows   = brImages.ReadInt32();
                int numCols   = brImages.ReadInt32();
                int magic2    = brLabels.ReadInt32();
                int numLabels = brLabels.ReadInt32();
                var pixels    = new byte[28][];

                for (int i = 0; i < pixels.Length; ++i)
                {
                    pixels[i] = new byte[28];
                }

                for (int i = 0; i < 28; ++i)
                {
                    for (int j = 0; j < 28; ++j)
                    {
                        byte b = brImages.ReadByte();
                        pixels[i][j] = b;
                    }
                }

                byte lbl    = brLabels.ReadByte();
                var  dImage = new DigitImage(pixels, lbl);
                CorrespondingLabel = lbl;
                PixelArray         = dImage.GetImageArray();
                var formatEmptyLines = Regex.Replace(dImage.ToString(), @"^\s+$[\r\n]*", string.Empty, RegexOptions.Multiline);
                DatasetInformation += string.Format("{0}\n\r", formatEmptyLines);

                ifsImages.Close();
                brImages.Close();
                ifsLabels.Close();
                brLabels.Close();
            }
            catch (Exception ex)
            {
                _exceptionLogging.LogException(ex.ToString());
            }
        }
 private void OnDownloadComplete(object sender, AsyncCompletedEventArgs e)
 {
     try
     {
         using (var imageTensor = ImageIO.ReadTensorFromImageFile <float>(_fileName, 224, 224, 128.0f, 1.0f / 128.0f))
         {
             var detectionResult      = _graph.Detect(imageTensor);
             var detectionAnnotations = MultiboxGraph.FilterResults(detectionResult, 0.1f);
             var detectionImage       = NativeImageIO.ImageFileToJpeg(_fileName, detectionAnnotations);
             var typeConverter        = TypeDescriptor.GetConverter(typeof(Bitmap));
             var detectionBmpImage    = (Bitmap)typeConverter.ConvertFrom(detectionImage.Raw);
             ImageSource = BitmapConverter.ConvertBitmap(detectionBmpImage);
         }
         IsModalVisible = false;
     }
     catch (Exception ex)
     {
         _exceptionLogDataAccess.LogException(ex.ToString());
         IsModalVisible = false;
     }
 }
        public object InvokeDynamicFunction(string function)
        {
            try
            {
                if (function.StartsWith("="))
                {
                    var methodStart = function.IndexOf('=');
                    var startIndex  = function.IndexOf('(');
                    var endIndex    = function.IndexOf(')');
                    var methodName  = function.Substring(++methodStart, startIndex - methodStart);
                    var parameters  = function.Substring(++startIndex, endIndex - startIndex).Split(',');
                    return(InvokeFunction(methodName, parameters));
                }
            }
            catch (Exception ex)
            {
                _exceptionLogDataAccess.LogException(ex.ToString());
                return(ex);
            }

            return(string.Empty);
        }
Пример #10
0
 private void GetSavedExperimentResults()
 {
     ExperimentResults = new ObservableCollection <PerformanceIndicatorEntity>();
     try
     {
         using (var reader = new StreamReader(CurrentDirectory.GetAssetsDirectoryFolder(@"CSVFiles\ExperimentResults.csv")))
         {
             do
             {
                 var line = reader.ReadLine();
                 if (line != null)
                 {
                     var values           = line.Split(',');
                     var experimentResult = new PerformanceIndicatorEntity()
                     {
                         PreprocessingTechnique = values[0],
                         Process          = values[1],
                         Accuracy         = int.Parse(values[2]),
                         AccuracyBaseline = int.Parse(values[3]),
                         AUC = int.Parse(values[4]),
                         AUCPrecisionRecall = int.Parse(values[5]),
                         AverageLoss        = int.Parse(values[6]),
                         LabelMean          = int.Parse(values[7]),
                         Loss           = int.Parse(values[8]),
                         Precision      = int.Parse(values[9]),
                         PredictionMean = int.Parse(values[10]),
                         Recall         = int.Parse(values[11]),
                         TrainTime      = int.Parse(values[12]),
                     };
                     ExperimentResults.Add(experimentResult);
                 }
             }while (!reader.EndOfStream);
         }
     }
     catch (Exception ex)
     {
         _exceptionLogDataAccess.LogException(ex.ToString());
     }
 }