더북(TheBook)

이제 hub_model 변수에 로드된 모델을 사용하여 이미지에 대한 객체 탐지를 수행하고, category_index를 활용하여 탐지된 객체의 클래스 ID를 실제 이름으로 변환할 수 있습니다.

다음처럼 cv2를 활용하여 이미지를 불러온 후, 텐서플로 모델에 넣기 위해 이미지를 한 번 더 리스트로 감싼 후 np.array를 사용하여 텐서 형태로 만들어줍니다.

!wget https://raw.githubusercontent.com/Lilcob/test_colab/main/three%20young%20man.jpg
image_path = '/content/three young man.jpg'
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image_np = np.array([image])
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.