简体   繁体   English

由于资源原因,无法将 model 与我的所有图像和蒙版配合使用

[英]Cannot fit model with all my images and masks, because of resources

I have a U-Net NN and I have a dataset with 40k+ images (they are numpy arrays with shape 768x768x3) and 10k+ masks to this images(with shape 768x768x1).我有一个 U-Net NN,我有一个包含 40k+ 图像的数据集(它们是 numpy arrays,形状为 768x768x3)和 10k+ 掩码到此图像(形状为 768x768x1)。 My computer and even Kaggle, Google Colab cannot fit it with their resources.我的电脑甚至 Kaggle、Google Colab 都无法适应他们的资源。 But I need to fit the model with all of this images and masks.但是我需要为 model 安装所有这些图像和蒙版。 So, what do I need to do?那么,我需要做什么? I have think about make a loop with 400 images and 400 masks on each iterations and fit every time 400 images to my model, but I have read, that on each iteration model will 'reset'.我考虑过在每次迭代中创建一个包含 400 个图像和 400 个掩码的循环,并且每次将 400 个图像适合我的 model,但我已经读过,在每次迭代中 model 都会“重置”。 So what I need to do to fit my model with all this images and masks?那么我需要做些什么才能使我的 model 与所有这些图像和蒙版相匹配?

Update : I have changed size of image and mask to (256,256,3) and (256,256,1), but even with this I can fit model with +/- 1000 images更新:我已将图像和蒙版的大小更改为 (256,256,3) 和 (256,256,1),但即使这样,我也可以将 model 与 +/- 1000 个图像相匹配

This is a very common problem in Data Science.这是数据科学中非常常见的问题。 There is not one solution, it's basically a process.没有一个解决方案,它基本上是一个过程。

Start out with the following steps and see if the problem still persists.从以下步骤开始,看看问题是否仍然存在。 Find out what is blocking, GPU or RAM.找出阻塞的原因,GPU 或 RAM。

  • If GPU, you need to know that your model is loaded in GPU memory and the batches are put there iteratively.如果GPU,你需要知道你的model是加载在GPU ZCD69B4957F06CD818D7BF3DZ618里面的。 So, when GPU memory is the problem, reduce your model size, or the amount of data present in the batch.因此,当 GPU memory 出现问题时,请减小 model 大小或批处理中存在的数据量。
  • If RAM, you should look into DataLoaders if you use PyTorch or Sequence if you use Tensorflow/Keras.如果是 RAM,如果使用 PyTorch,则应查看DataLoaders ;如果使用 Tensorflow/Keras,则应查看Sequence In general, the data is loaded like an iterator, meaning it's only really loaded upon request (with some sort of a waiting queue, you can also again specify how large that is allowed to be).通常,数据像迭代器一样加载,这意味着它只是在请求时才真正加载(使用某种等待队列,您还可以再次指定允许的大小)。 This will make an epoch slower, as you cannot load all data upfront into memory for rapid access, but you still manage to iterate over your data and process it as such.这将使 epoch 变慢,因为您无法将所有数据预先加载到 memory 中以进行快速访问,但您仍然设法迭代数据并照此处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow 无法容纳图像列表 - Tensorflow cannot fit a list of images 使用 MaskRcnn 从 model.detect() 之后的图像中获取预测掩码的 x,y 坐标 - Getting the x,y coordinates of the predicted masks from the images after model.detect() with MaskRcnn Numpy / Scipy带有蒙版和RGB图像 - Numpy/Scipy with masks and RGB images 由于 FK,无法删除 model 的某些实例 - Cannot delete some instances of model because of FK 适合Python中所有变量的模型(Scikit Learn) - Fit model to all variables in Python (Scikit Learn) 当训练数据是图像时,Keras model.fit() 中的“批次”是什么 - what is a “batch” in Keras model.fit() when training data are images 无法准确地将一批图像输入到 model.fit 中 - not able to accurately input a batch of images into a model.fit Keras ImageDataGenerator 用于在单独的目录中使用图像和掩码进行分割 - Keras ImageDataGenerator for segmentation with images and masks in separate directories 如何在Pytorch中为图像及​​其遮罩创建自定义数据集? - How make customised dataset in Pytorch for images and their masks? 一起转换图像和蒙版(Keras 示例) - Transforming images and masks together (Keras example)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM