prepare2 <- function (arq) {
x <- abind::abind(list(png::readPNG(arq)), along = 0.1)
l <- list(y = NULL, x = x)
class(l) <- "captcha"
l
}
#' install tensorflow
#'
#' install tensorflow
#'
#' @export
install_tensorflow <- function() {
keras::install_tensorflow()
}
#' available
#'
#' available
#'
#' @export
py_available <- function() {
reticulate::py_available(initialize = TRUE)
}
#' predict
#'
#' predict!
#'
#' @param img an image
#'
#' @export
pred <- function(img) {
X <- prepare2(img)$x
pred_ids <- stats::predict(rfb$model, X) %>%
apply(c(1, 2), which.max) %>%
as.vector()
paste(rfb$labs[pred_ids], collapse = "")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.