kookmin-sw / capstone-2023-08

capstone-2023-08 created by GitHub Classroom
1 stars 4 forks source link

DL API 구현 #29

Closed dh5473 closed 1 year ago

dh5473 commented 1 year ago

진행상황 공유

DL 파트 현재 진행상황 공유드립니다! 크게 3가지 과정으로 진행되는데, 오래 걸리는 human_parsing 과정과 나머지 과정을 나누었습니다. 실제 실행은 utils.py를 통해 각 모델로 연결됩니다.

프론트 혹은 back이 되었든 request로 받아야 할 정보는 다음과 같습니다.

  1. uid
  2. 촬영자 이미지 저장 경로
  3. 촬영자 이미지 segmentation 처리 후 저장 경로
  4. 촬영자 human_parsing_keypoints (json) 저장 경로
class HumanParsing(APIView):
    def post(self, request):
        info = StoragePathSerializer(data=request.data)
        human = PreprocessingHumanImg(info['user_id'],
                                      info['human_img_path'],
                                      info['preprocessing_human_img_path'],
                                      info['human_parsing_keypoints_path']
                                      )
        try:
            human.parsing_human_pose()
        except:  
            return Response("failed", status=status.HTTP_400_BAD_REQUEST)

        return Response("success", status=status.HTTP_201_CREATED) 


아래 API는 옷 이미지 전처리와 최종 이미지 결과 모델을 처리하는 기능입니다.
request로 uid 정보만 받으면, 나머지는 EC2에서 (휘발성 메모리 혹은 컨테이너 메모리) 처리할 예정입니다.

class Inference(APIView):
    def post(self, request):
        info = StoragePathSerializer(data=request.data)
        cloth = InferenceImg(info['user_id'],
                             info['cloth_img_path'],
                             info['preprocessing_cloth_img_path'],
                             info['result_img_path']
                             )
        try:
            cloth.preprocessing_cloth()
            cloth.inference()
        except:  
            return Response("failed", status=status.HTTP_400_BAD_REQUEST)

        return Response("success", status=status.HTTP_201_CREATED)