Is there any method to convert the ggplot image directly to an image array/vector (ex. CIMG format) to process in a Convolutional Neural Network, without having to save these files on local disk and reload them?
Issue Faced:
Saving each plot as a jpeg file is taking up to 5 hours currently.
The process that I have followed is given below:
- Generate over 10,000 plots through looping
- Use GGsave to save the plot as png (or jpeg) on local disk (looping through the save function)
- Load the files using ImageR (or openCV if using python)
Manipulate RGB matrix (128,128,3 images) for Convolutional Neural Network.
plts = list()
plt_names = c()
idx = 1
for (i in seq(length(df_example$cats))){
df_plot = df_example[i+(i+10)] %>% ggplot(aes(x = time, y = cats)) + geom_density(color = 'blue')
plts[idx] = df_plot
plt_names = c(plt_names, paste0(df_example$time[i+10]))
idx = idx + 1 }
for(i in seq(plt_len)){
ggsave(filename = paste0(plt_names[i],'.jpeg'),plot = plts[[i]]) }