Skip to content

Instantly share code, notes, and snippets.

@sanealytics
Created September 9, 2016 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanealytics/fb5f834e377bca66ea0d7de111b5f568 to your computer and use it in GitHub Desktop.
Save sanealytics/fb5f834e377bca66ea0d7de111b5f568 to your computer and use it in GitHub Desktop.
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