public async Task SavePhotosPredictionsAsync() { var trainPhotosPaths = (await GetPhotosPathsByFileAsync(_trainPhotosFileLocation)).ToList(); var testPhotosPaths = (await GetPhotosPathsByFileAsync(_testPhotosFileLocation)).ToList(); var photos = trainPhotosPaths.Union(testPhotosPaths).ToList(); if (photos.Count != photos.Distinct().Count()) { throw new Exception("Duplicates photos found!"); } var samplePhotos = new List <SamplePhoto>(); var predictions = await _photoProcessingService.ComputePredictionsAsync(photos); foreach (var location in photos) { var name = GetPhotoName(location); var description = await GetPhotoDescriptionAsync(name); var prediction = predictions.ElementAt(photos.IndexOf(location)).ToArray(); var samplePhoto = new SamplePhoto(name, location, description, prediction); samplePhotos.Add(samplePhoto); } await _samplePhotoRepository.DeleteAsync(samplePhoto => true); foreach (var samplePhoto in samplePhotos) { await _samplePhotoRepository.CreateAsync(samplePhoto); } }
public ClusterSamplePhoto(SamplePhoto samplePhoto) { SamplePhoto = samplePhoto; }