![]() ![]() In this case, don’t forget to set the RETICULATE_PYTHON environment variable. ![]() If you are using Shinyapps.io or RStudio Connect the dependencies will be infered when deploying the app. If you are managing the complete infrastructure, make sure that you have Python and all required Python packages installed in the server. ![]() This Shiny app can be hosted in any server using the Shiny Server. Model % layer_conv_2d( filters = 16, kernel_size = c( 3, 3), activation = "relu") %>% layer_max_pooling_2d( pool_size = c( 2, 2)) %>% layer_conv_2d( filters = 16, kernel_size = c( 3, 3), activation = "relu") %>% layer_max_pooling_2d( pool_size = c( 2, 2)) %>% layer_flatten() %>% layer_dense( units = 128, activation = "relu") %>% layer_dense( units = 10, activation = "softmax") load_model_weights_tf(model, "cnn-model-weights") Hosting the shiny app ![]() In this case you can use the save_model_weights_tf function. When building more advanced models you may not be able to save the entire model using the save_model_tf function. You can download this file if you want to try the app. Note that to keep the code simple, it will only accept JPEG images with 28x28 pixels. You can see a live version of this app here. If you are deploying to RStudio Connect or Shinnyapps.io, don’t forget to set the RETICULATE_PYTHON environment variable so rsconnect can detect what python packages are required to reproduce your local environment. This app can be used locally or deployed using any Shiny deployment option. Library(shiny) library(keras) # Load the model model % array_reshape(., dim = c( 1, dim(.), 1)) paste0( "The predicted class number is ", predict_classes(model, img)) }) output $image <- renderPlot( shinyApp(ui, server) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |