鱼C论坛

 找回密码
 立即注册
查看: 3873|回复: 11

[已解决]为什么出现错误if src_img.ndim != 3: AttributeError: 'NoneType' object has no ...

[复制链接]
发表于 2020-3-28 14:55:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 一个账号 于 2020-3-28 15:22 编辑
  1. import sys
  2. import os
  3. import numpy as np
  4. import cv2
  5. import tensorflow as tf

  6. from sklearn.model_selection import train_test_split


  7. class plate_cnn_net:
  8.     def __init__(self):
  9.         self.img_w,self.img_h = 136,36
  10.         self.y_size = 2
  11.         self.batch_size = 100
  12.         self.learn_rate = 0.001

  13.         self.x_place = tf.placeholder(dtype=tf.float32, shape=[None, self.img_h, self.img_w, 3], name='x_place')
  14.         self.y_place = tf.placeholder(dtype=tf.float32, shape=[None, self.y_size], name='y_place')
  15.         self.keep_place = tf.placeholder(dtype=tf.float32, name='keep_place')

  16.     def cnn_construct(self):
  17.         x_input = tf.reshape(self.x_place, shape=[-1, self.img_h, self.img_w, 3])

  18.         cw1 = tf.Variable(tf.random_normal(shape=[3, 3, 3, 32], stddev=0.01), dtype=tf.float32)
  19.         cb1 = tf.Variable(tf.random_normal(shape=[32]), dtype=tf.float32)
  20.         conv1 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(x_input, filter=cw1, strides=[1, 1, 1, 1], padding='SAME'), cb1))
  21.         conv1 = tf.nn.max_pool(conv1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  22.         conv1 = tf.nn.dropout(conv1, self.keep_place)

  23.         cw2 = tf.Variable(tf.random_normal(shape=[3, 3, 32, 64], stddev=0.01), dtype=tf.float32)
  24.         cb2 = tf.Variable(tf.random_normal(shape=[64]), dtype=tf.float32)
  25.         conv2 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(conv1, filter=cw2, strides=[1, 1, 1, 1], padding='SAME'), cb2))
  26.         conv2 = tf.nn.max_pool(conv2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  27.         conv2 = tf.nn.dropout(conv2, self.keep_place)

  28.         cw3 = tf.Variable(tf.random_normal(shape=[3, 3, 64, 128], stddev=0.01), dtype=tf.float32)
  29.         cb3 = tf.Variable(tf.random_normal(shape=[128]), dtype=tf.float32)
  30.         conv3 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(conv2, filter=cw3, strides=[1, 1, 1, 1], padding='SAME'), cb3))
  31.         conv3 = tf.nn.max_pool(conv3, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  32.         conv3 = tf.nn.dropout(conv3, self.keep_place)

  33.         conv_out = tf.reshape(conv3, shape=[-1, 17 * 5 * 128])

  34.         fw1 = tf.Variable(tf.random_normal(shape=[17 * 5 * 128, 1024], stddev=0.01), dtype=tf.float32)
  35.         fb1 = tf.Variable(tf.random_normal(shape=[1024]), dtype=tf.float32)
  36.         fully1 = tf.nn.relu(tf.add(tf.matmul(conv_out, fw1), fb1))
  37.         fully1 = tf.nn.dropout(fully1, self.keep_place)

  38.         fw2 = tf.Variable(tf.random_normal(shape=[1024, 1024], stddev=0.01), dtype=tf.float32)
  39.         fb2 = tf.Variable(tf.random_normal(shape=[1024]), dtype=tf.float32)
  40.         fully2 = tf.nn.relu(tf.add(tf.matmul(fully1, fw2), fb2))
  41.         fully2 = tf.nn.dropout(fully2, self.keep_place)

  42.         fw3 = tf.Variable(tf.random_normal(shape=[1024, self.y_size], stddev=0.01), dtype=tf.float32)
  43.         fb3 = tf.Variable(tf.random_normal(shape=[self.y_size]), dtype=tf.float32)
  44.         fully3 = tf.add(tf.matmul(fully2, fw3), fb3, name='out_put')

  45.         return fully3

  46.     def train(self,data_dir,model_save_path):
  47.         print('ready load train dataset')
  48.         X, y = self.init_data(data_dir)
  49.         # print("===")
  50.         # print(X)
  51.         # print(y)
  52.         # print("===")
  53.         print('success load ' + str(len(y)) + ' datas')
  54.         train_x, test_x, train_y, test_y = train_test_split(X, y, test_size=0.2, random_state=0)

  55.         out_put = self.cnn_construct()
  56.         predicts = tf.nn.softmax(out_put)
  57.         predicts = tf.argmax(predicts, axis=1)
  58.         actual_y = tf.argmax(self.y_place, axis=1)
  59.         accuracy = tf.reduce_mean(tf.cast(tf.equal(predicts, actual_y), dtype=tf.float32))
  60.         cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=out_put, labels=self.y_place))
  61.         opt = tf.train.AdamOptimizer(self.learn_rate)
  62.         train_step = opt.minimize(cost)

  63.         with tf.Session() as sess:
  64.             init = tf.global_variables_initializer()
  65.             sess.run(init)
  66.             step = 0
  67.             saver = tf.train.Saver()
  68.             while True:
  69.                 train_index = np.random.choice(len(train_x), self.batch_size, replace=False)
  70.                 train_randx = train_x[train_index]
  71.                 train_randy = train_y[train_index]
  72.                 _, loss = sess.run([train_step, cost], feed_dict={self.x_place: train_randx,
  73.                                                                   self.y_place: train_randy, self.keep_place: 0.75})
  74.                 step += 1
  75.                 print(step, loss)

  76.                 if step % 10 == 0:
  77.                     test_index = np.random.choice(len(test_x), self.batch_size, replace=False)
  78.                     test_randx = test_x[test_index]
  79.                     test_randy = test_y[test_index]
  80.                     acc = sess.run(accuracy, feed_dict={self.x_place: test_randx,
  81.                                                         self.y_place: test_randy, self.keep_place: 1.0})
  82.                     print('accuracy:' + str(acc))
  83.                     if acc > 0.99 and step > 500:
  84.                         saver.save(sess, model_save_path, global_step=step)
  85.                         break

  86.     def test(self,x_images,model_path):
  87.         out_put = self.cnn_construct()
  88.         predicts = tf.nn.softmax(out_put)
  89.         probabilitys = tf.reduce_max(predicts, reduction_indices=[1])
  90.         predicts = tf.argmax(predicts, axis=1)
  91.         saver = tf.train.Saver()
  92.         with tf.Session() as sess:
  93.             sess.run(tf.global_variables_initializer())
  94.             saver.restore(sess, model_path)
  95.             preds, probs = sess.run([predicts, probabilitys], feed_dict={self.x_place: x_images, self.keep_place: 1.0})
  96.         return preds,probs

  97.     def list_all_files(self,root):
  98.         files = []
  99.         list = os.listdir(root)
  100.         for i in range(len(list)):
  101.             element = os.path.join(root, list[i])
  102.             if os.path.isdir(element):
  103.                 files.extend(self.list_all_files(element))
  104.             elif os.path.isfile(element):
  105.                 files.append(element)
  106.         return files

  107.     def init_data(self,dir):
  108.         print(dir)
  109.         X = []
  110.         y = []
  111.         if not os.path.exists(dir):
  112.             raise ValueError('没有找到文件夹')
  113.         files = self.list_all_files(dir)
  114.         print()
  115.         labels = [os.path.split(os.path.dirname(file))[-1] for file in files]
  116.         print(labels)
  117.         print(len(labels))

  118.         for i, file in enumerate(files):
  119.             src_img = cv2.imread(file)
  120.             if src_img.ndim != 3:
  121.                 continue
  122.             resize_img = cv2.resize(src_img, (136, 36))
  123.             X.append(resize_img)
  124.             y.append([[0, 1] if labels[i] == 'has' else [1, 0]])

  125.         X = np.array(X)
  126.         y = np.array(y).reshape(-1, 2)
  127.         return X, y

  128.     def init_testData(self,dir):
  129.         test_X = []
  130.         if not os.path.exists(dir):
  131.             raise ValueError('没有找到文件夹')
  132.         files = self.list_all_files(dir)
  133.         for file in files:
  134.             src_img = cv2.imread(file, cv2.COLOR_BGR2GRAY)
  135.             if src_img.ndim != 3:
  136.                 continue
  137.             resize_img = cv2.resize(src_img, (136, 36))
  138.             test_X.append(resize_img)
  139.         test_X = np.array(test_X)
  140.         return test_X


  141. if __name__ == '__main__':
  142.     cur_dir = sys.path[0]
  143.     print(cur_dir)
  144.     data_dir = os.path.join(cur_dir, './carIdentityData/cnn_plate_train')
  145.     print(data_dir)
  146.     test_dir = os.path.join(cur_dir, './carIdentityData/cnn_plate_test')
  147.     train_model_path = os.path.join(cur_dir, './carIdentityData/model/plate_recongnize/model.ckpt')
  148.     model_path = os.path.join(cur_dir,'./carIdentityData/model/plate_recongnize/model.ckpt-510')

  149.     train_flag = 0
  150.     net = plate_cnn_net()

  151.     if train_flag == 1:
  152.         # 训练模型
  153.         net.train(data_dir,train_model_path)
  154.     else:
  155.         # 测试部分
  156.         test_X = net.init_testData(test_dir)
  157.         preds,probs = net.test(test_X,model_path)
  158.         for i in range(len(preds)):
  159.             pred = preds[i].astype(int)
  160.             prob = probs[i]
  161.             if pred == 1:
  162.                 print('plate',prob)
  163.             else:
  164.                 print('no',prob)
