From 64a153c00660c3f017be804704ef453a2db1f6f8 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 20 Sep 2019 09:02:44 -0400 Subject: [PATCH 1/4] try 1.3 on freebsd and arm --- .cirrus.yml | 2 +- .drone.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 9490fcd..4c3190b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,7 +4,7 @@ task: name: FreeBSD env: matrix: - - JULIA_VERSION: 1.2 + - JULIA_VERSION: 1.3 - JULIA_VERSION: nightly allow_failures: $JULIA_VERSION == "nightly" install_script: diff --git a/.drone.yml b/.drone.yml index 3112246..dca9dd4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,5 +1,5 @@ kind: pipeline -name: linux-arm-1.2 +name: linux-arm-1.3 platform: os: linux @@ -7,7 +7,7 @@ platform: steps: - name: build - image: julia:1.2 + image: julia:1.3 commands: - uname -a - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' @@ -15,7 +15,7 @@ steps: --- kind: pipeline -name: linux-aarch64-1.2 +name: linux-aarch64-1.3 platform: os: linux @@ -23,7 +23,7 @@ platform: steps: - name: build - image: julia:1.2 + image: julia:1.3 commands: - uname -a - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' From 60934483ababa13fc109c86d24c3c4ed4c408fa5 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 20 Sep 2019 11:56:37 -0400 Subject: [PATCH 2/4] expand versions tested --- .drone.yml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 2 ++ appveyor.yml | 2 ++ 3 files changed, 36 insertions(+) diff --git a/.drone.yml b/.drone.yml index dca9dd4..a015a7c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,3 +27,35 @@ steps: commands: - uname -a - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' + +--- + +kind: pipeline +name: linux-arm-nightly + +platform: + os: linux + arch: arm + +steps: +- name: build + image: julia:nightly + commands: + - uname -a + - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' + +--- + +kind: pipeline +name: linux-aarch64-nightly + +platform: + os: linux + arch: arm64 + +steps: +- name: build + image: julia:nightly + commands: + - uname -a + - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' diff --git a/.travis.yml b/.travis.yml index 3e9e838..2eaa3b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,9 @@ os: - osx julia: + - 1.0 - 1.2 + - 1.3 - nightly notifications: diff --git a/appveyor.yml b/appveyor.yml index 9f725fd..6c91d8c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,8 @@ environment: matrix: + - julia_version: 1.0 - julia_version: 1.2 + - julia_version: 1.3 - julia_version: latest platform: From 2a9217bfb15c43848d98a346fdffb2082f70146b Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 20 Sep 2019 12:11:53 -0400 Subject: [PATCH 3/4] disable nightly on arm given not available --- .drone.yml | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/.drone.yml b/.drone.yml index a015a7c..55a6880 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,34 +28,34 @@ steps: - uname -a - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' ---- - -kind: pipeline -name: linux-arm-nightly - -platform: - os: linux - arch: arm - -steps: -- name: build - image: julia:nightly - commands: - - uname -a - - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' - ---- - -kind: pipeline -name: linux-aarch64-nightly - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: julia:nightly - commands: - - uname -a - - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' +# --- +# +# kind: pipeline +# name: linux-arm-nightly +# +# platform: +# os: linux +# arch: arm +# +# steps: +# - name: build +# image: julia:nightly +# commands: +# - uname -a +# - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' +# +# --- +# +# kind: pipeline +# name: linux-aarch64-nightly +# +# platform: +# os: linux +# arch: arm64 +# +# steps: +# - name: build +# image: julia:nightly +# commands: +# - uname -a +# - julia --project=. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)' From c8a26b9a5dad2afc1d2ce7ece6b32da0c44333bb Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 20 Sep 2019 13:15:11 -0400 Subject: [PATCH 4/4] speed improvement attempts for CUDA postprocessing --- src/postprocess.jl | 26 ++++++++++++++------------ test/runtests.jl | 21 ++++++++++++++++----- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/postprocess.jl b/src/postprocess.jl index df96a51..fb3b7ec 100644 --- a/src/postprocess.jl +++ b/src/postprocess.jl @@ -7,32 +7,32 @@ Post processing function. Confidence score threshold to select correct predictions. Recommended : 0.3 IoU threshold to remove unnecessary predictions: Recommended:0.3 """ -function postprocess(yolomat::xtype,settings::Settings; conf_thresh::T = 0.3, iou_thresh::T = 0.3) where {T<:AbstractFloat} +function postprocess(yolomat::Array{Float32},settings::Settings; conf_thresh::T = 0.3, iou_thresh::T = 0.3) where {T<:AbstractFloat} im_w = settings.image_shape[1] im_h = settings.image_shape[2] num_images = size(yolomat,4) all_detections = map(x->PredictLabel[],1:num_images) RATE = 32 - @views for i in 1:num_images + for i in 1:num_images for cy in 1:13 for cx in 1:13 - for b in 1:5 + @views for b in 1:5 channel = (b-1)*(settings.num_classes + 5) tx = yolomat[cy,cx,channel+1,i] ty = yolomat[cy,cx,channel+2,i] tw = yolomat[cy,cx,channel+3,i] th = yolomat[cy,cx,channel+4,i] tc = yolomat[cy,cx,channel+5,i] - x = Float32((sigmoid(tx) + cx-1) * RATE) - y = Float32((sigmoid(ty) + cy-1) * RATE) - w = Float32(exp(tw) * (settings.anchors[b][1]) * RATE) - h = Float32(exp(th) * (settings.anchors[b][2]) * RATE) - conf = Float32(sigmoid(tc)) - classScores = Array{Float32}(yolomat[cy,cx,channel+6:channel+25,i]) + x = (sigmoid(tx) + cx-1) * RATE + y = (sigmoid(ty) + cy-1) * RATE + w = exp(tw) * settings.anchors[b][1] * RATE + h = exp(th) * settings.anchors[b][2] * RATE + conf = sigmoid(tc) + classScores = yolomat[cy,cx,channel+6:channel+25,i] classScores = softmax(classScores) classNo = argmax(classScores) bestScore = classScores[classNo] - classConfidenceScore = conf*bestScore + classConfidenceScore = conf * bestScore if classConfidenceScore > conf_thresh bbox = BBOX( x = max(0.0,x-w/2)/im_w, @@ -53,7 +53,9 @@ function postprocess(yolomat::xtype,settings::Settings; conf_thresh::T = 0.3, io return all_detections end end - +function postprocess(yolomat::KnetArray{Float32}, settings::Settings; conf_thresh::T = 0.3, iou_thresh::T = 0.3) where {T<:AbstractFloat} + postprocess(Array{Float32}(yolomat), settings; conf_thresh = conf_thresh, iou_thresh = iou_thresh) +end """ nonMaxSupression!(detections::Vector{PredictLabel}, iou_thresh::Float32) @@ -63,7 +65,7 @@ function nonMaxSupression!(detections::Vector{PredictLabel}, iou_thresh::T) wher sort!(detections, by = x -> x.conf, rev = true) for i = 1:length(detections) k = i + 1 - while k <= length(detections) + @views while k <= length(detections) iou = ioumatch(detections[i].bbox, detections[k].bbox) if iou > iou_thresh && (detections[i].class == detections[k].class) deleteat!(detections, k) diff --git a/test/runtests.jl b/test/runtests.jl index fbeebd1..09ecef4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -93,14 +93,25 @@ end inference_rate = 1 / inference_time @test inference_time < 1.0 #seconds - predictions = YOLO.postprocess(res, settings, conf_thresh = 0.1, iou_thresh = 0.3) + predictions = YOLO.postprocess(res, settings, conf_thresh = 0.3, iou_thresh = 0.3) - if false #disabled because Makie can't be tested on headless CI - scene = YOLO.renderResult(vocloaded.imstack_mat[:,:,:,1], predictions[1], settings, save_file = "test.png") - @test isfile("test.png") - rm("test.png", force=true) + t = @elapsed for i in 1:10 + YOLO.postprocess(res, settings, conf_thresh = 0.3, iou_thresh = 0.3) end + postprocess_time = (t / 10) / num_images + postprocess_rate = 1 / postprocess_time + @test postprocess_time < 1.0 #seconds + + ## Makie Tests + #disabled because Makie can't be tested on headless CI + # scene = YOLO.renderResult(vocloaded.imstack_mat[:,:,:,1], predictions[1], settings, save_file = "test.png") + # @test isfile("test.png") + # rm("test.png", force=true) + enable_info() @info "YOLO_v2_tiny inference time per image: $(round(inference_time, digits=2)) seconds ($(round(inference_rate, digits=2)) fps)" + @info "YOLO_v2_tiny postprocess time per image: $(round(postprocess_time, digits=4)) seconds ($(round(postprocess_rate, digits=2)) fps)" + @info "Total time per image: $(round(inference_time + postprocess_time, digits=2)) seconds ($(round(1/(inference_time + postprocess_time), digits=2)) fps)" + end