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

Add basic functions for colorspace transforms. #3

Merged
merged 41 commits into from
Jun 22, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
901b875
Add basic functions for colorspace transforms.
SomTambe Jun 7, 2021
093f8b7
Modify docs.
SomTambe Jun 7, 2021
3c39144
Make vector a tuple
SomTambe Jun 7, 2021
684ea01
Removed CUDA from ependency
SomTambe Jun 7, 2021
f714e2a
Add single not for batch dim
SomTambe Jun 7, 2021
9f92224
Add ChainRules dependency
SomTambe Jun 7, 2021
d11a5cb
Added V to LICENSE
SomTambe Jun 8, 2021
f074375
Add tests.
SomTambe Jun 8, 2021
15d1d31
Remove newline from EOF
SomTambe Jun 8, 2021
fbcb568
Add channelify adjoint
SomTambe Jun 9, 2021
9511d4b
sample commit using gpg
SomTambe Jun 9, 2021
26aa7a0
Signed commit
SomTambe Jun 9, 2021
d348861
Add custom adjoints for `colorview`, `channelview`, `(::Colorant{T,N})`
SomTambe Jun 13, 2021
8cd6768
Make necessary changes
SomTambe Jun 13, 2021
76e77ea
\Delta changed to (\Delta...,)
SomTambe Jun 14, 2021
0fe299e
Complete adjoints for `(CT<:Colorant{T})(::Real)`
SomTambe Jun 15, 2021
0141543
Removed debugging line
SomTambe Jun 15, 2021
1a3ec8f
Add tests for `channelify`
SomTambe Jun 16, 2021
721e6c6
Change from symbols to instances
SomTambe Jun 16, 2021
5dcafa6
Few changes
SomTambe Jun 16, 2021
4723f91
Change `<:Color` to `<:Colorant` in `colorify`
SomTambe Jun 16, 2021
52c0207
Add tests for `colorify` and reversibility
SomTambe Jun 16, 2021
be22a5d
Merge branch 'main' of github.com:SomTambe/DiffImages.jl into dev
SomTambe Jun 17, 2021
5fdec09
Added Documenter package
SomTambe Jun 17, 2021
c019c8b
Merge branch 'main' of github.com:SomTambe/DiffImages.jl into dev
SomTambe Jun 17, 2021
02e9085
Make changes
SomTambe Jun 17, 2021
75797b0
Change name of folder from `tests` to `test`
SomTambe Jun 17, 2021
598b427
Add Test dependency
SomTambe Jun 17, 2021
c11cb13
Add `channelview` and `colorview` differentiability tests
SomTambe Jun 17, 2021
62a66a0
Add note for `colorview(T, gray1, gray2...)` adjoint and tests
SomTambe Jun 17, 2021
95e10a9
Change doctests a bit
SomTambe Jun 17, 2021
a71d974
Changed the docstring arguments
SomTambe Jun 17, 2021
2b1e4aa
add requirements
SomTambe Jun 17, 2021
ace5a7f
Add Images to doctests
SomTambe Jun 17, 2021
89b15d5
Add Test dependency
SomTambe Jun 17, 2021
7f4cc3f
Fix CI issue
SomTambe Jun 17, 2021
fae45dd
Add Project.toml file for docs
SomTambe Jun 18, 2021
041507c
remove comments
SomTambe Jun 18, 2021
1bbce28
Commit necessary changes
SomTambe Jun 18, 2021
45e1787
Change `unsqueeze` to `reshape`
SomTambe Jun 21, 2021
f6ddc1a
Add tests for `channelify` and `colorify`
SomTambe Jun 21, 2021
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
87 changes: 62 additions & 25 deletions tests/colors/conversions.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,67 @@
@testset "Colorspace transforms tests" begin
f = Chain(x->HSV.(x),channelify,flatten,Dense(768,16),Dense(16,10),x->σ.(x))
g_3 = Chain(Conv((3,3),7=>4,relu),
Conv((3,3),4=>3,relu),
x->colorify(RGB,x),
x->HSV.(x),
channelify,
flatten,
Dense(256*3,16),
Dense(16,10),
x->σ.(x))
g_1 = Chain(Conv((3,3),7=>4,relu),
Conv((3,3),4=>3,relu),
x->colorify(RGB,x),
x->Gray.(x),
channelify,
flatten,
Dense(256*1,16),
Dense(16,10),
x->σ.(x))
# f = Chain(x->HSV.(x),channelify,flatten,Dense(768,16),Dense(16,10),x->σ.(x))
# g_3 = Chain(Conv((3,3),7=>4,relu),
# Conv((3,3),4=>3,relu),
# x->colorify(RGB,x),
# x->HSV.(x),
# channelify,
# flatten,
# Dense(256*3,16),
# Dense(16,10),
# x->σ.(x))
# g_1 = Chain(Conv((3,3),7=>4,relu),
# Conv((3,3),4=>3,relu),
# x->colorify(RGB,x),
# x->Gray.(x),
# channelify,
# flatten,
# Dense(256*1,16),
# Dense(16,10),
# x->σ.(x))
ds = (7,7,5)
working_cspaces = (:YIQ,
:LCHab,
:Lab,
:BGRA,:ABGR,:BGR,
:RGBA,:ARGB,:RGB,
:HSL,
:AGray,:GrayA,:Gray,
:HSV) # colorspaces those have samplers defined for Base.Random

