Skip to content

Commit 86c55fd

Browse files
authored
Fix progress bar in imagedatasetstats (#217)
1 parent cbdf36b commit 86c55fd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Project.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name = "FastAI"
22
uuid = "5d0beca9-ade8-49ae-ad0b-a3cf890e669f"
33
authors = ["Lorenz Ohly", "Julia Community"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
88
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
99
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
10+
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
1011
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
1112
DataAugmentation = "88a5189c-e7ff-4f85-ac6b-e6158070f02e"
1213
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
@@ -28,7 +29,7 @@ Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
2829
MosaicViews = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
2930
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
3031
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
31-
ReTest = "e0db7c4e-2690-44b9-bad6-7687da720f89"
32+
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
3233
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
3334
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
3435
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
@@ -77,11 +78,9 @@ julia = "1.6"
7778
[extras]
7879
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7980

81+
[pollen]
82+
title = "FastAI.jl"
83+
url = "https://github.com/FluxML/FastAI.jl"
8084

8185
[targets]
8286
test = ["Test"]
83-
84-
85-
[pollen]
86-
title = "FastAI.jl"
87-
url = "https://github.com/FluxML/FastAI.jl"

src/Vision/Vision.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import ..FastAI:
5252

5353
import Colors: colormaps_sequential, Colorant, Color, Gray, Normed, RGB,
5454
alphacolor, deuteranopic, distinguishable_colors
55+
using ColorVectorSpace
5556
import FixedPointNumbers: N0f8
5657
import DataAugmentation
5758
import DataAugmentation: apply, Identity, ToEltype, ImageToTensor, Normalize,
@@ -60,6 +61,7 @@ import DataAugmentation: apply, Identity, ToEltype, ImageToTensor, Normalize,
6061
ResizePadDivisible, itemdata
6162
import ImageInTerminal
6263
import IndirectArrays: IndirectArray
64+
import ProgressMeter: Progress, next!
6365
import Requires: @require
6466
import StaticArrays: SVector
6567
import Statistics: mean, std

src/Vision/encodings/imagepreprocessing.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ If `progress = true`, show a progress bar.
129129
function imagedatasetstats(
130130
data,
131131
C;
132-
progress=true,
133-
progressfn=progress ? tqdm : identity)
132+
progress=true)
134133
means, stds = imagestats(getobs(data, 1), C)
135134
loaderfn = d -> eachobsparallel(d, buffered=false, useprimary=true)
136135

137-
for (means_, stds_) in mapobs(img -> imagestats(img, C), data) |> loaderfn |> progressfn
136+
p = Progress(nobs(data), enabled=progress)
137+
for (means_, stds_) in mapobs(img -> imagestats(img, C), data) |> loaderfn
138138
means .+= means_
139139
stds .+= stds_
140+
next!(p)
140141
end
141142
return means ./ nobs(data), stds ./ nobs(data)
142143
end

0 commit comments

Comments
 (0)