复制代码




最佳答案
2020-3-29 11:11:59
不是很清楚了吗,此时src_img 是 None
再打印一下此时的file文件,肯定不是图片
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-3-28 14:57:18 | 显示全部楼层
  1. if src_img.ndim != 3:
  2. AttributeError: 'NoneType' object has no attribute 'ndim'
复制代码



刚刚提交的时候无法使用代码格式。

为什么会出现错误:if src_img.ndim != 3:
AttributeError: 'NoneType' object has no attribute 'ndim'

明明前一分钟运行的时候还没有这个错误,为什么现在运行就有了。该有的文件夹都有阿
求明白的人指点迷津~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-28 14:58:37 | 显示全部楼层
刚刚提交的时候无法使用代码格式。
  1. import sys
  2. import os
  3. import numpy as np
  4. import cv2
  5. import tensorflow as tf

  6. from sklearn.model_selection import train_test_split


  7. class plate_cnn_net:
  8.     def __init__(self):
  9.         self.img_w,self.img_h = 136,36
  10.         self.y_size = 2
  11.         self.batch_size = 100
  12.         self.learn_rate = 0.001

  13.         self.x_place = tf.placeholder(dtype=tf.float32, shape=[None, self.img_h, self.img_w, 3], name='x_place')
  14.         self.y_place = tf.placeholder(dtype=tf.float32, shape=[None, self.y_size], name='y_place')
  15.         self.keep_place = tf.placeholder(dtype=tf.float32, name='keep_place')

  16.     def cnn_construct(self):
  17.         x_input = tf.reshape(self.x_place, shape=[-1, self.img_h, self.img_w, 3])

  18.         cw1 = tf.Variable(tf.random_normal(shape=[3, 3, 3, 32], stddev=0.01), dtype=tf.float32)
  19.         cb1 = tf.Variable(tf.random_normal(shape=[32]), dtype=tf.float32)
  20.         conv1 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(x_input, filter=cw1, strides=[1, 1, 1, 1], padding='SAME'), cb1))
  21.         conv1 = tf.nn.max_pool(conv1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  22.         conv1 = tf.nn.dropout(conv1, self.keep_place)

  23.         cw2 = tf.Variable(tf.random_normal(shape=[3, 3, 32, 64], stddev=0.01), dtype=tf.float32)
  24.         cb2 = tf.Variable(tf.random_normal(shape=[64]), dtype=tf.float32)
  25.         conv2 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(conv1, filter=cw2, strides=[1, 1, 1, 1], padding='SAME'), cb2))
  26.         conv2 = tf.nn.max_pool(conv2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  27.         conv2 = tf.nn.dropout(conv2, self.keep_place)

  28.         cw3 = tf.Variable(tf.random_normal(shape=[3, 3, 64, 128], stddev=0.01), dtype=tf.float32)
  29.         cb3 = tf.Variable(tf.random_normal(shape=[128]), dtype=tf.float32)
  30.         conv3 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(conv2, filter=cw3, strides=[1, 1, 1, 1], padding='SAME'), cb3))
  31.         conv3 = tf.nn.max_pool(conv3, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
  32.         conv3 = tf.nn.dropout(conv3, self.keep_place)

  33.         conv_out = tf.reshape(conv3, shape=[-1, 17 * 5 * 128])

  34.         fw1 = tf.Variable(tf.random_normal(shape=[17 * 5 * 128, 1024], stddev=0.01), dtype=tf.float32)
  35.         fb1 = tf.Variable(tf.random_normal(shape=[1024]), dtype=tf.float32)
  36.         fully1 = tf.nn.relu(tf.add(tf.matmul(conv_out, fw1), fb1))
  37.         fully1 = tf.nn.dropout(fully1, self.keep_place)

  38.         fw2 = tf.Variable(tf.random_normal(shape=[1024, 1024], stddev=0.01), dtype=tf.float32)
  39.         fb2 = tf.Variable(tf.random_normal(shape=[1024]), dtype=tf.float32)
  40.         fully2 = tf.nn.relu(tf.add(tf.matmul(fully1, fw2), fb2))
  41.         fully2 = tf.nn.dropout(fully2, self.keep_place)

  42.         fw3 = tf.Variable(tf.random_normal(shape=[1024, self.y_size], stddev=0.01), dtype=tf.float32)
  43.         fb3 = tf.Variable(tf.random_normal(shape=[self.y_size]), dtype=tf.float32)
  44.         fully3 = tf.add(tf.matmul(fully2, fw3), fb3, name='out_put')

  45.         return fully3

  46.     def train(self,data_dir,model_save_path):
  47.         print('ready load train dataset')
  48.         X, y = self.init_data(data_dir)
  49.         # print("===")
  50.         # print(X)
  51.         # print(y)
  52.         # print("===")
  53.         print('success load ' + str(len(y)) + ' datas')
  54.         train_x, test_x, train_y, test_y = train_test_split(X, y, test_size=0.2, random_state=0)

  55.         out_put = self.cnn_construct()
  56.         predicts = tf.nn.softmax(out_put)
  57.         predicts = tf.argmax(predicts, axis=1)
  58.         actual_y = tf.argmax(self.y_place, axis=1)
  59.         accuracy = tf.reduce_mean(tf.cast(tf.equal(predicts, actual_y), dtype=tf.float32))
  60.         cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=out_put, labels=self.y_place))
  61.         opt = tf.train.AdamOptimizer(self.learn_rate)
  62.         train_step = opt.minimize(cost)

  63.         with tf.Session() as sess:
  64.             init = tf.global_variables_initializer()
  65.             sess.run(init)
  66.             step = 0
  67.             saver = tf.train.Saver()
  68.             while True:
  69.                 train_index = np.random.choice(len(train_x), self.batch_size, replace=False)
  70.                 train_randx = train_x[train_index]
  71.                 train_randy = train_y[train_index]
  72.                 _, loss = sess.run([train_step, cost], feed_dict={self.x_place: train_randx,
  73.                                                                   self.y_place: train_randy, self.keep_place: 0.75})
  74.                 step += 1
  75.                 print(step, loss)

  76.                 if step % 10 == 0:
  77.                     test_index = np.random.choice(len(test_x), self.batch_size, replace=False)
  78.                     test_randx = test_x[test_index]
  79.                     test_randy = test_y[test_index]
  80.                     acc = sess.run(accuracy, feed_dict={self.x_place: test_randx,
  81.                                                         self.y_place: test_randy, self.keep_place: 1.0})
  82.                     print('accuracy:' + str(acc))
  83.                     if acc > 0.99 and step > 500:
  84.                         saver.save(sess, model_save_path, global_step=step)
  85.                         break

  86.     def test(self,x_images,model_path):
  87.         out_put = self.cnn_construct()
  88.         predicts = tf.nn.softmax(out_put)
  89.         probabilitys = tf.reduce_max(predicts, reduction_indices=[1])
  90.         predicts = tf.argmax(predicts, axis=1)
  91.         saver = tf.train.Saver()
  92.         with tf.Session() as sess:
  93.             sess.run(tf.global_variables_initializer())
  94.             saver.restore(sess, model_path)
  95.             preds, probs = sess.run([predicts, probabilitys], feed_dict={self.x_place: x_images, self.keep_place: 1.0})
  96.         return preds,probs

  97.     def list_all_files(self,root):
  98.         files = []
  99.         list = os.listdir(root)
  100.         for i in range(len(list)):
  101.             element = os.path.join(root, list[i])
  102.             if os.path.isdir(element):
  103.                 files.extend(self.list_all_files(element))
  104.             elif os.path.isfile(element):
  105.                 files.append(element)
  106.         return files

  107.     def init_data(self,dir):
  108.         print(dir)
  109.         X = []
  110.         y = []
  111.         if not os.path.exists(dir):
  112.             raise ValueError('没有找到文件夹')
  113.         files = self.list_all_files(dir)
  114.         print()
  115.         labels = [os.path.split(os.path.dirname(file))[-1] for file in files]
  116.         print(labels)
  117.         print(len(labels))

  118.         for i, file in enumerate(files):
  119.             src_img = cv2.imread(file)
  120.             if src_img.ndim != 3:
  121.                 continue
  122.             resize_img = cv2.resize(src_img, (136, 36))
  123.             X.append(resize_img)
  124.             y.append([[0, 1] if labels[i] == 'has' else [1, 0]])

  125.         X = np.array(X)
  126.         y = np.array(y).reshape(-1, 2)
  127.         return X, y

  128.     def init_testData(self,dir):
  129.         test_X = []
  130.         if not os.path.exists(dir):
  131.             raise ValueError('没有找到文件夹')
  132.         files = self.list_all_files(dir)
  133.         for file in files:
  134.             src_img = cv2.imread(file, cv2.COLOR_BGR2GRAY)
  135.             if src_img.ndim != 3:
  136.                 continue
  137.             resize_img = cv2.resize(src_img, (136, 36))
  138.             test_X.append(resize_img)
  139.         test_X = np.array(test_X)
  140.         return test_X


  141. if __name__ == '__main__':
  142.     cur_dir = sys.path[0]
  143.     print(cur_dir)
  144.     data_dir = os.path.join(cur_dir, './carIdentityData/cnn_plate_train')
  145.     print(data_dir)
  146.     test_dir = os.path.join(cur_dir, './carIdentityData/cnn_plate_test')
  147.     train_model_path = os.path.join(cur_dir, './carIdentityData/model/plate_recongnize/model.ckpt')
  148.     model_path = os.path.join(cur_dir,'./carIdentityData/model/plate_recongnize/model.ckpt-510')

  149.     train_flag = 0
  150.     net = plate_cnn_net()

  151.     if train_flag == 1:
  152.         # 训练模型
  153.         net.train(data_dir,train_model_path)
  154.     else:
  155.         # 测试部分
  156.         test_X = net.init_testData(test_dir)
  157.         preds,probs = net.test(test_X,model_path)
  158.         for i in range(len(preds)):
  159.             pred = preds[i].astype(int)
  160.             prob = probs[i]
  161.             if pred == 1:
  162.                 print('plate',prob)
  163.             else:
  164.                 print('no',prob)