cspaces = (:HSV,:AHSV,:HSVA,
:Gray,:AGray,:GrayA,
:HSL,:AHSL,:HSLA,
:RGB,:ARGB,:RGBA,
:BGR,:ABGR,:BGRA,
:XYZ,:AXYZ,:XYZA,
:xyY,:AxyY,:xyYA,
:Lab,:ALab,:LabA,
:Luv,:ALuv,:LuvA,
:LCHab,:ALCHab,:LCHabA,
:LCHuv,:ALCHuv,:LCHuvA,
:DIN99,:ADIN99,:DIN99A,
:LMS,:ALMS,:LMSA,
:YIQ,:AYIQ,:YIQA) # tuple of all exprs of Colorspaces and their transparent variants
johnnychen94 marked this conversation as resolved.
Show resolved Hide resolved
i_2 = rand(BGR, 5, 3) # 2-dim input testing
i_4 = rand(RGBA, 9, 9, 2) # 4-channel testing; RGBA chosen because Random sampler available
@testset "Testing channelify" begin
@test size(f(rand(RGB,16,16,3))) == (10,3)
@test size(f(rand(Gray,16,16,3))) == (10,3)
end
@testset "Testing colorify" begin
@test size(g_3(rand(20,20,7,3))) == (10,3)
@test size(g_1(rand(20,20,7,3))) == (10,3)
@test size(channelify(i_2)) == (5,3,3) # to check if 2-dim inputs are working. Currently no use of them.
@test size(channelify(i_4)) == (9,9,4,2) # to check if 4 channel outputs are correct.
for cs in working_cspaces
i = rand(eval(cs), ds...)
if cs ∈ (:Gray,)
@test size(channelify(i)) == (ds[1:end-1]...,1,ds[end])
elseif cs ∈ (:AGray,:GrayA)
@test size(channelify(i)) == (ds[1:end-1]...,2,ds[end])
elseif cs ∈ (:BGRA,:ABGR,:RGBA,:ARGB)
@test size(channelify(i)) == (ds[1:end-1]...,4,ds[end])
else
@test size(channelify(i)) == (ds[1:end-1]...,3,ds[end])
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Also test for differentiability

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes sure

# @testset "Testing colorify" begin
# @test size(g_3(rand(20,20,7,3))) == (10,3)
# @test size(g_1(rand(20,20,7,3))) == (10,3)
# end
end