Skip to content

Commit 0cc7be4

Browse files
authored
Merge pull request #69 from donlzx/master
Fix RandomCrop transform
2 parents 03ccd3b + 3c05528 commit 0cc7be4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/projective/crop.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ the crop by `offsets[i]` times the difference between the two.
117117
function offsetcropbounds(
118118
sz::NTuple{N, Int},
119119
bounds::Bounds{N},
120-
offsets::NTuple{N, <:Number}) where N
120+
offsets::NTuple{N, T}) where {N, T<:AbstractFloat}
121+
offsets = map(o -> o == one(T) ? one(T) - eps(T) : o, offsets)
121122
indices = bounds.rs
122123
mins = getindex.(indices, 1)
123-
diffs = length.(indices) .- sz
124+
diffs = length.(indices) .- sz .+ 1
124125

125126
startindices = floor.(Int, mins .+ (diffs .* offsets))
126127
endindices = startindices .+ sz .- 1

0 commit comments

Comments
 (0)