Skip to content

Commit

Permalink
Merge 48cd2e5 into 36ff54d
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 24, 2019
2 parents 36ff54d + 48cd2e5 commit d889163
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Currently only supports loading [YOLOv2-tiny](https://github.com/pjreddie/darkne

The majority of this is made possible by Yavuz Bakman's great work in https://github.com/Ybakman/YoloV2

<p float="left">
<img src="examples/boat.png" alt="drawing" width="200"/>
<img src="examples/bikes.png" alt="bikes" width="200"/>
<img src="examples/cowcat.png" alt="cowcat" width="200"/>
</p>

**Docs**

See below for examples or ask questions on [![Join the julia slack](https://img.shields.io/badge/slack-%23machine--learning-yellow)](https://slackinvite.julialang.org)
Expand Down Expand Up @@ -52,11 +58,11 @@ res = model(vocloaded.imstack_mat);
predictions = YOLO.postprocess(res, settings, conf_thresh = 0.3, iou_thresh = 0.3)
```

### Testing a single custom image
### Testing a single custom image
To pass an image through, the image needs to be loaded, and scaled to the appropriate input size.
For YOLOv2-tiny that would be `(w, h, color_channels, minibatch_size) == (416, 416, 3, 1)`.

`loadResizePadImageToFit` can be used to load, resize & pad the image, while maintaining aspect ratio and anti-aliasing during the resize process.
`loadResizePadImageToFit` can be used to load, resize & pad the image, while maintaining aspect ratio and anti-aliasing during the resize process.
```julia
using YOLO
## Load once
Expand Down
Binary file added examples/bikes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/boat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/cowcat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions src/makierendering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,27 @@ function renderResult(img::Array{Float32}, predictions::Vector{YOLO.PredictLabel
Makie.rotate!(scene, -0.5pi)

for p in predictions
alpha = clamp(p.conf,0.5,1.0)
col = cols[p.class]
rect = [p.bbox.y*img_h, p.bbox.x*img_w, p.bbox.h*img_h, p.bbox.w*img_w]
Makie.poly!(scene, [Rectangle{Float32}(rect...)], color=RGBA(red(col),blue(col),green(col),clamp(p.conf*1.3,0.2,0.6)))
pcol = RGBA(red(col),blue(col),green(col),alpha)
x = p.bbox.x*img_w
y = p.bbox.y*img_h
w = p.bbox.w*img_w
h = p.bbox.h*img_h
points = [
Point(y,x+w) => Point(y+h,x+w);
Point(y,x) => Point(y+h,x);
Point(y+h,x+w) => Point(y+h,x);
Point(y,x+w) => Point(y,x);
]
Makie.linesegments!(points, linewidth = 8, color=pcol)
name = get(settings.numsdic,p.class,"")
conf_rounded = round(p.conf, digits=2)
Makie.text!(scene, "$name\n$(conf_rounded)",
position = (rect[1], rect[2]),
position = (y+3, x+3),
align = (:left, :top),
colo = :black,
textsize = 6,
color = pcol,
textsize = 8,
font = "Dejavu Sans"
)
end
Expand Down

0 comments on commit d889163

Please sign in to comment.