Пример #1
0
        //---------------------------------------------


        #region Constructor
        internal SidePageTrainer()
        {
            InitializeComponent();

            this.cbTrainingLayer.DataSource = new object[] { "All", 1, 2, 3, 4, 5, };
            this.m_networkState             = new TrainingStatus();
        }
Пример #2
0
        //Train the person group
        private async Task TrainPersonGroup()
        {
            try
            {
                while (true)
                {
                    await faceServiceClient.TrainPersonGroupAsync(personGroupId);

                    System.Diagnostics.Debug.WriteLine("트레이닝 시작");

                    TrainingStatus trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                    System.Diagnostics.Debug.WriteLine("트레이닝");
                    if (trainingStatus.Status.ToString() != "running")
                    {
                        break;
                    }
                    await Task.Delay(1000);
                }
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.Error.Code);
                Console.WriteLine(ex.Error.Message);
                System.Diagnostics.Debug.WriteLine("트레이닝 오류" + ex);
            }
            catch (FaceAPIException f)
            {
                MessageBox.Show(f.ErrorMessage, f.ErrorCode);
                System.Diagnostics.Debug.WriteLine("그룹만들기 FaceAPIException=" + f);
            }
        }
Пример #3
0
        private async void GeneratePersonGroup_Click(object sender, RoutedEventArgs e)
        {
            CreatePersonResult zach = await faceServiceClient.CreatePersonAsync(personGroupId, "Zachary");

            // StorageFile yveImageDir = @"C:\Data\Users\DefaultAccount\Pictures\YveFolder\636294255522489954.jpg\";
            Stream s = await photoFile.OpenStreamForReadAsync();

            await faceServiceClient.AddPersonFaceAsync(personGroupId, zach.PersonId, s);

            status.Text = "Person created!";
            await Task.Delay(1000);

            //The training of the users above.
            await faceServiceClient.TrainPersonGroupAsync(personGroupId);

            TrainingStatus sstatus = null;

            while (true)
            {
                sstatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                if (sstatus.Status != Status.Running)
                {
                    status.Text = "Person group training complete";
                    break;
                }
                await Task.Delay(1000);
            }
        }
Пример #4
0
        private async Task <bool> TrainModel()
        {
            bool trainingSucceeded = false;

            TrainingStatus trainingStatus = null;

            try
            {
                await faceServiceClient.TrainPersonGroupAsync(PersonGroup);

                while (true)
                {
                    trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(PersonGroup);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }

                    await Task.Delay(1000);
                }
            }
            catch (FaceAPIException ex)
            {
                Debug.WriteLine($"Error training the model: {ex.ErrorMessage}");
            }

            if (trainingStatus.Status == Status.Succeeded)
            {
                trainingSucceeded = true;
            }

            return(trainingSucceeded);
        }
