server <- function(input, output) {
re1 <- reactive({gsub("\\\\", "/", input$file1$datapath)})
output$Image1 <- renderImage({list(src = re1(),
width = 300,
height = 300)})
re2 <- reactive({gsub("\\\\", "/", input$file2$datapath)})
output$Image2 <- renderImage({list(src = re2(),
width = 300,
height = 300)})
txt_1 <- getGoogleVisionResponse(re1,feature = 'TEXT_DETECTION')
}
shinyApp(ui, server)
我收到此错误,
Warning: Error in as.vector: cannot coerce type 'closure' to vector of type
'character'
Stack trace (innermost first):
43: as.character.default
42: as.character
41: stri_count_regex
40: stringr::str_count
39: imageToText
38: getGoogleVisionResponse
37: server [F:/TELS Shiny/telsIR/appv3.R#86]
1: runApp
Error in as.vector(x, "character") :
cannot coerce type 'closure' to vector of type 'character'
GoogleVision API已经过适当的身份验证 . 它独立工作 . 只是不作为我想要构建的Shiny应用程序的一部分 . 一旦我得到txt_1对象,我将对其执行许多操作(矢量化并运行预训练的密集层 .
ui代码如下,
ui <- fluidPage(
titlePanel('Test App)'),
fluidRow(
column(2,
fileInput(
inputId = "file1",
label = "Upload Image-1",
accept = c('image/png', 'image/jpeg','image/jpg')
),
fileInput(
inputId = "file2",
label = "Upload Image-2",
accept = c('image/png', 'image/jpeg','image/jpg')
)),
tags$hr(),
column(2,offset = 0,
textOutput("filename"),
imageOutput(outputId = "Image1"),
imageOutput(outputId = "Image2")
)
),
textOutput(outputId = "Category")
)