错误“_ImageSchema”对象没有属性 'readImages'

ERROR '_ImageSchema' object has no attribute 'readImages'

正在尝试从 pyspark 中的文件夹加载图像

from pyspark.ml.image import ImageSchema
from pyspark.sql.functions import lit

zero_df = ImageSchema.readImages('../Transfer-Learning- 
PySpark/images/o').withColumn("label",lit(0))

抛出错误

     AttributeError                            Traceback (most recent call last)
     <ipython-input-9-29c9b120f9c2> in <module>
                   2 from pyspark.sql.functions import lit
                    3 
     ----> 4 zero_df = ImageSchema.readImages('../Transfer-Learning- 
     PySpark/images/o').withColumn("label",lit(0))

     AttributeError: '_ImageSchema' object has no attribute 'readImages'

Python 3.8 星火 v3.0.2

从 Spark 2.4 开始,可以使用 DataFrameReader 格式直接加载图像 image:

zero_df = spark.read.format("image").load(<path to files>)

可以找到更多详细信息 here

从那时起 ImageSchema.readImages 的用法一直 deprecated 并且该方法已在 Spark 3.0.0

中删除