错误“\u imageschema”对象没有属性“readimages”

nzkunb0c  于 2021-07-12  发布在  Spark
关注(0)|答案(1)|浏览(392)

正在尝试从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 spark v3.0.2版

cnwbcb6i

cnwbcb6i1#

从spark 2.4开始,可以使用以下格式的dataframereader直接加载图像 image :

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

更多细节可以在这里找到。
使用 ImageSchema.readImages 从那时起,它就被弃用了,并且在spark 3.0.0中删除了该方法

相关问题