Pyspark从本地文件读取图像并将其显示在pyspark中

时间:2018-11-13 14:18:02

标签: python pyspark

我的本​​地文件夹中有一些png文件,我想将它们读取为图像并在pyspark中显示为图像。下面是我的代码;

import os
os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages databricks:spark-deep- 
learning:1.1.0-spark2.3-s_2.11 pyspark-shell'

from pyspark.sql import SparkSession
from pyspark.ml.image import ImageSchema
spark = SparkSession.builder.getOrCreate()
sc = spark.sparkContext


# collect all .png files in working dir
direc=C:/Python/deeplearning/*.png

import IPython.display as dp

# create list of image objects
images = []
for ea in direc:
images.append(dp.Image(filename=ea, format='png'))

# display all images
for ea in images:
dp.display_png(ea)

我得到的错误如下:

File "<ipython-input-35-5bb7da3922f3>", line 2
direc= 
      C:/Python/deeplearning/*.png
        ^
SyntaxError: invalid syntax

我该如何解决?谢谢。

0 个答案:

没有答案