重组c#读取的图片一维数组为rgb图片或单通道灰度图图片

在keras+tensorflow框架下训练的权重可以在tf.keras.models.load_model调用,不必重新训练。
同理,keras+tensorflow框架下的function,在这些function前加tf.同样可以实现原框架下的功能。

import numpy as np
import tensorflow as tf
import cv2
import os

class MODEL_lug(object):
    def __init__(self):
        self.model=tf.keras.models.load_model('C:\\Users\\18367\\Desktop\\corner_test\\0324_lug_irv2.h5')
    def predict(self,image_lug,width,height):
        image_temp = np.zeros((height,width,3),dtype = np.uint8)
        for channel in np.arange(3):
            for j in np.arange(height):
                for i in np.arange(width):
                    image_temp[j,i,channel]=image_lug[width*j*3+i*3+channel]
        image_input = np.zeros((height, width, 3), dtype=np.uint8)
        image_input[:, :, 0] = image_temp[:, :, 2]
        image_input[:, :, 1] = image_temp[:, :, 1]
        image_input[:, :, 2] = image_temp[:, :, 0]
        image_inpu
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值