본문 바로가기

자료

[Object Detection] Convert Darknet yolov3 model to keras model

728x90

Convert Yolo v3 model to Keras model

 

2-1. 방법 1

* 잘못된 코드 수정해야함 

 

darknet  학습을 통해 만들어진 .weights 파일을

텐서플로우에서 실행하기 위하여 keras 파일인 .h5 파일로 변환할 수 있는 깃헙이다.

 

https://github.com/xiaochus/YOLOv3

 

xiaochus/YOLOv3

Keras implementation of yolo v3 object detection. Contribute to xiaochus/YOLOv3 development by creating an account on GitHub.

github.com

* process_image 함수 시작 전 코드 삽입

image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

 

잘못된 코드 수정

col = np.tile(np.arange(0, grid_w), grid_h).reshape(-1, grid_w)
row = np.tile(np.arange(0, grid_h).reshape(-1, 1), grid_w)
col = col.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)
row = row.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)

 

사용 방법

$ python yad2k.py cfg/yolo.cfg yolov3.weights data/yolo.h5

 

만들어진 .h5 파일을 이용하여 demo 를 실행해볼 수도 있다. 

$ python demo.py
728x90