From 5203e3df96552d4f723d24c93051fa11dfb404d0 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 29 Oct 2021 14:09:19 +0800 Subject: [PATCH 1/2] docs: introduce MosaicViews as dataset preview utils --- docs/Project.toml | 3 +++ docs/src/index.md | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/Project.toml b/docs/Project.toml index dfa65cd1..a7e01068 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,2 +1,5 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" +ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" +ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31" diff --git a/docs/src/index.md b/docs/src/index.md index efa74fb6..28a6e4e5 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -55,3 +55,22 @@ will trigger a download dialog to `~/.julia/datadeps/MNIST`. To overwrite this on a case by case basis, it is possible to specify a data directory directly in `traindata(dir = )` and `testdata(dir = )`. + +## Preview + +For image dataset, [`MosaicViews`](https://github.com/JuliaArrays/MosaicViews.jl) provides a very simple interface to display a list +of images. + +```@example +using MLDatasets +# Alternatively, you can also just call `using Images` +using ImageCore, ImageShow + +# The original dataset is stored in row-major order, +# to display it normally in Julia, we need to permute the +# first two dimensions. +test_x = Gray.(PermutedDimsArray(MNIST.testtensor(), (2, 1, 3))); +test_x_sample = @view test_x[:, :, 1:64]; + +mosaic(test_x_sample, nrow=8) +``` From d1ab62295597171743784c2291240ad1c08c99f7 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 29 Oct 2021 14:21:38 +0800 Subject: [PATCH 2/2] move ImageShow to make.jl and add missing docs dependency When building documentation locally we need to manually do `]dev .` to tell Julia use dev version of MLDatasets, and this immediately updates the Project.toml file, to keep it complete I commit this change . This change won't affect docs CI. --- docs/Project.toml | 1 + docs/make.jl | 5 +++-- docs/src/index.md | 8 +++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index a7e01068..11387b51 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -3,3 +3,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31" +MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458" diff --git a/docs/make.jl b/docs/make.jl index 71aa5542..9523a925 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,4 +1,5 @@ using Documenter, MLDatasets +using ImageShow # for better image display ## Commented out since gives warning # DocMeta.setdocmeta!(MLDatasets, :DocTestSetup, :(using MLDatasets); recursive=true) @@ -34,7 +35,7 @@ makedocs( "Iris" => "datasets/Iris.md", "Boston Housing" => "datasets/BostonHousing.md", ], - + "Text" => Any[ "PTBLM" => "datasets/PTBLM.md", "UD_English" => "datasets/UD_English.md", @@ -54,4 +55,4 @@ makedocs( ) -deploydocs(repo = "github.com/JuliaML/MLDatasets.jl.git") \ No newline at end of file +deploydocs(repo = "github.com/JuliaML/MLDatasets.jl.git") diff --git a/docs/src/index.md b/docs/src/index.md index 28a6e4e5..6cb7b14b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -63,12 +63,10 @@ of images. ```@example using MLDatasets -# Alternatively, you can also just call `using Images` -using ImageCore, ImageShow +using ImageCore -# The original dataset is stored in row-major order, -# to display it normally in Julia, we need to permute the -# first two dimensions. +# The original dataset is stored in row-major order, to display it +# normally in Julia, we need to permute the first two dimensions. test_x = Gray.(PermutedDimsArray(MNIST.testtensor(), (2, 1, 3))); test_x_sample = @view test_x[:, :, 1:64];