Python 错误:'&燃气轮机';在';非类型';和';int';

Python 错误:'&燃气轮机';在';非类型';和';int';,python,error-handling,compiler-errors,jupyter-notebook,syntax-error,Python,Error Handling,Compiler Errors,Jupyter Notebook,Syntax Error,我正在尝试运行此代码,但是我得到了TypeError:“>”在“NoneType”和“int”的实例之间不受支持。如何删除此错误?我仍然是python的初学者。希望有人能帮助我 author = 'Rocco' import math import numpy as np import cv2 from skimage import feature from scipy import ndimage class PHogFeature

我正在尝试运行此代码,但是我得到了TypeError:“>”在“NoneType”和“int”的实例之间不受支持。如何删除此错误?我仍然是python的初学者。希望有人能帮助我

author = 'Rocco'

    import math
    
    import numpy as np 
    import cv2 from skimage 
    import feature from scipy 
    import ndimage 

class PHogFeatures(): 
def init(self): 
pass
    
    def get_features(self, image_path, bins=8, angle=360., pyramid_levels=3):

        feature_vec = self.phog(image_path, bins, angle, pyramid_levels)
        feature_vec = feature_vec.T[0]  # Transpose vector, take the first array
        return feature_vec

    def phog(self, image_path, bin, angle, pyramid_levels): 
         grayscale_img = cv2.imread(r'C:\Users\user\Documents\FYP\Dataset\Train', 0) # 0 converts it to grayscale 
         bh = np.array([]) 
         bv = np.array([])
    
    if np.sum(np.sum(grayscale_img)) > 100.:
         edges_canny = feature.canny(grayscale_img, sigma=math.sqrt(2)) 
         [GradientY, GradientX] = np.gradient(np.double(grayscale_img)) 
         GradientYY = np.gradient(GradientY)[1] # Take only the first matrix 
         Gr = np.sqrt((GradientX * GradientX + GradientY * GradientY))
    
         index = GradientX == 0.
         index = index.astype(int)  # Convert boolean array to an int array
         GradientX[np.where(index > 0)] = np.power(10, -5)
         YX = GradientY / GradientX

cv2.imread的参数不应该指向文件吗?当前它看起来像一个目录路径。你能键入回溯而不是链接图像吗?另外,你能修正你的缩进,使它与你的核心相匹配吗?您现在使用的语法无效。请参阅