forked from jackliu333/object_detection_using_tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
41 lines (34 loc) · 1.02 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
library(shiny)
library(shinydashboard)
library(rsconnect)
library(tidyverse)
library(reticulate)
library(purrr)
library(stringr)
# Create conda env if not exist
if(!("foodbank_py37" %in% conda_list()$name)){
# conda_create("foodbank_py37", python_version = "3.7")
use_condaenv("foodbank_py37", required = TRUE)
# Set up python libraries for object detection
source_python("setup.py")
}
# Check python version
# py_config()
# Load OD model and prediction functions
source_python("image_classification.py")
# Function to convert scoring result to a df
convert_scoring_rst <- function(df){
all_df = NULL
for(x in names(df)){
tmp_name = x
tmp_val = df[[x]]
tmp_val = as.numeric(as.character(tmp_val))
tmp_row = data.frame(tmp_name, tmp_val)
all_df = rbind(all_df, tmp_row)
}
colnames(all_df) = c("Category", "Prediction")
return(all_df)
}
# Load all image names from current directory
ALL_IMGS = list.files("images/")
ALL_CATS = unique(unlist(purrr::map(ALL_IMGS, function(x) str_split(x,"_")[[1]][1])))