是否有任何方法可以将ggplot图像直接转换为图像数组/矢量(例如CIMG格式)以在卷积神经网络中处理,而无需将这些文件保存在本地磁盘上并重新加载它们?
问题面临:
将每个绘图保存为jpeg文件目前最多需要5个小时 .
我遵循的流程如下:
-
通过循环生成超过10,000个绘图
-
使用GGsave将绘图保存为本地磁盘上的png(或jpeg)(循环保存功能)
-
使用ImageR加载文件(如果使用python,则加载openCV)
-
操纵卷积神经网络的RGB矩阵(128,128,3图像) .
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]])}