FluxML/FastAI.jl

Error in reproducing the "Data containers" tutorial: "key :nothing not found"

Closed this issue · 5 comments

I run the following code in Data containers in a Jupyter notebook in VS code.

using FastAI
import FastAI: Image
data, _ = loaddataset("imagenette2-160", (Image, Label))

image, class = obs = getobs(data, 1)
@show class
image

The image cannot be displayed properly with the error info below.

KeyError: key :nothing not found

Stacktrace:
  [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
    @ Base ./dict.jl:481
  [2] _parse_color
    @ ~/.julia/packages/Crayons/u3AH8/src/crayon.jl:143 [inlined]
  [3] #Crayon#1
    @ ~/.julia/packages/Crayons/u3AH8/src/crayon.jl:171 [inlined]
  [4] encodeimg(::ImageInTerminal.SmallBlocks, colordepth::ImageInTerminal.TermColor256, img::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}}, maxheight::Int64, maxwidth::Int64)
    @ ImageInTerminal ~/.julia/packages/ImageInTerminal/aJGpm/src/encodeimg.jl:65
  [5] imshow(io::IOContext{IOBuffer}, img::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}}, colordepth::ImageInTerminal.TermColor256, maxsize::Tuple{Int64, Int64})
    @ ImageInTerminal ~/.julia/packages/ImageInTerminal/aJGpm/src/imshow.jl:31
  [6] imshow(io::IOContext{IOBuffer}, img::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}}, colordepth::ImageInTerminal.TermColor256)
    @ ImageInTerminal ~/.julia/packages/ImageInTerminal/aJGpm/src/imshow.jl:26
  [7] show(io::IOContext{IOBuffer}, mime::MIME{Symbol("text/plain")}, img::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}})
    @ ImageInTerminal ~/.julia/packages/ImageInTerminal/aJGpm/src/ImageInTerminal.jl:67
  [8] limitstringmime(mime::MIME{Symbol("text/plain")}, x::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}})
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/inline.jl:43
  [9] display_mimestring
    @ ~/.julia/packages/IJulia/e8kqU/src/display.jl:71 [inlined]
 [10] display_dict(x::PermutedDimsArray{RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{RGB{FixedPointNumbers.N0f8}}})
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/display.jl:102
 [11] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [12] invokelatest
    @ ./essentials.jl:714 [inlined]
 [13] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/execute_request.jl:112
 [14] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [15] invokelatest
    @ ./essentials.jl:714 [inlined]
 [16] eventloop(socket::ZMQ.Socket)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/eventloop.jl:8
 [17] (::IJulia.var"#15#18")()
    @ IJulia ./task.jl:423

Note that I can display a normal color matrix (i.e., an image) successfully like rand(RGB{Colors.N0f8}, 3, 3).

Try running it in vs code as a .jl file, it'll work fine.

Hi, thanks for the bug report.
This is related to a breakage in Crayons.jl (KristofferC/Crayons.jl#60) and an outdated dependency in DataAugmentation.jl which I am fixing in a new release a right now. Until then, a temporary workaround that works on my machine is running the following before any show* calls.

using Crayons; Crayons.COLORS[:nothing] = Crayons.COLORS[:default]

Try running it in vs code as a .jl file, it'll work fine.

Yes, it worked, though I feel Jupyter is more convenient.

Thanks for the reply @lorenzoh. The workaround indeed behaved well. I will leave this issue open until the next release for others' reference.

New version of DataAugmentation.jl is now released, and I am no longer getting the error, so closing this.