复制代码


为什么会出现错误:if src_img.ndim != 3:
AttributeError: 'NoneType' object has no attribute 'ndim'

明明前一分钟运行的时候还没有这个错误,为什么现在运行就有了。该有的文件夹都有阿
求明白的人指点迷津~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-28 14:58:34 | 显示全部楼层
说明cv2读取的文件不对,检查一下路径
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-28 15:27:44 | 显示全部楼层
BngThea 发表于 2020-3-28 14:58
说明cv2读取的文件不对,检查一下路径

检查过了  奇怪的是 我上一秒都还能执行 下一秒就不能了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-28 15:31:27 | 显示全部楼层
愿你 发表于 2020-3-28 15:27
检查过了  奇怪的是 我上一秒都还能执行 下一秒就不能了

你检查一下files变量,是不是有些不是图片
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-29 09:55:54 | 显示全部楼层
BngThea 发表于 2020-3-28 15:31
你检查一下files变量,是不是有些不是图片

都是图片呀
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-29 09:59:10 | 显示全部楼层

用try捕捉一下异常,然后打印对应的 src_img
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-29 10:22:12 | 显示全部楼层
BngThea 发表于 2020-3-29 09:59
用try捕捉一下异常,然后打印对应的 src_img
  1.     def init_testData(self,dir):
  2.         test_X = []
  3.         if not os.path.exists(dir):
  4.             raise ValueError('没有找到文件夹')
  5.         files = self.list_all_files(dir)
  6.         for file in files:
  7.             src_img = cv2.imread(file, cv2.COLOR_BGR2GRAY)
  8.             try:
  9.                 if src_img.ndim != 3:
  10.                     continue
  11.             except Exception as ex:
  12.                 print("发生异常")
  13.                 print(src_img)
  14.             resize_img = cv2.resize(src_img, (136, 36))
  15.             test_X.append(resize_img)
  16.         test_X = np.array(test_X)
  17.         return test_X
复制代码


报错信息:
  1. Traceback (most recent call last):
  2.   File "D:/pycharm/djangocode/project6/python_LPR/newcode/plateNeuralNet.py", line 200, in <module>
  3.     test_X = net.init_testData(test_dir)
  4.   File "D:/pycharm/djangocode/project6/python_LPR/newcode/plateNeuralNet.py", line 177, in init_testData
  5.     resize_img = cv2.resize(src_img, (136, 36))
  6. cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

  7. 发生异常
  8. None
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-29 11:11:59 | 显示全部楼层    本楼为最佳答案   
不是很清楚了吗,此时src_img 是 None
再打印一下此时的file文件,肯定不是图片
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-31 21:06:58 | 显示全部楼层
BngThea 发表于 2020-3-29 11:11
不是很清楚了吗,此时src_img 是 None
再打印一下此时的file文件,肯定不是图片

可能是因为有几张有了中文 现在可以啦 谢谢~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-11-20 11:34:05 | 显示全部楼层
你好,我也出现和你一样的问题,但我测试后发现src_img返回值为空,file返回值为E:\新建文件夹 (4)\CarPlateIdentity-master\code\carIdentityData/cnn_char_train\0\111-4.jpg,这是什么错误啊?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-29 23:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表