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

@LogWell found a solution how to prepare DATASETS. You can use following files structure: #38

Open
lemon1220 opened this issue Sep 4, 2019 · 21 comments

Comments

@lemon1220
Copy link

@LogWell found a solution how to prepare DATASETS. You can use following files structure:

datasets/CIHP/images/0002190.png
datasets/CIHP/list/img_list.txt
datasets/CIHP/images/tool/logwell_script.m
datasets/CIHP/images/edges
datasets/CIHP/images/labels

where
datasets/CIHP/images/0002190.png - it's a source image

datasets/CIHP/list/img_list.txt contain following data:
0002190.png

and datasets/CIHP/images/tool/logwell_script.m - it's a MATLAB script for prepare edges and labels:

clear;
close all;
fclose all;
%%
imglist = '../list/img_list.txt';  % 00000.png
list = textread(imglist, '%s');

for i = 1:length(list);
    imname = list{i};
    instance_map = imread(fullfile('../images', imname));
    instance_contour = uint8(imgradient(rgb2gray(instance_map)) > 0);
    imwrite(instance_contour, fullfile('../edges', imname));
    imwrite(instance_contour, fullfile('../labels', imname));
    
end

Just run this script using command like:
/opt/MATLAB/R2018b/bin/matlab -nodisplay -nojvm -nosplash -nodesktop -r "try, run('tool/logwell_script.m'), catch, exit(1), end, exit(0);"

and after that you can run
python test_pgn.py
for get segmented images.

Originally posted by @rcrvano in #26 (comment)

@lemon1220
Copy link
Author

hi friends.
Do you know HOW can I run this script under windows matlab? I didnot have matlab on ubuntu.

@lemon1220
Copy link
Author

excuse me. who can tell me how run the following code?
`clear;
close all;
fclose all;
%%
imglist = '../list/img_list.txt'; % 00000.png
list = textread(imglist, '%s');

for i = 1:length(list);
imname = list{i};
instance_map = imread(fullfile('../images', imname));
instance_contour = uint8(imgradient(rgb2gray(instance_map)) > 0);
imwrite(instance_contour, fullfile('../edges', imname));
imwrite(instance_contour, fullfile('../labels', imname));

end`

@mukundhan3
Copy link

can you tell me a python equivalent of the above code logwell_script.m . I dont have matlab license with me.
Thanks in advance.

@LogWell
Copy link

LogWell commented Oct 3, 2019

I'm sorry, I don't use it on Windows, but the code should be almost the same @lemon1220

I don't know how to implement it, just use it @mukundhan3

The author may not be able to receive information, or ask friends around you.

@qzane
Copy link

qzane commented Oct 24, 2019

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@MuhammadAsadJaved
Copy link

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@qzane Can you explain how to run this script? an example command to run? I tried but failed. I am trying like this python datasets/CIHP/images CIHP but can't run.

@qzane
Copy link

qzane commented Dec 3, 2019

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@qzane Can you explain how to run this script? an example command to run? I tried but failed. I am trying like this python datasets/CIHP/images CIHP but can't run.

@MuhammadAsadJaved try python make_dataset.py datasets/CIHP/images CIHP2 if you use the same name the image may be override (you should first check the images folder, maybe they have already been removed).

@MuhammadAsadJaved
Copy link

@qzane Yes sir you are right. CIHP2 generates 3 folders edges, images and list. Do I only need this information for generate segmented image? Note: The edges folder contains only empty black images.

@qzane
Copy link

qzane commented Dec 3, 2019

Yes, edges are for evaluation only which you don't need but has to be there

@MuhammadAsadJaved
Copy link

@qzane Thank you very much sir. So nice of you. Stay blessed.

@MuhammadAsadJaved
Copy link

@qzane i generated list and edges for existing images in the dataset folder of this repo using your script. then i run python test_pgn.py
and generate output like this. Where is the problem? Can you give me some suggestion?

pgan1
pgan2
pgan3

@qzane
Copy link

qzane commented Dec 5, 2019

@MuhammadAsadJaved
Can you send me these images? I can try that on my computer.

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Dec 6, 2019 via email

@neonb88
Copy link

neonb88 commented Jan 26, 2020

