Created
September 9, 2016 04:33
-
-
Save sanealytics/fb5f834e377bca66ea0d7de111b5f568 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shinyServer(function(input, output, session) { | |
# Session level | |
idx <- round(runif(1, 1, 2500)) # random place to start | |
state <- reactive({ | |
if(input$submit > 0) { # Not on first page load | |
isolate({ # Don't get reactive on me now | |
answer <- input$yesorno | |
m <- matches$find(query = paste0('{"_id": "', ids.df.todo[idx], '"}'), fields = '{}' ,limit = 1, pagesize=1) | |
answer.clean <- ifelse(answer == "First", | |
m$prediction$styleNames[[1]]$style[1], | |
ifelse(answer == "Second", | |
m$prediction$styleNames[[1]]$style[2], | |
ifelse(answer == "Third", | |
m$prediction$styleNames[[1]]$style[3], | |
answer))) | |
datum <- data.frame(email = input$email, | |
id = ids.df.todo[idx], | |
answer = answer.clean, | |
ts = Sys.time() | |
) | |
corrections$insert(datum) | |
}) | |
} | |
idx <<- idx + 1 # Keep on moving | |
}) | |
output$instagram <- renderPrint({ | |
state() | |
i <- instagram$find(query = paste0('{"_id": "', ids.df.todo[idx], '"}'), fields = '{}' ,limit = 1, pagesize=1) | |
cat(paste0("<a href='", i$`_id`,"' target='_blank'>", | |
"<img src='", i$image, "' />", | |
"</a>")) | |
}) | |
getFirst <- reactive({ | |
state() | |
m <- matches$find(query = paste0('{"_id": "', ids.df.todo[idx], '"}'), fields = '{}' ,limit = 1, pagesize=1) | |
}) | |
output$deepDress <- renderPrint({ | |
m <- getFirst() | |
cat(paste0("<img src='", m$prediction$styleNames[[1]]$urls$imageURL, "' />")) | |
}) | |
output$deepDressProb <- renderText({ | |
m <- getFirst() | |
paste(round(m$prediction$styleNames[[1]]$probability), '%') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment