Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more nit updates
  • Loading branch information
WeichenXu123 committed Sep 5, 2018
commit 3c8863c2bd7a4789dd96e849a72eb0aac708abcf
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ package org.apache.spark.ml.source.image
* {{{
* // Scala
* val df = spark.read.format("image")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very cool!

* .option("dropImageFailures", "true")
* .option("dropImageFailures", true)
* .load("data/mllib/images/partitioned")
*
* // Java
* Dataset<Row> df = spark.read().format("image")
* .option("dropImageFailures", "true")
* .option("dropImageFailures", true)
* .load("data/mllib/images/partitioned");
* }}}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ImageFileFormatSuite extends SparkFunSuite with MLlibTestSparkContext {
val df1 = spark.read.format("image").load(imagePath)
assert(df1.count === 9)

val df2 = spark.read.format("image").option("dropImageFailures", "true").load(imagePath)
val df2 = spark.read.format("image").option("dropImageFailures", true).load(imagePath)
assert(df2.count === 8)
}

Expand All @@ -50,11 +50,11 @@ class ImageFileFormatSuite extends SparkFunSuite with MLlibTestSparkContext {

test("image datasource test: read non image") {
val filePath = imagePath + "/cls=kittens/date=2018-01/not-image.txt"
val df = spark.read.format("image").option("dropImageFailures", "true")
val df = spark.read.format("image").option("dropImageFailures", true)
.load(filePath)
assert(df.count() === 0)

val df2 = spark.read.format("image").option("dropImageFailures", "false")
val df2 = spark.read.format("image").option("dropImageFailures", false)
.load(filePath)
assert(df2.count() === 1)
val result = df2.head()
Expand All @@ -64,7 +64,7 @@ class ImageFileFormatSuite extends SparkFunSuite with MLlibTestSparkContext {

test("image datasource partition test") {
val result = spark.read.format("image")
.option("dropImageFailures", "true").load(imagePath)
.option("dropImageFailures", true).load(imagePath)
.select(substring_index(col("image.origin"), "/", -1).as("origin"), col("cls"), col("date"))
.collect()

Expand All @@ -82,7 +82,7 @@ class ImageFileFormatSuite extends SparkFunSuite with MLlibTestSparkContext {

// Images with the different number of channels
test("readImages pixel values test") {
val images = spark.read.format("image").option("dropImageFailures", "true")
val images = spark.read.format("image").option("dropImageFailures", true)
.load(imagePath + "/cls=multichannel/").collect()

val firstBytes20Set = images.map { rrow =>
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/ml/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def readImages(self, path, recursive=False, numPartitions=-1,
:return: a :class:`DataFrame` with a single column of "images",
see ImageSchema for details.

>>> df = ImageSchema.readImages('data/mllib/images/kittens', recursive=True)
>>> df = ImageSchema.readImages('data/mllib/images/origin/kittens', recursive=True)
>>> df.count()
5

Expand Down