Example #1
0
 public NIPDataProvider(SearchingParams searchingPars, SamplingParams samplingPars, int maxSampleCount)
     : base(ToList(searchingPars, samplingPars, maxSampleCount), Projections, null)
 {
     Contract.Requires(!searchingPars.IsEmpty);
     Contract.Requires(!samplingPars.IsEmpty);
     Contract.Requires(maxSampleCount > 0);
 }
Example #2
0
        internal static IEnumerable<NoisedImagePartReader> FindReaders(SearchingParams searchingPars, SamplingParams samplingPars)
        {
            Contract.Requires(!searchingPars.IsEmpty);
            Contract.Requires(!samplingPars.IsEmpty);
            Contract.Ensures(Contract.Result<IEnumerable<NoisedImagePartReader>>() != null);

            return SearchForNIPs(samplingPars, SearchForFiles(searchingPars));
        } 
 public NoisedImagePartProvider(SearchingParams searchingPars, SamplingParams samplingPars, int maxSampleCount)
 {
     Contract.Requires(!searchingPars.IsEmpty);
     Contract.Requires(!samplingPars.IsEmpty);
     Contract.Requires(maxSampleCount > 100);
     
     this.searchingPars = searchingPars;
     this.samplingPars = samplingPars;
     this.maxSampleCount = maxSampleCount;
 }
 public NIPFFLearningScriptProvider(SearchingParams searchingPars, SamplingParams samplingPars, int maxSampleCount)
 {
     Contract.Requires(!searchingPars.IsEmpty);
     Contract.Requires(!samplingPars.IsEmpty);
     Contract.Requires(maxSampleCount > 100);
     
     this.searchingPars = searchingPars;
     this.samplingPars = samplingPars;
     this.maxSampleCount = maxSampleCount;
 }
Example #5
0
        // Helpers:
        private static List<NIPData> ToList(SearchingParams searchingPars, SamplingParams samplingPars, int? maxSampleCount)
        {
            Contract.Ensures(Contract.Result<List<NIPData>>() != null);
            Contract.Ensures(Contract.Result<List<NIPData>>().Count > 0);

            List<NIPData> result = null;

            var readers = Search.FindReaders(searchingPars, samplingPars);
            if (maxSampleCount == null)
            {
                result = readers.Select(r => new NIPData(r)).ToList();
            }
            else
            {
                result = readers.OrderByRandom().Take(maxSampleCount.Value).Select(r => new NIPData(r)).ToList();
            }

            if (result.Count == 0)
            {
                throw new InvalidOperationException("Samples not found.");
            }

            return result;
        } 
Example #6
0
 public static IUnorderedNeuralVectorFlowProvider CreateRValidationProvider()
 {
     var searchPars = new SearchingParams(Settings.Default.ImagePaths.Split(';'), new[] { "*.jpg", "*.png" }, true);
     var samplPars = new SamplingParams(Settings.Default.SampleSize, Settings.Default.RecurrentSampleLength, 10);
     return new NoisedImageLineProvider(searchPars, samplPars, Settings.Default.ValidationSampleCount);
 }
Example #7
0
 static NIPDataProvider CreateDataProvider(int max)
 {
     var searchPars = new SearchingParams(Properties.Settings.Default.ImagePaths.Split(';'), new[] { "*.jpg", "*.png" }, true);
     var samplPars = new SamplingParams(Properties.Settings.Default.SampleSize);
     var prov = new NIPDataProvider(searchPars, samplPars, max);
     return prov;
 }
Example #8
0
 private static IEnumerable<FileInfo> SearchForFiles(SearchingParams searchingPars)
 {
     var visited = new HashSet<string>();
     return SearchForFiles(searchingPars.Directories.Select(d => new DirectoryInfo(d)).Where(di => di.Exists), searchingPars.Filters, searchingPars.Recursive, visited);
 }
Example #9
0
 static ScriptCollectionProvider CreateProvider(int sampleCount, bool recurrent)
 {
     //string debugPath = @"C:\Users\unbornchikken\Pictures\NN\HQ_Parts\";
     //var searchPars = new SearchingParams(debugPath, new[] { "*.jpg", "*.png" }, true);
     
     var searchPars = new SearchingParams(Properties.Settings.Default.ImagePaths.Split(';'), new[] { "*.jpg", "*.png" }, true);
     var samplPars = new SamplingParams(Properties.Settings.Default.SampleSize, 25, 10);
     if (!recurrent)
     {
         return new NIPScriptProvider(searchPars, samplPars, sampleCount);
     }
     else
     {
         return new NILScriptProvider(searchPars, samplPars, sampleCount);            
     }
 }