在keras数据生成器中生成的图像和掩码不匹配

时间:2018-04-11 01:48:05

标签: keras

在Keras中使用数据生成器,我尝试在磁盘上写入增强图像和掩码。我正在执行以下操作,但生成的增强蒙版与生成的增强图像不匹配:

private void replaceParagraph(XWPFParagraph paragraph, Map<String, String> fieldsForReport) throws POIXMLException {
    String find, text, runsText;
    List<XWPFRun> runs;
    XWPFRun run, nextRun;
    for (String key : fieldsForReport.keySet()) {
        text = paragraph.getText();
        if (!text.contains("${"))
            return;
        find = "${" + key + "}";
        if (!text.contains(find))
            continue;
        runs = paragraph.getRuns();
        for (int i = 0; i < runs.size(); i++) {
            run = runs.get(i);
            runsText = run.getText(0);
            if (runsText.contains("${") || (runsText.contains("$") && runs.get(i + 1).getText(0).substring(0, 1).equals("{"))) {
                while (!runsText.contains("}")) {
                    nextRun = runs.get(i + 1);
                    runsText = runsText + nextRun.getText(0);
                    paragraph.removeRun(i + 1);
                }
                run.setText(runsText.contains(find) ?
                        runsText.replace(find, fieldsForReport.get(key)) :
                        runsText, 0);
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我发现问题是我自己的问题。我应该使用相同的种子: image_gen = image_datagen.flow(images,seed = seed,batch_size = 1,shuffle = False,save_to_dir = dir_image,save_prefix =&#39; aug&#39;,save_format =&#39; png&#39;)

mask_gen = image_datagen.flow(mask,seed = seed,batch_size = 1,shuffle = False,save_to_dir = dir_mask,save_prefix =&#39; aug&#39;,save_format =&#39; png&#39;)< / p>