In the current era, technology regarding artificial intelligence has developed rapidly and has been used in various areas of life. Face detection is one of the applications of Artificial Intelligence. This research aims to detect students' faces during the online learning process and succeeded in getting positive feedback when tested on students. Student detection includes drowsy and alertness. The method is via webcam in real-time so that the screen will show whether the student is drowsy or alert. In the trial, the teacher can find out who is in a drowsy and alert condition. On the other hand, students can find out that they fall into the drowsy or alert category. So that both parties immediately respond to what should be done based on the classification results. The algorithms used are Decision Tree and Random Forest. The accuracy results of the Random Forest algorithm are better than the Decision Tree algorithm, namely 65 percent, while the Decision Tree algorithm is 58 percent. The division of training data and test data uses a Kfold of 5. When Kfold is equal to 2, both algorithms have the highest accuracy, where Random Forest has an accuracy of 85 percent, and Decision Tre has an accuracy of 65 percent.