From d8cd3876e8686744c489a65a8434db255a7a465e Mon Sep 17 00:00:00 2001 From: Ben Raymond Date: Sun, 17 Jul 2022 17:41:48 +1000 Subject: [PATCH] default to 'cuda' with silent fallback on cpu-only machines. Move jpeg to depends v0.1.0 --- DESCRIPTION | 4 ++-- R/yolo.R | 7 ++++--- man/ovml_yolo.Rd | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c950ed..469300d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ovml Title: Machine Learning Tools for Volleyball -Version: 0.0.15 +Version: 0.1.0 Authors@R: c(person("Ben", "Raymond", role = c("aut", "cre"), email = "ben@untan.gl"), person("Adrien", "Ickowicz", role = "aut")) Description: Image and video machine learning tools, for application to volleyball analytics. @@ -11,12 +11,12 @@ Imports: digest, ggplot2, grid, + jpeg, magick, magrittr, rappdirs, torch Suggests: - jpeg, testthat License: MIT + file LICENSE Encoding: UTF-8 diff --git a/R/yolo.R b/R/yolo.R index 707a514..d449806 100644 --- a/R/yolo.R +++ b/R/yolo.R @@ -24,14 +24,15 @@ #' } #' #' @export -ovml_yolo <- function(version = 4, device = "cpu", weights_file = "auto", class_labels) { +ovml_yolo <- function(version = 4, device = "cuda", weights_file = "auto", class_labels) { if (is.numeric(version)) version <- as.character(version) assert_that(version %in% c("3", "4", "4-tiny", "4-mvb", "4-tiny-mvb", "7")) assert_that(is.string(device)) + device_was_specified <- !missing(device) device <- tolower(device) device <- match.arg(device, c("cpu", "cuda")) if (device == "cuda" && !cuda_is_available()) { - warning("'cuda' device not available, using 'cpu'") + if (device_was_specified) warning("'cuda' device not available, using 'cpu'") device <- "cpu" } to_cuda <- device == "cuda" @@ -45,7 +46,7 @@ ovml_yolo <- function(version = 4, device = "cpu", weights_file = "auto", class_ expected_sha1 <- "520878f12e97cf820529daea502acca380f1cb8e" } else if (version == "7") { if (missing(class_labels) || length(class_labels) < 1 || is.na(class_labels)) class_labels <- ovml_class_labels("coco") - w_url <- "https://github.com/openvolley/ovml/releases/download/yolov7/yolov7.torchscript.pt" + w_url <- "https://github.com/openvolley/ovml/releases/download/0.1.0/yolov7.torchscript.pt" expected_sha1 <- "d8da940cd8175c2c670ad5ac86f5547b6f80c095" from_jit <- TRUE dn <- NULL diff --git a/man/ovml_yolo.Rd b/man/ovml_yolo.Rd index 112cab5..aa083c5 100644 --- a/man/ovml_yolo.Rd +++ b/man/ovml_yolo.Rd @@ -4,7 +4,7 @@ \alias{ovml_yolo} \title{Construct YOLO network} \usage{ -ovml_yolo(version = 4, device = "cpu", weights_file = "auto", class_labels) +ovml_yolo(version = 4, device = "cuda", weights_file = "auto", class_labels) } \arguments{ \item{version}{integer or string: one of