In January, 2020, the script is named write_edge.m. Full path: CIHP_PGN/datasets/CIHP/tool/write_edge.m

@neonb88
Copy link

neonb88 commented Jan 26, 2020

@lemon1220 Also, doesn't this approach not make sense? The whole point of their training the PGN network(s) is so they can segment and label everything with the neural network. This script dumbly uses old computer vision techniques like gradients. I think there's a better way to do this. Will update when I find it

@neonb88
Copy link

neonb88 commented Jan 26, 2020

can you tell me a python equivalent of the above code logwell_script.m . I dont have matlab license with me.
Thanks in advance.

@mukundhan3 : You can use octave, the free version of MATLAB. Also, this might also be useful to show how to run scripts from the command line

@ynyBonfennil
Copy link

@qzane i generated list and edges for existing images in the dataset folder of this repo using your script. then i run python test_pgn.py
and generate output like this. Where is the problem? Can you give me some suggestion?

@MuhammadAsadJaved I know it's a bit late to comment this, but I had the same problem like this.
My problem was the misplacement of pre-trained model. At first, I thought I should place all the files in the pre-trained model (checkpoint / model.ckpt-593292.data-00000-of-00001 / model.ckpt-593292.index / model.ckpt-593292.meta), but it didn't work.
What we should do is just extract zip file to checkpoint directory, so the checkpoint directory would be like checkpoint/CIHP_pgn/(somefiles).

I hope this will help you.

@gayalkuruppu
Copy link

gayalkuruppu commented May 27, 2020

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@qzane Thank you for your python script. But this only generates the edges file and the respective blank(black) images. Do you have a python script to generate labels as well?

@mdrews93
Copy link

mdrews93 commented Jun 14, 2021

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@qzane Thank you for your python script. But this only generates the edges file and the respective blank(black) images. Do you have a python script to generate labels as well?

@gayalkuruppu I don't think you need labels to get the correct output. I created a folder with custom images, ran the python script that was linked to in a previous comment (https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14 and I saved it as prepare_dataset.py) with

python prepare_dataset.py custom_dataset/CIHP/images CIHP

and it created a new folder within datasets/ called CIHP (it'll be named whatever you use as the last argument in the previous python command).

The new folder has the structure

CIHP_PGN/
├─ datasets/
│  ├─ CIHP/
│  │  ├─ edges/
│  │  │  ├─ image0.png
│  │  │  ├─ image1.png
│  │  ├─ images/
│  │  │  ├─ image0.png
│  │  │  ├─ image1.jpg
│  │  ├─ list/
│  │  │  ├─ val_id.txt
│  │  │  ├─ val.txt

and then I was able to run python test_pgn.py and see the results in CIHP_PGN/output/cihp_parsing_maps/

@confifu
Copy link

confifu commented Jun 16, 2021

If anyone needs it I have a working example of the model here : https://colab.research.google.com/drive/15uGzI5adMsZ7mIfVsr3Ruda25JswraPU?usp=sharing

@l-mengwei
Copy link

I write a python script to prepare the data, maybe you want to try it
https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14

@qzane Thank you for your python script. But this only generates the edges file and the respective blank(black) images. Do you have a python script to generate labels as well?

@gayalkuruppu I don't think you need labels to get the correct output. I created a folder with custom images, ran the python script that was linked to in a previous comment (https://gist.github.com/qzane/4d07b7551914f97f2bf8b9c79138ab14 and I saved it as prepare_dataset.py) with

python prepare_dataset.py custom_dataset/CIHP/images CIHP

and it created a new folder within datasets/ called CIHP (it'll be named whatever you use as the last argument in the previous python command).

The new folder has the structure

CIHP_PGN/
├─ datasets/
│  ├─ CIHP/
│  │  ├─ edges/
│  │  │  ├─ image0.png
│  │  │  ├─ image1.png
│  │  ├─ images/
│  │  │  ├─ image0.png
│  │  │  ├─ image1.jpg
│  │  ├─ list/
│  │  │  ├─ val_id.txt
│  │  │  ├─ val.txt

and then I was able to run python test_pgn.py and see the results in CIHP_PGN/output/cihp_parsing_maps/

Sorry to bother you now, I just tried to run this script, but the resulting edges are full black images and not producing the correct edge images. How to solve this please? Thank you~

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