Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No images in common" during Prediction #4

Open
AneeshDN opened this issue Apr 29, 2020 · 3 comments
Open

"No images in common" during Prediction #4

AneeshDN opened this issue Apr 29, 2020 · 3 comments

Comments

@AneeshDN
Copy link

Hi @IAmWave

As communicated earlier I have set up the code and completed the training.

When I run the predictions on the given image set, it working. But when I run the prediction on my custom images it's trowing the response "No images in common", Can you let me know why is this issue happening. Thanks.

Attaching my custom images used during prediction 4,
G0020129-LOI-1

4k_all_max_top_part_1_750_label_result

Best Regards,
Aneesh

@vvolhejn
Copy link
Owner

vvolhejn commented Apr 29, 2020

Could you please elaborate on the commands that you ran? The message "No images in common" comes from acres.evaluation.mask_images, which is what I suppose you're running. This command takes a directory of images and a directory of masks, and produces unblurred images by applying the mask. Masks classify the image's pixels into three categories: not-a-barcode/barcode-black/barcode-white. To obtain the predicted mask for your images, run acres.binarization.predict, as detailed in README.md. Check if this indeed produces the masks that you would expect. They should be in some subdirectory under what you entered as the --job-dir argument. Afterwards, run acres.evaluation.mask_images.

Let me know if this helped and if not, please paste the commands that you ran here.

@AneeshDN
Copy link
Author

AneeshDN commented May 5, 2020

Hi @IAmWave

Apologies for the delay in reply.

Below are the commands which I am executed

  1. Prediction

python -m acres.binarization.predict --job-dir logs/example/ --network-name strided32 --dataset-dir data/muenster_blur/ --batch-size 50 --model-name task.py-2020-04-16_125854-bs=40,cp=0.0,es=10,ih=600,iw=800,nn=strided32,pc=2,ps=1,ts=500

After successful execution of the above command, I see a new folder created under logs\example\task.py-2020-04-16_125854-bs=40,cp=0.0,es=10,ih=600,iw=800,nn=strided32,pc=2,ps=1,ts=500\predictions. i.e, it is creating the mask for the images in data/muenster_blur/images directory

  1. Unblur the input images

python -m acres.evaluation.mask_images ./data/labels/ ./logs/example/task.py-2020-04-16_125854-bs=40,cp=0.0,es=10,ih=600,iw=800,nn=strided32,pc=2,ps=
1,ts=500/predictions/ ./results/output/ --mask-weight 0.3

This command executes acres.evaluation.mask_images by taking the images under ./data/labels directory. I have placed the images shared in the earlier post in the ./data/labels directory.

Let me if I am doing anything wrong in the above 2 steps.

When you say run acres.binarization.predict to get the predicted mask for my images. You are asking me to execute the following command,

python -m acres.binarization.predict --job-dir logs/example/ --network-name strided32 --dataset-dir data/predict_labels/ --batch-size 50 --model-name task.py-2020-04-16_125854-bs=40,cp=0.0,es=10,ih=600,iw=800,nn=strided32,pc=2,ps=1,ts=500

When I execute the above command the output is FileNotFoundError: [WinError 3] The system cannot find the path specified: 'data/predict_labels/masks' which is because under ./data/predict_labels/ there is only 1 directory images.
Should there be ./data/predict_labels/masks directory with the masked images of the images in ./data/predict_labels/images? Request you to correct my understanding here, also if yes how to get the mask for these images. Thanks.

Best Regards,
Aneesh

@vvolhejn
Copy link
Owner

Sorry for the late reply. I see where the problem is; in predict.py, I am using the function dataset.make_datasets, which takes a dataset of both images and masks and splits it into a training, dev (validation) and test set. This was enough for my purposes, but for actual prediction you need to load a dataset for which masks are not available. Sadly, I don't have time to maintain this project, but I'll gladly point you towards what needs to be changed for this to work.

During prediction, the function dataset.make_datasets is only used to retrieve the test set and so it would be enough to write a function which loads the dataset in your format and plug it into predict.py. See the dataset module for what is currently being done. I'm using the tf.estimator API and I don't remember how it works anymore; I'm afraid you'll have to dig into the code to figure out the exact format needed and how to avoid loading masks. (I'm saying this because the model_fn expects the labels as argument as well.)

A hacky solution would be to create a white blank mask for each of your images; it isn't used in prediction anyways. Then you could probably directly use the dataset.make_dataset function to load your dataset, and use this in predict.py.

Also note that there are some divisibility assumptions on the image size: see here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants