简体   繁体   English

OpenCV2 错误:(-215:Assertion failed) 'cv::resize' while training the model

[英]OpenCV2 error: (-215:Assertion failed) 'cv::resize' while training the model

I am trying to train my model but I am getting below error.我正在尝试训练我的 model 但我遇到了错误。 PFB code and error: Code: datasets.py PFB 代码和错误:代码: datasets.py

from numpy import * import csv import cv2 #import util从 numpy 导入 * 导入 csv 导入 cv2 #import util

class C100Dataset: """ X is a feature vector Y is the predictor variable """ tr_x = [] # X (data) of training set. class C100Dataset: """ X 是特征向量 Y 是预测变量 """ tr_x = [] # X(数据)训练集。 tr_y = [] # Y (label) of training set. tr_y = [] # 训练集的 Y(标签)。 ts_x = [] # X (data) of test set. ts_x = [] # 测试集的 X(数据)。 ts_y = [] # Y (label) of test set. ts_y = [] # 测试集的 Y(标签)。 #filename='cifar100.csv' def init (self, filename): ## read the csv for dataset (cifar100.csv, cifar100_lt.csv or cifar100_nl.csv), # # Format: # image file path,classname #filename='cifar100.csv' def init (self, filename): ## read the csv for dataset (cifar100.csv, cifar100_lt.csv or cifar100_nl.csv), # # Format: # image file path,classname

    ### TODO: Read the csv file and make the training and testing set
    ## YOUR CODE HERE
    
    with open(filename) as csvfile:
        reader = csv.reader(csvfile,delimiter=' ', quotechar='|')
        for row in reader:
            
            row[0] = row[0].replace('cifar100','./Downloads/dataset/')
            #try
            x = cv2.resize(cv2.imread(row[0]), dsize=(640, 480))
            
            x = transpose(x, (2, 0, 1))
            if 'train' in row[0].split('/'):
                self.tr_x.append(x)
                self.tr_y.append(row[1])
            else:
                self.ts_x.append(x)
                self.ts_y.append(row[1])

def getDataset(self):
    return [self.tr_x, self.tr_y, self.ts_x, self.ts_y]

Error:错误:

OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-4g0fenxj\opencv\modules\imgproc\src\resize.cpp:4051: error: (-215:Assertion failed).ssize:empty() in function 'cv::resize OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-4g0fenxj\opencv\modules\imgproc\src\resize.cpp:4051:错误:(-215:断言失败) .ssize:empty() 在 function 'cv::resize

Check that you are reading an image with cv2.imread(row[0]) .检查您是否正在使用cv2.imread(row[0])读取图像。 The .ssize.empty() indicates the src for cv2.resize is "empty." .ssize.empty()表示cv2.resizesrc是“空的”。 I can recreate this same error message with a simple test case我可以用一个简单的测试用例重新创建同样的错误消息

import cv2
cv2.resize(cv2.imread('foobar'), dsize=(640, 480))
cv2.error: OpenCV(4.5.2) C:\Users\...\opencv\modules\imgproc\src\resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenCV2 错误:OpenCV(4.5.5) 错误:(-215:Assertion failed) img.channels() == 3 in function 'cv::tracking::impl::TrackerKCFImpl::getSubWindow' - OpenCV2 error: OpenCV(4.5.5) error: (-215:Assertion failed) img.channels() == 3 in function 'cv::tracking::impl::TrackerKCFImpl::getSubWindow' OpenCV 调整大小错误(-215:断言失败) - OpenCV resize error(-215:Assertion Failed) 错误:OpenCV(4.1.0) 错误:(-215:Assertion failed) !ssize.empty() in function 'cv::resize' - error: OpenCV(4.1.0) error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' cv2.resize() - 错误 - OpenCV(4.2.0) - 错误:(-215:Assertion failed) - 循环图像 - cv2.resize() - error - OpenCV(4.2.0) - error: (-215:Assertion failed) - loop over images OpenCV(4.1.2) 错误: (-215:Assertion failed).ssize:empty() in function 'cv::resize' - OpenCV(4.1.2) error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' 此错误的问题: (-215:Assertion failed).ssize:empty() in function 'cv::resize' OpenCV - Problem with this error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' OpenCV 在函数 'cv::resize' 中检索 opencv 错误(-215:Assertion failed)!ssize.empty() - Retrieving opencv error (-215:Assertion failed) !ssize.empty() in function 'cv::resize' cv2.error: OpenCV(4.5.2) resize.cpp:4051: error: (-215:Assertion failed).ssize:empty() in function 'cv::resize' - cv2.error: OpenCV(4.5.2) resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' 错误: (-215:Assertion failed) 使用 openCV 时 - error: (-215:Assertion failed) while using openCV OpenCV(4.2.0),imwrite() 到子文件夹会破坏模块; cv2.error: (-215:Assertion failed).ssize:empty() in function 'cv::resize'`' - OpenCV(4.2.0),imwrite() to a subfolder breaks the module; cv2.error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'`'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM