Win10環境下基於TensorFlow實現灰度圖着色

一、環境:Win10+Pycharm+TensorFlow(1.15)+Python3.6
二、示例代碼
基於訓練模型,加載以及預處理圖像如下:

def load_image(path):
    img = imread(path)
    # crop image from center
    short_edge = min(img.shape[:2])
    yy = int((img.shape[0] - short_edge) / 2)
    xx = int((img.shape[1] - short_edge) / 2)
    crop_img = img[yy : yy + short_edge, xx : xx + short_edge]
    # resize img to (224,224)
    img = skimage.transform.resize(crop_img, (224, 224))
    # desaturate image
    return (img[:,:,0] + img[:,:,1] + img[:,:,2]) / 3.0

三、測試效果
由於項目需要,基於TensorFlow實現灰度圖着色,看了一些相關的開源代碼並進行測試,上色效果還可以,測試效果如下所示:
原圖:
在這裏插入圖片描述
着色效果圖如下:
在這裏插入圖片描述
模型下載
提取碼:eu51
整體着色效果還可以。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章