웹 시프_20241204
2024.12.04 14:03
!mkdir models img
!gdown --id 1SGVNbOjBoitZw5nHHJQ5A3LL3uDqeznA --output ./img/sample01.jpg
!gdown --id 11dlWfIkDRnJ0BfojfBYbhS9q3Fl2TT1q --output ./img/sample02.jpg
!gdown --id 1U_StuW-A0dgtmzAoY4tOYHrSj5xROJms --output ./img/sample03.jpg
!gdown --id 1uD0u_9kG_gCI5pq8FBa8W6kmjQjYk1vn --output ./img/sample04.jpg
!gdown --id 1mQdvtEW2pwVslQ7bZb3OLtrr-LzA0cVa --output ./img/sample05.jpg
!gdown --id 1mLB3UZ0hgVPXguPRedHtb1UWAy2nlUyF --output ./models/pts_in_hull.npy
!gdown --id 16nCigXxDjH7KKyZxJ-KvE-Zlv79ZO-mz --output ./models/colorization_deploy.prototxt
!gdown --id 1PgvjpEId1mlX7i4MqNfsJeoiB1rJfxJ3 --output ./models/colorization_release.caffemodel
!gdown --id 1Zk3Tv2PRMhnJQR6sEjla8V4idUt2rJBC --output ./models/colorization_release_norebal.caffemodel
import cv2
import numpy as np
import matplotlib.pyplot as plt
proto = './models/colorization_deploy.prototxt'
weight = './models/colorization_release.caffemodel'
pts_in_hull = np.load('./models/pts_in_hull.npy')
pts_in_hull = pts_in_hull.transpose().reshape(2, 313, 1, 1).astype(np.float32)
net = cv2.dnn.readNetFromCaffe(proto, weight)
net.getLayer(net.getLayerId('class8_ab')).blobs = [pts_in_hull]
net.getLayer(net.getLayerId('conv8_313_rh')).blobs = [np.full((1, 313), 2.606, np.float32)]
img_path = './img/sample05.jpg'
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
img_input = img.copy()
#convert BGR to RGB
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
img_rgb = img.copy()
#normalize input
img_rgb = (img_rgb / 255.).astype(np.float32)
img_lab = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2LAB)
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
» | 웹 시프_20241204 | setUID | 2024.12.04 | 36 |
5 | 웹 시프_model_20241120 | setUID | 2024.11.20 | 46 |
4 | 웹시스템프로그래밍_word embedding | setUID | 2024.11.06 | 74 |
3 | 시스템 프로그래밍 1차 과제 | setUID | 2024.10.04 | 243 |
2 | minecraft assets | setUID | 2024.10.02 | 84 |
1 | 2주차 시스템 프로그래밍 | setUID | 2024.09.13 | 241 |