4-1/졸업프로젝트

2022_5_2_졸프 일지 - 모델 성능 왜 이러지/출석 학생 DB저장

개발자 덕구🐾 2022. 5. 2. 19:29
728x90

 

model_func를 변경시켜 몇명의 얼굴이 detect되었고 

출석한 학생의 label과 출석하지 않은 학생의 레이블을 출력하도록 코드를 만들었다. 

 

이 사진이 캡처본이고 DB에는 남자연예인과 한소희, 그리고 다른 여자 연예인이 있었다. 

 

그러나 이 모델을 

이 사진에서 2명의 얼굴만이 detect되었고

그마저도 identification에서 틀렸다.  (DB에 있는 다른 여자인물이라고 예상했다)

 

 

 

그래도 일단 먼저 웹서비스 구현을 위해서 출석되었다고 나온 라벨을

어떻게 이용자에게 알려줄건지 생각하고 구현하고있다.

 

 

 

모델 성능이 말이 안나오게 안좋다.

fine tuning, esr gan을 찾아 모델 성능을 향상 시켜봐야겠다. 

성능의 절실함을 느낄 수 있었다. 

 

 

 

 

# 캡쳐  
# /checks
@blue_check.route("/",methods=['POST'])
def CreateCapture() :
    if request.method =='POST' :
        img = ImageGrab.grab()
        img.save('capture_img.png')
        
        return make_response(jsonify(SUCCESS=True),200)

    
# 출석확인  
# /checks/attendance/<classIdx>
@blue_check.route("/attendance/<int:classIdx>",methods=['POST'])
def CreatesCheck(classIdx) :
    if request.method =='POST' :
        capture_addr = 'C:\\Users\\dumi3\\checkcmate_pro2\\CheckMate_Project\\capture_img.png'
        data = list(Class.find({"classIdx" : classIdx})) # 해당 클래스정보 
        student_img_addr = data[0]['studentImgAddr'] # 해당 클래스의 학생 이미지 경로
        # 학생들의 임베딩값 추출 & 출석확인
        students =Embedding.Create_Check(student_img_addr, capture_addr) # 출석한 학생의 레이블 
        print("출석한 학생은 {}입니다.".format(students))
        classStudentList=list(Student.find({"classIdx" : classIdx},{"_id" : 0, "name":1}))
        
        studentList = [] # 학생의 이름만을 추출 
        for i in range(len(classStudentList)) :
            studentList.append(classStudentList[i]['name'])
            
        noattendance = list(set(studentList) - set(students)) # 모든 학생 중 안온학생을 구함 
        print("출석하지 않은 학생은 {}입니다.".format(noattendance))
        
        x = dt.datetime.now()
        date = str(x.year)+"년 "+str(x.month)+"월 "+str(x.day) + "일"
        Attendance.update_one({"classIdx" : classIdx}, # 날짜와 출석하지 않은 학생 DB에 저장 
                {   "$set" :
                    {date : noattendance }
                }
            ) 
        
        return make_response(jsonify(SUCCESS=True),200)

 

위 코드를 추가하여 해당 클래스의 학생 리스트에서 출석이 확인된 학생을 빼주었다.

결과적으로 출석하지 않은 학생의 리스트만 noattendace리스트에 남게된다.

 

 

 

datetime라이브러리를 이용해 날짜를 구하여 출석을 하지 않은 학생의 리스트를 DB에 저장하는 코드이다. 

 

 

 

 

Postman으로 전송하고

(classIdx ==  9)

 

 

 

 

 

Robo 3T를 이용해 결과를 확인해보면 

 

classIdx가 9인 document를 찾아 오늘 날짜 데이터를 만들어 오지않은 학생의 이름을 삽입하였다. 

이제 문제는 모델의 성능이다. 

 

 

반응형