I am trying to write a plumber function to accept images and score on images and return the scored result. So there are two parts I am trying to figure out.
Part 1: writing plumber function and this is all I came up with.
#* @post /imageAnalysistest
scoreFunction = function(image){
******* need help figuring this part ***********
image_read(image) %>%
image_write(paste0(path,"temp.jpg"))
**************************************************
# preprocess image
x = image_load(paste0(path,"temp.jpg"),target_size = c(img_width, img_height)) %>%
array_reshape(c(-1,img_width, img_height, channels))
# do predictions
probs = model %>% predict(x, steps = as.integer(test_samples/batch_size), verbose = 1)
return(probs)
}
I tried passing as below and it prints a bunch of characters. I guess its converting image to character?
#* @post /imageAnalysistest
scoreFunction = function(req){
print(req$postBody)
}
Part 2: curl the data to send a file to score on the image.
curl \
-F "image=@/home/550.jpg" \
http://192.168.1.1:8085/imageAnalysistest
TLDR: I am trying to write a plumber function to accept images to score on a image recognition model. I am OK sending a image as raw, so I can convert it to jpg for scoring