rstudio / tfdeploy

tfdeploy: Deploy Tensorflow Models from R
https://tensorflow.rstudio.com/tools/tfdeploy/
23 stars 12 forks source link

'serve_savedmodel' seems not create swagger file #22

Closed oli666 closed 6 years ago

oli666 commented 6 years ago

Trying

export_savedmodel(model_keras, "savedmodel")
view_savedmodel("savedmodel")
serve_savedmodel('savedmodel',` browse = TRUE)

results in correctly showing the graph for a saved model, however, the Swagger UI complains about "failed to load spec" ("swagger.json" is highlighted in red in the URL box of the page). I was wondering if I had to explicitly create the swagger file somewhere upstream or if the "server_savedmodel" function would do that on the fly? Looking into the dir of the model, I can not find a swagger.jsons file.

oli666 commented 6 years ago

I have also tried what suggest in https://github.com/rstudio/tfdeploy/issues/1

library(reticulate)
use_python("/usr/local/bin/python3", required = TRUE)

tensorflow::install_tensorflow()

library(tfdeploy)
model_path <- system.file("models/tensorflow-mnist/", package = "tfdeploy")
serve_savedmodel(model_path)

Still getting "failed to load spec" error.

jjallaire commented 6 years ago

@javierluraschi Could you take a look at this?

javierluraschi commented 6 years ago

@oli666 I'm not able to reproduce this issue... can you try:

devtools::install_github("rstudio/tfdeploy")

and retry again?

If that still fails, could you share the output of sessionInfo()?

oli666 commented 6 years ago

I am using the example from https://tensorflow.rstudio.com/tools/cloudml/articles/deployment.html; tried that on two machines, one local Windows laptop and a virtual server running Ubuunt on AWS.

On Ubuntu, I can use the function "view_savedmodel" without issues, however, "serve_savedmodel" produces the issue already described ("Failed to load spec."); on Windows, both functions produce error messages.

Ubuntu:

R version 3.4.3 (2017-11-30) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.3 LTS

Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.6.0 LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] tfdeploy_0.5 bindrcpp_0.2 swagger_3.4.0 cloudml_0.5
[5] tfruns_1.3 corrr_0.2.1 yardstick_0.0.1 recipes_0.1.2
[9] rsample_0.0.2 broom_0.4.2 tidyquant_0.5.4 forcats_0.2.0
[13] stringr_1.2.0 dplyr_0.7.4 purrr_0.2.4 readr_1.1.1.9000
[17] tidyr_0.7.1 tibble_1.4.2 ggplot2_2.2.1 tidyverse_1.1.1.9000
[21] quantmod_0.4-12 TTR_0.23-3 PerformanceAnalytics_1.4.3541 xts_0.10-1
[25] zoo_1.8-1 lubridate_1.6.0 lime_0.3.1.9999 keras_2.1.4.9000

loaded via a namespace (and not attached): [1] colorspace_1.3-2 class_7.3-14 base64enc_0.1-3 rstudioapi_0.7 DRR_0.0.3
[6] prodlim_1.6.1 xml2_1.1.1 codetools_0.2-15 splines_3.4.3 mnormt_1.5-5
[11] robustbase_0.92-8 knitr_1.17 shinythemes_1.1.1 RcppRoll_0.2.2 zeallot_0.1.0
[16] jsonlite_1.5 pROC_1.10.0 ddalpha_1.3.1.1 kernlab_0.9-25 sfsmisc_1.1-1
[21] shiny_1.0.5 compiler_3.4.3 httr_1.3.1 assertthat_0.2.0 Matrix_1.2-11
[26] lazyeval_0.2.0 htmltools_0.3.6 tools_3.4.3 gtable_0.2.0 glue_1.2.0
[31] reshape2_1.4.2 Rcpp_0.12.16 cellranger_1.1.0 debugme_1.1.0.9000 nlme_3.1-131
[36] iterators_1.0.9 psych_1.7.8 timeDate_3043.102 gower_0.1.2 rvest_0.3.2
[41] mime_0.5 stringdist_0.9.4.6 DEoptimR_1.0-8 MASS_7.3-48 MLmetrics_1.1.1
[46] scales_0.5.0 ipred_0.9-6 clisymbols_1.2.0 hms_0.3 parallel_3.4.3
[51] yaml_2.1.18 curl_3.0 reticulate_1.6 rpart_4.1-11 stringi_1.1.7
[56] tensorflow_1.5.0.9000 foreach_1.4.4 lava_1.6 rlang_0.2.0 pkgconfig_2.0.1
[61] lattice_0.20-35 bindr_0.1 htmlwidgets_1.0 CVST_0.2-1 tidyselect_0.2.4
[66] processx_3.0.3.9000 plyr_1.8.4 magrittr_1.5 R6_2.2.2 dimRed_0.1.0
[71] pillar_1.2.0 haven_1.1.0 whisker_0.3-2 foreign_0.8-69 withr_2.1.1
[76] boxes_0.0.0.9000 survival_2.41-3 nnet_7.3-12 modelr_0.1.1 crayon_1.3.4
[81] Quandl_2.8.0 grid_3.4.3 readxl_1.0.0 digest_0.6.15 xtable_1.8-2
[86] httpuv_1.3.6.2 munsell_0.4.3 glmnet_2.0-13

devtools::session_info()

> Session info -------------------------------------------------------------

> setting value

> version R version 3.4.0 (2017-04-21)

> system x86_64, mingw32

> ui RTerm

> language (EN)

> collate German_Germany.1252

> tz Europe/Berlin

> date 2018-03-23

> Packages -----------------------------------------------------------------

> package * version date source

> assertthat 0.2.0 2017-04-11 CRAN (R 3.4.0)

> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)

> base * 3.4.0 2017-04-21 local

> base64enc 0.1-3 2015-07-28 CRAN (R 3.4.0)

> compiler 3.4.0 2017-04-21 local

> crayon 1.3.4 2017-09-16 CRAN (R 3.4.3)

> datasets * 3.4.0 2017-04-21 local

> debugme 1.1.0 2017-10-22 CRAN (R 3.4.3)

> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)

> digest 0.6.15 2018-01-28 CRAN (R 3.4.3)

> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)

> graphics * 3.4.0 2017-04-21 local

> grDevices * 3.4.0 2017-04-21 local

> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)

> httpuv 1.3.6.2 2018-03-02 CRAN (R 3.4.3)

> jsonlite 1.5 2017-06-01 CRAN (R 3.4.0)

> keras * 2.1.4 2018-02-24 CRAN (R 3.4.3)

> knitr 1.20 2018-02-20 CRAN (R 3.4.3)

> magrittr 1.5 2014-11-22 CRAN (R 3.4.0)

> memoise 1.1.0 2017-04-21 CRAN (R 3.4.0)

> methods * 3.4.0 2017-04-21 local

> processx 2.0.0.1 2017-07-30 CRAN (R 3.4.3)

> R6 2.2.2 2017-06-17 CRAN (R 3.4.0)

> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)

> reticulate 1.6 2018-03-23 Github (rstudio/reticulate@dc65a53)

> rmarkdown 1.9 2018-03-01 CRAN (R 3.4.3)

> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)

> stats * 3.4.0 2017-04-21 local

> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)

> stringr 1.3.0 2018-02-19 CRAN (R 3.4.3)

> swagger 3.4.0 2017-10-27 CRAN (R 3.4.2)

> tensorflow 1.5.0.9000 2018-03-23 Github (rstudio/tensorflow@178942e)

> tfdeploy * 0.5 2018-03-23 Github (rstudio/tfdeploy@1fab8ec)

> tfruns 1.3 2018-03-23 Github (rstudio/tfruns@282de31)

> tools 3.4.0 2017-04-21 local

> utils * 3.4.0 2017-04-21 local

> whisker 0.3-2 2013-04-28 CRAN (R 3.4.0)

> withr 2.1.2 2018-03-22 Github (jimhester/withr@79d7b0d)

> yaml 2.1.18 2018-03-08 CRAN (R 3.4.3)

> zeallot 0.1.0 2018-01-28 CRAN (R 3.4.3)

Windows:

R version 3.4.0 (2017-04-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] shiny_1.0.5 tfdeploy_0.5 keras_2.1.4

loaded via a namespace (and not attached): [1] Rcpp_0.12.16 compiler_3.4.0 base64enc_0.1-3 shinyjs_1.0 tools_3.4.0 zeallot_0.1.0
[7] digest_0.6.15 jsonlite_1.5 memoise_1.1.0 evaluate_0.10.1 debugme_1.1.0 reprex_0.1.2
[13] rstudioapi_0.7 yaml_2.1.18 swagger_3.4.0 withr_2.1.2 stringr_1.3.0 knitr_1.20
[19] devtools_1.13.5 rprojroot_1.3-2 reticulate_1.6 R6_2.2.2 processx_2.0.0.1 rmarkdown_1.9
[25] callr_2.0.2 magrittr_1.5 whisker_0.3-2 backports_1.1.2 tfruns_1.3 htmltools_0.3.6
[31] assertthat_0.2.0 mime_0.5 xtable_1.8-2 httpuv_1.3.6.2 tensorflow_1.5.0.9000 stringi_1.1.7
[37] miniUI_0.1.1 crayon_1.3.4

oguntee12 commented 6 years ago

I am experiencing the very same problem and could not get it to work in both Windows and Mac.

javierluraschi commented 6 years ago

Python 3 was affected by this issue, resolved now with 0.5.1, please reinstall using devtools::install_github("rstudio/tfdeploy").