Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ShuhuaGao opened this issue Apr 3, 2022 · 5 comments

Comments

@ShuhuaGao
Copy link

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).

@Chandu-4444
Copy link
Contributor

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

@lorenzoh
Copy link
Member

lorenzoh commented Apr 4, 2022

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]

@ShuhuaGao
Copy link
Author

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

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

@ShuhuaGao
Copy link
Author

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

@lorenzoh lorenzoh changed the title Error in reproducing the "Data containers" tutorial Error in reproducing the "Data containers" tutorial: "key :nothing not found" Apr 4, 2022
@lorenzoh
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants