I have three different PySpark Dataframe containing images. When I print these ImageSchema, I have this :
root
|-- image: struct (nullable = true)
| |-- origin: string (nullable = true)
| |-- height: integer (nullable = true)
| |-- width: integer (nullable = true)
| |-- nChannels: integer (nullable = true)
| |-- mode: integer (nullable = true)
| |-- data: binary (nullable = true)
I want to apply a PCA (or another dimension reduction from Pyspark) on these, but I can't understand how to do this. I think of using pandas_udf, as I see that DeepImageFeaturizer from DataBricks is now deprecated and pandas_udf is now advised, but I can't understand how to use it for this type of data...
# Different examples of lines I saw on tutorials to use pandas_udf
multiple_test_udf = pandas_udf(multiple_test_df['image.data'], returnType=?)
pandas_udf(return_type, PandasUDFType.SCALAR_ITER)
I think that image.data of ImageSchema is the only interesting part in the ImageSchema to apply my PCA, and image.data is the one to be converted as pandas_udf. Also, I think pandas_udf is the input of the PCA. I "just" don't understand how to do these steps in practise...
Thanks for your help ;)
PS : I use :
- Python 3.7
- Pyspark 3.0
- Pandas 0.24 I run my code on a Jupyter Notebook put into an Anaconda 3 server.