... using Microsoft.Cognitive.CustomVision.Training; using Microsoft.Cognitive.CustomVision.Training.Models; using System; using System.Linq; using System.Threading.Tasks; ... namespace VisionRacing.TrainingRacingImages { class Program { ... private static async Task WorkOnProject(TrainingApi trainingApi, string name) { var option = " "; while (!string.IsNullOrEmpty(option)) { Console.Clear(); var project = await GetOrCreateProject(trainingApi, name); Console.WriteLine($" --- Project {project.Name} ---"); Console.WriteLine(); await ListProjectTags(trainingApi, project.Id); Console.WriteLine("Type an option number:"); Console.WriteLine(" 1: Create Karting images"); Console.WriteLine(" 2: Create F1 images"); Console.WriteLine(" 3: Create MotoGP images"); Console.WriteLine(" 4: Create Rally images"); Console.WriteLine(" 5: Train project"); Console.WriteLine(" 6: Delete project"); Console.WriteLine(); Console.WriteLine($"Press any other key to exit project {name}"); option = Console.ReadLine(); switch (option) { case "1": await CreateTagImages(trainingApi, project.Id, ImageType.Karting); break; case "2": await CreateTagImages(trainingApi, project.Id, ImageType.F1); break; case "3": await CreateTagImages(trainingApi, project.Id, ImageType.MotoGP); break; case "4": await CreateTagImages(trainingApi, project.Id, ImageType.Rally); break; case "5": await TrainProject(trainingApi, project.Id); break; case "6": await DeleteProject(trainingApi, project.Id); option = string.Empty; break; default: option = string.Empty; break; } } } ... private static async Task<Project> GetOrCreateProject(TrainingApi trainingApi, string name) { var projects = await trainingApi.GetProjectsAsync(); var project = projects.Where(p => p.Name.ToUpper() == name.ToUpper()).SingleOrDefault(); if (project == null) { project = await trainingApi.CreateProjectAsync(name); } return project; } ... private static async Task ListProjectTags(TrainingApi trainingApi, Guid projectId) { var tagList = await trainingApi.GetTagsAsync(projectId); if (tagList.Tags.Any()) { Console.WriteLine($"Tags: {Environment.NewLine}{string.Join(Environment.NewLine, tagList.Tags.Select(t => $" {t.Name} (Image count: {t.ImageCount})"))}{Environment.NewLine}"); } else { Console.WriteLine($"No tags yet...{Environment.NewLine}"); } } ... private enum ImageType { F1, Karting, MotoGP, Rally } } }