Пример #5
0
        public async Task <bool> CreatePerson(byte[] bitmap, string name)
        {
            try
            {
                // Create PERSON
                var newPerson = await _faceClient.CreatePersonAsync(_miriotPersonGroupId, name, JsonConvert.SerializeObject(new UserData()));

                // Add FACE to PERSON
                using (var stream = new MemoryStream(bitmap))
                    await _faceClient.AddPersonFaceAsync(_miriotPersonGroupId, newPerson.PersonId, stream);

                await _faceClient.TrainPersonGroupAsync(_miriotPersonGroupId);

                TrainingStatus state = null;
                while (state?.Status != Status.Running)
                {
                    state = await _faceClient.GetPersonGroupTrainingStatusAsync(_miriotPersonGroupId);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #6
0
        private async void OnStartTrainingClicked(object sender, RoutedEventArgs e)
        {
            this.progressControl.IsActive = true;

            TrainingStatus trainingStatus = null;

            try
            {
                await FaceServiceHelper.TrainPersonGroupAsync(this.CurrentPersonGroup.PersonGroupId);

                while (true)
                {
                    trainingStatus = await FaceServiceHelper.GetPersonGroupTrainingStatusAsync(this.CurrentPersonGroup.PersonGroupId);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure requesting training");
            }

            this.progressControl.IsActive = false;

            if (trainingStatus.Status != Status.Succeeded)
            {
                await new MessageDialog("Training finished with failure.").ShowAsync();
            }
        }
Пример #7
0
        /// <summary>
        /// Trains the Facial Recognition Model in the Azure Face Resource
        /// </summary>
        /// <param name="sender">A sender object</param>
        /// <param name="e">RoutedEventArgs</param>
        /// <remarks>
        /// <para>Model training is blackboxed</para>
        /// </remarks>
        private async void TrainButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (personGroupId.Length > 0)
            {
                TrainStatusTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                await ApiCallAllowed(true);

                await faceServiceClient.TrainPersonGroupAsync(personGroupId);

                TrainingStatus trainingStatus = null;
                while (true)
                {
                    await ApiCallAllowed(true);

                    trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }
                    await Task.Delay(1000);
                }

                TrainStatusTextBlock.Text = "Submission Status: Training Completed!";
            }
            else
            {
                TrainStatusTextBlock.Foreground = new SolidColorBrush(Colors.Red);
                TrainStatusTextBlock.Text       = "Submission Status: No person group ID found. Have you completed section two?";
            }
        }
        /// <summary>
        /// Creates person group in Azure face recognition API
        /// </summary>
        /// <returns>boolean</returns>
        public async Task <bool> CreateGroup()
        {
            var people = await _databaseController.GetImageObjects();

            await _faceServiceClient.CreatePersonGroupAsync(_groupId, "fun");

            foreach (var person in people)
            {
                CreatePersonResult result = await _faceServiceClient.CreatePersonAsync(_groupId, person.Id.ToString());

                await _faceServiceClient.AddPersonFaceAsync(_groupId, result.PersonId, RecUtil.GetStreamFromUri(person.ImageContentUri));
            }

            await _faceServiceClient.TrainPersonGroupAsync(_groupId);

            TrainingStatus trainingStatus = null;

            while (true)
            {
                trainingStatus = await _faceServiceClient.GetPersonGroupTrainingStatusAsync(_groupId);

                if (trainingStatus.Status != Status.Running)
                {
                    break;
                }

                await Task.Delay(1000);
            }

            return(true);
        }
        private async void TrainPersonGroup(object obj)
        {
            try
            {
                await _faceServiceClient.TrainPersonGroupAsync(SelectedPersonGroup.PersonGroupId);

                while (true)
                {
                    TrainingStatus trainingStatus = await _faceServiceClient.GetPersonGroupTrainingStatusAsync(SelectedPersonGroup.PersonGroupId);

                    if (trainingStatus.Status != Microsoft.ProjectOxford.Face.Contract.Status.Running)
                    {
                        StatusText = $"Person group finished with status: {trainingStatus.Status}";
                        break;
                    }

                    StatusText = "Training person group...";
                    await Task.Delay(1000);
                }
            }
            catch (FaceAPIException ex)
            {
                StatusText = $"Failed to train person group: {ex.ErrorMessage}";
            }
            catch (Exception ex)
            {
                StatusText = $"Failed to train person group: {ex.Message}";
            }
        }
Пример #10
0
        private void TrainNetwork(DateTime trainFrom, DateTime trainTo, TrainingStatus status)
        {
            if (_input == null || _ideal == null)
            {
                CreateTrainingSets(trainFrom, trainTo);
            }
            _trainThread = Thread.CurrentThread;
            int    epoch = 1;
            ITrain train = null;

            try
            {
                var trainSet = new BasicNeuralDataSet(_input, _ideal);
                train = new ResilientPropagation(_network, trainSet);
                double error;
                do
                {
                    train.Iteration();
                    error = train.Error;
                    status?.Invoke(epoch, error, TrainingAlgorithm.Resilient);
                    epoch++;
                } while (error > MaxError);
            }
            catch (ThreadAbortException) { _trainThread = null; }
            finally
            {
                train?.FinishTraining();
            }
            _trainThread = null;
        }
        // GET: TrainingAssessmentStatus
        public async Task <ActionResult> Index()
        {
            try
            {
                TrainingStatus objTrainingStatus = new TrainingStatus();
                InitializeServiceClient();
                HttpResponseMessage response = await client.PostAsJsonAsync("Skill/GetAllSkills", req);

                List <Skill> skills = new List <Skill>();
                Skill        skAll  = new Skill();
                skAll.SkillId   = 0;
                skAll.SkillName = "All Skills";
                skills.Add(skAll);
                List <Skill> academySkills = await response.Content.ReadAsAsync <List <Skill> >();

                for (int i = 0; i < academySkills.Count; i++)
                {
                    skills.Add(academySkills[i]);
                }
                objTrainingStatus.Skills = skills;
                HttpResponseMessage projectResponse = await client.PostAsJsonAsync("Project/GetAllProjects", req);

                List <Project> projects = await projectResponse.Content.ReadAsAsync <List <Project> >();

                objTrainingStatus.Projects = projects;
                return(View(objTrainingStatus));
            }
            catch (Exception ex)
            {
                //LogHelper.AddLog("TrainingAssessmentStatusController", ex.Message, ex.StackTrace, "HCL.Academy.Web", user.EmailID);
                TelemetryClient telemetry = new TelemetryClient();
                telemetry.TrackException(ex);
                return(View());
            }
        }
Пример #12
0
        private async void Train()
        {
            String personGroupId = "students";
            await faceServiceClient.UpdatePersonGroupAsync(personGroupId, "SISstudenti");


            string friend1ImageDir = AppDomain.CurrentDomain.BaseDirectory + @"Slike\" + rfid + @"\";

            foreach (string imagePath in Directory.GetFiles(friend1ImageDir, "*.jpg"))
            {
                using (Stream stream = File.OpenRead(imagePath))
                {
                    // Detect faces in the image and add to Anna
                    await faceServiceClient.AddPersonFaceAsync(
                        personGroupId, Guid.Parse(guid), stream);
                }
            }
            await faceServiceClient.TrainPersonGroupAsync(personGroupId);

            TrainingStatus trainingStatus = null;

            while (true)
            {
                trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                if (trainingStatus.Status != Status.Running)
                {
                    break;
                }

                await Task.Delay(1000);
            }
        }
        public async Task TrainPersonGroup(string groupId, string groupName, string personName, string faceImageDir)
        {
            // Gruppe erstellen
            await _faceClient.PersonGroup.CreateAsync(groupId, groupName);

            // Person hinzufügen
            var person = await _faceClient.PersonGroupPerson.CreateAsync(groupId, personName);

            // Fotos der Person hinzufügen
            foreach (string imagePath in Directory.GetFiles(faceImageDir, "*.jpg"))
            {
                using (Stream s = File.OpenRead(imagePath))
                {
                    await _faceClient.PersonGroupPerson.AddFaceFromStreamAsync(groupId, person.PersonId, s);
                }
            }

            // Model trainieren
            await _faceClient.PersonGroup.TrainAsync(groupId);

            // Trainingsstatus abfragen
            TrainingStatus trainingStatus = null;

            while (true)
            {
                trainingStatus = await _faceClient.PersonGroup.GetTrainingStatusAsync(groupId);

                if (trainingStatus.Status != TrainingStatusType.Running)
                {
                    break;
                }
                await Task.Delay(1000);
            }
        }
Пример #14
0
        private async Task StartTrainingAsync()
        {
            Console.WriteLine("Training Group {0}", MAGIC_MIRROR_GROUP);
            await _faceApiClient.TrainPersonGroupAsync(MAGIC_MIRROR_GROUP);

            TrainingStatus trainingStatus = null;

            while (true)
            {
                trainingStatus = await _faceApiClient.GetPersonGroupTrainingStatusAsync(MAGIC_MIRROR_GROUP);

                if (trainingStatus.Status != Status.Running)
                {
                    if (trainingStatus.Status == Status.Failed)
                    {
                        Console.WriteLine("Trainig Failed!");
                        Console.WriteLine(trainingStatus.Message);
                    }
                    break;
                }

                Console.Write(".");
                await Task.Delay(1000);
            }

            Console.WriteLine("Group Trained");
        }
        public async Task <IList <IdentifyResult> > Identify(IList <DetectedFace> faces)
        {
            if (faces.Count == 0)
            {
                return(new List <IdentifyResult>());
            }

            IList <IdentifyResult> result = new List <IdentifyResult>();

            try
            {
                TrainingStatus status = await _faceClient.PersonGroup.GetTrainingStatusAsync(_personGroupId);

                if (status.Status != TrainingStatusType.Failed)
                {
                    IList <Guid> faceIds = faces.Select(face => face.FaceId.GetValueOrDefault()).ToList();

                    result = await _faceClient.Face.IdentifyAsync(_personGroupId, faceIds, null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(result);
        }
Пример #16
0
    /// <summary>
    /// Gets the person-group's training status.
    /// </summary>
    /// <returns>The group's training status.</returns>
    /// <param name="groupId">Person-group ID.</param>
    public TrainingStatus GetPersonGroupTrainingStatus(string groupId)
    {
        if (string.IsNullOrEmpty(faceSubscriptionKey))
        {
            throw new Exception("The face-subscription key is not set.");
        }

        string requestUrl = string.Format("{0}/persongroups/{1}/training", GetFaceServiceUrl(), groupId);

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("ocp-apim-subscription-key", faceSubscriptionKey);

        HttpWebResponse response = CloudWebTools.DoWebRequest(requestUrl, "GET", "", null, headers, true, false);

        TrainingStatus status = null;

        if (!CloudWebTools.IsErrorStatus(response))
        {
            StreamReader reader = new StreamReader(response.GetResponseStream());
            status = JsonUtility.FromJson <TrainingStatus>(reader.ReadToEnd());
        }
        else
        {
            ProcessFaceError(response);
        }

        return(status);
    }
Пример #17
0
        private async Task <string> EnsurePersonGroup(string personGroupId)
        {
            try
            {
                var personGroup = await faceClient.PersonGroup.GetAsync(personGroupId);
            }
            catch (APIErrorException ex)
            {
                if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    //await faceClient.PersonGroup.CreateAsync(personGroupId, "XD Developer");
                    await faceClient.PersonGroup.CreateAsync(personGroupId, "XD Developer 2", recognitionModel : recognitionModel);//recognition_02
                }
                else
                {
                    throw ex;
                }
            }

            TrainingStatus trainingStatus = null;

            try
            {
                trainingStatus = await faceClient.PersonGroup.GetTrainingStatusAsync(personGroupId);
            }
            catch { }

            return(trainingStatus != null && trainingStatus.Status == TrainingStatusType.Succeeded ? personGroupId : string.Empty);
        }
Пример #18
0
        internal SidePageTrainer()
        {
            InitializeComponent();

            this.cbTrainingLayer.DataSource = new object[] { "All", 1, 2, 3, 4, 5, };
            this.m_networkState = new TrainingStatus();
        }
Пример #19
0
        private async void addFaceAndTrainData(string imagePath, System.Guid personId)
        {
            try
            {
                using (Stream imageFileStream = File.OpenRead(imagePath))
                {
                    AddPersistedFaceResult faceRes = await faceServiceClient.AddPersonFaceAsync(this.personGroupId, personId, imageFileStream);

                    Console.Out.WriteLine("Added face to Person with Id " + faceRes.PersistedFaceId);
                }


                await faceServiceClient.TrainPersonGroupAsync(this.personGroupId);

                TrainingStatus status = null;
                do
                {
                    status = await faceServiceClient.GetPersonGroupTrainingStatusAsync(this.personGroupId);
                } while (status.Status.ToString() != "Succeeded");
            }
            catch (FaceAPIException f)
            {
                MessageBox.Show(f.ErrorCode, f.ErrorMessage);
            }
        }
Пример #20
0
        /// <summary>
        /// Trains the group, using the provided images to increase precision in associating a face to a name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnTrain_Click(object sender, EventArgs e)
        {
            try
            {
                await faceServiceClient.TrainPersonGroupAsync(_groupId);

                TrainingStatus trainingStatus = null;
                while (true)
                {
                    trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(_groupId);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }

                    await Task.Delay(1000);
                }

                MessageBox.Show("Training successfully completed");
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #21
0
        public static TrainingCourseViewModel TrainingCourseFrom(TrainingStatus source, TrainingCourseType courseType, DateTime cutoffDate)
        {
            if (source == null)
            {
                return(new TrainingCourseViewModel
                {
                    Trainees = new List <TraineeViewModel>()
                });
            }
            var sessions = courseType == TrainingCourseType.Unknown ? source.Sessions.Sessions.Values.AsEnumerable() : source.Sessions[courseType];

            return(new TrainingCourseViewModel
            {
                CourseType = courseType,
                Trainees = from t in source.Trainees.Values
                           select new TraineeViewModel
                {
                    Name = t.Name,
                    Relationship = t.CampaignRelationship,
                    Sessions = from r in source.Registrations.Registrations
                               join s in sessions on r.SessionID equals s.ID
                               where r.TraineeID == t.ID
                               select new TrainingSessionViewModel
                    {
                        Attended = s.Date.Date > cutoffDate ? null : (bool?)r.Attended,
                        Completed = s.Date.Date > cutoffDate ? null : (bool?)r.Completed,
                        AchievesCompliance = source.ComplianceAchievedBy(r),
                        Date = s.Date
                    }
                }
            });
        }
        //TODO: checks if inerstion was successful

        /// <summary>
        /// Inserts new image into person group
        /// </summary>
        /// <param name="imageModel">Object to insert into person group</param>
        /// <returns>boolean</returns>
        public async Task <bool> InsertPersonInToGroup(ImageModel imageModel)
        {
            CreatePersonResult result = await _faceServiceClient.CreatePersonAsync(_groupId, imageModel.Id.ToString());

            if (result == null)
            {
                throw new ManagerException(RecognitionErrorMessages.PersonNotCreatedError);
            }

            await _faceServiceClient.AddPersonFaceAsync(_groupId, result.PersonId, RecUtil.GetStreamFromUri(imageModel.ImageContentUri));

            await _faceServiceClient.TrainPersonGroupAsync(_groupId);

            TrainingStatus trainingStatus = null;

            while (true)
            {
                trainingStatus = await _faceServiceClient.GetPersonGroupTrainingStatusAsync(_groupId);

                if (trainingStatus.Status != Status.Running)
                {
                    break;
                }

                await Task.Delay(1000);
            }

            return(true);
        }
Пример #23
0
        public IActionResult TrainAPersonGroup(string personGroupId)
        {
            try
            {
                faceClient.PersonGroup.TrainAsync(personGroupId);

                TrainingStatus trainingStatus = null;

                while (true)
                {
                    trainingStatus = faceClient.PersonGroup.GetTrainingStatusAsync(personGroupId).Result;

                    if (trainingStatus.Status != TrainingStatusType.Running)
                    {
                        break;
                    }

                    Task.Delay(1000).Wait();
                }

                return(Ok(new BaseResponse(null, "Success!!!", true)));
            }
            catch (Exception e)
            {
                return(BadRequest(new BaseResponse(null, e.Message, false)));
            }
        }
Пример #24
0
        private async Task GetTrainStatus()
        {
            try
            {
                TrainingStatus trainingStatus = null;
                while (true)
                {
                    trainingStatus = await _faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }
                    await Task.Delay(1000);

                    Console.WriteLine("GetPersonGroupTrainingStatusAsync");
                }
                //-----------------------------------------------------------------------------------------------------
                //_identityButton.Enabled = true;
                Console.WriteLine(trainingStatus.Status);
            }
            catch (FaceAPIException ex)
            {
                Console.WriteLine("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage);
            }
        }
Пример #25
0
        private async void NewPersonGroup_Click(object sender, RoutedEventArgs e)
        {
            CreatePersonResult guest = await faceServiceClient.CreatePersonAsync(personGroupId, "Guest");

            //if (guest != null)
            //{
            //    await faceServiceClient.DeletePersonAsync(personGroupId, guest.PersonId);
            //    //The data of the past user has been deleted
            //}

            Stream s = await photoFile.OpenStreamForReadAsync();

            await faceServiceClient.AddPersonFaceAsync(personGroupId, guest.PersonId, s);

            // Training of the new user will now begin.
            status.Text = "Training of the new user will now begin";
            await faceServiceClient.TrainPersonGroupAsync(personGroupId);

            TrainingStatus sstatus = null;

            while (true)
            {
                sstatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                if (sstatus.Status != Status.Running)
                {
                    status.Text = "Person group training complete";
                    break;
                }
                await Task.Delay(1000);
            }
            status.Text = "Training of the new user has been completed. ";
        }
Пример #26
0
 internal TrainingDocumentInfo(string documentName, int pageCount, IReadOnlyList <FormRecognizerError> errors, TrainingStatus status)
 {
     DocumentName = documentName;
     PageCount    = pageCount;
     Errors       = errors;
     Status       = status;
 }
Пример #27
0
    /// <summary>
    /// Determines whether the person-group's training is finished.
    /// </summary>
    /// <returns><c>true</c> if the person-group's training is finished; otherwise, <c>false</c>.</returns>
    /// <param name="groupId">Person-group ID.</param>
    public bool IsPersonGroupTrained(string groupId)
    {
        TrainingStatus status   = GetPersonGroupTrainingStatus(groupId);
        bool           bSuccess = (status != null && status.status == Status.Succeeded);

        return(bSuccess);
    }
Пример #28
0
        /// <summary>
        /// Creates a PersonGroup.
        /// </summary>
        /// <returns>The PersonGroup ID.</returns>
        private static async Task <string> CreatePersonGroup(IFaceClient client)
        {
            // Create a PersonGroup.
            var personGroupId = Guid.NewGuid().ToString();
            await client.PersonGroup.CreateAsync(personGroupId, "test", recognitionModel : recognitionModel);

            Console.WriteLine("Creating person group... Done");
            Console.WriteLine($"Person group ID: {personGroupId}\n");

            // Add persons.
            var personFolders = Directory.EnumerateDirectories("data\\PersonGroup");

            foreach (var personFolder in personFolders)
            {
                var person = await client.PersonGroupPerson.CreateAsync(
                    personGroupId,
                    Path.GetFileNameWithoutExtension(personFolder));

                var faceFiles = Directory.EnumerateFiles(personFolder, "*.*", SearchOption.AllDirectories).Where(
                    filename => string.Compare(".jpg", Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)
                    == 0).ToList();

                // Add faces.
                foreach (var faceFile in faceFiles)
                {
                    using (var fileStream = new FileStream(faceFile, FileMode.Open, FileAccess.Read))
                    {
                        await client.PersonGroupPerson.AddFaceFromStreamAsync(
                            personGroupId,
                            person.PersonId,
                            fileStream);
                    }
                }
            }

            // Train the PersonGroup for identification usage.
            await client.PersonGroup.TrainAsync(personGroupId);

            Console.WriteLine("Training PersonGroup... Started");

            // Wait for training to complete.
            TrainingStatus trainingStatus = null;

            do
            {
                if (trainingStatus != null)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(100));
                }

                trainingStatus = await client.PersonGroup.GetTrainingStatusAsync(personGroupId);

                Console.WriteLine($"Training Status: {trainingStatus.Status}");
            }while (trainingStatus.Status != TrainingStatusType.Failed &&
                    trainingStatus.Status != TrainingStatusType.Succeeded);

            Console.WriteLine("Training PersonGroup... Done\n");

            return(personGroupId);
        }
        public async Task <bool> CreatePerson(Model model)
        {
            bool result = false;

            Person person = await _client.PersonGroupPerson.CreateAsync(Consts.personGroupId, model.Name);

            MemoryStream memstream = new MemoryStream(model.byteContent, 0, model.byteContent.Length);

            await _client.PersonGroupPerson.AddFaceFromStreamAsync(Consts.personGroupId, person.PersonId, memstream);

            await _client.PersonGroup.TrainAsync(Consts.personGroupId);

            while (true)
            {
                TrainingStatus trainingStatus = null;
                trainingStatus = await _client.PersonGroup.GetTrainingStatusAsync(Consts.personGroupId);

                if (trainingStatus.Status != TrainingStatusType.Running)
                {
                    result = true;
                    break;
                }
                await Task.Delay(1000);
            }

            return(result);
        }
Пример #30
0
        public async Task TrainPersonGroup()
        {
            try
            {
                await FaceServiceClient.TrainPersonGroupAsync(_personGroupId);

                TrainingStatus trainingStatus = null;
                while (true)
                {
                    trainingStatus = await FaceServiceClient.GetPersonGroupTrainingStatusAsync(_personGroupId);

                    if (trainingStatus.Status != Status.Running)
                    {
                        break;
                    }

                    await Task.Delay(1000);
                }
                return;
            }
            catch
            {
                return;
            }
        }
 private void CreateModuleTypesAndTrainingStatus()
 {
     classRoomType = _context.ModuleTypes.Add(new ModuleType()
     {
         TypeName = "Classroom"
     });
     OnlineType = _context.ModuleTypes.Add(new ModuleType()
     {
         TypeName = "Online"
     });
     PlannedStatus = _context.TrainingStatuses.Add(new TrainingStatus()
     {
         StatusName = "Planned"
     });
     OngoingStatus = _context.TrainingStatuses.Add(new TrainingStatus()
     {
         StatusName = "Canceled"
     });
     OngoingStatus = _context.TrainingStatuses.Add(new TrainingStatus()
     {
         StatusName = "Ongoing"
     });
     CompletedStatus = _context.TrainingStatuses.Add(new TrainingStatus()
     {
         StatusName = "Completed"
     });
     _context.SaveChanges();
 }
Пример #32
0
        public void Stop()
        {
            // this.m_trainingSession.ResetStatus();
            this.m_networkState = new TrainingStatus();
            this.m_trainingPaused = false;

            this.updateStatus();

            if (backgroundWorker.IsBusy)
            {
                HistoryListener.Write("Stopping Thread");
                this.backgroundWorker.CancelAsync();

                this.timer.Stop();
                this.m_trainingPaused = false;
            }
            else
            {
                HistoryListener.Write("Thread is not running");
            }
        }
        /// <summary>
        ///   Training callback
        /// </summary>
        /// <param name = "status">Training status</param>
        /// <param name = "correctOutputs">Correct outputs percentage</param>
        /// <param name = "error">Error RMS</param>
        /// <param name = "iteration">Iteration</param>
        private void CallBack(TrainingStatus status, double correctOutputs, double error, int iteration)
        {
            if (status == TrainingStatus.Finished)
            {
                _buttonPause.Enabled = false;
                _buttonAbort.Enabled = false;
                _cbLog.Enabled = true;
                _tbHiddenUnits.Enabled = true;
                _cmbActivationFunction.Enabled = true;
                _cmbActivationFunctionHidden.Enabled = true;
                _cmbActivationFunctionOutput.Enabled = true;
                try
                {
                    if (_cbLog.Checked)
                        logger.Close();
                    _tElapsedTime.Stop();
                }
                catch (Exception ex)
                {
                    Debug.Fail(ex.StackTrace);
                    MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                MessageBox.Show(Resources.TrainingFinished, Resources.Finished, MessageBoxButtons.OK, MessageBoxIcon.Information);
                _buttonStart.Enabled = false;
                _buttonAbort.Enabled = false;
                _buttonPause.Enabled = false;
                return;
            }
            if (_cbLog.Enabled)
                logger.WriteLine(iteration + CommaSeparator + correctOutputs);
            Invoke(new Action(
                () =>
                {
                    _tbStatus.Text = status.ToString();
                    _textBoxIteration.Text = iteration.ToString();
                    _tbCorrectOutputs.Text = correctOutputs.ToString();
                    _textBoxError.Text = error.ToString();
                }));
        }
Пример #34
0
        public void Forget()
        {
            this.m_networkContainer.ActivationNetwork.Randomize();
            this.m_networkContainer.Precision = 0;
            //this.m_trainingSession.ResetStatus();

             //   this.m_trainingSession.IsPaused = false;
            this.m_networkState = new TrainingStatus();
            this.m_trainingPaused = false;
            this.m_graphControl.ClearGraph();
            this.updateStatus();

            HistoryListener.Write("Network learnings cleared");
        }
Пример #35
0
 private void networkContainer_SavepointRestored(object sender, EventArgs e)
 {
     //        this.m_trainingSession.NetworkState = this.m_networkContainer.Savepoints.CurrentSavepoint.NetworkStatus;
     this.m_networkState = this.m_networkContainer.Savepoints.CurrentSavepoint.NetworkStatus;
     this.updateStatus();
 }