python - 错误:“NoneType”和“int”的实例之间不支持“>”
问题描述
我正在尝试运行此代码,但是出现 TypeError: '>' not supported between '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
解决方案
推荐阅读
- r - 如何提取字符串的剩余子字符串
- python - 从服务器复制文件
- android - FaceDetector.findFaces 准确度参数
- typescript - 为什么 Typescript 在 foreach 中使用匿名函数时不显示错误,但在使用箭头函数时抛出正确的错误?
- java - 从图库中为 CircleImageView 选择照片
- python - Django AttributeError 'CreateUserForm' 对象没有属性 'username'
- scala - 我在哪里可以找到适用于 Pyspark 的 xgboost4j-1.1.2.jar 包的正确版本 sparkxgb.zip?
- r - 如何实现具有可调节列的 R 闪亮表?
- python - 带有跳过标记区域的行的自定义标记
- arrays - Scala Array Copy 的工作方式似乎有所不同