Engineering-Course / CIHP_PGN

Code repository for Part Grouping Network, ECCV 2018
MIT License
430 stars 117 forks source link

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

Open lemon1220 opened 5 years ago

lemon1220 commented 5 years ago

@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 https://github.com/Engineering-Course/CIHP_PGN/issues/26#issuecomment-496198813_

lemon1220 commented 5 years ago

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

lemon1220 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

MuhammadAsadJaved commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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

MuhammadAsadJaved commented 4 years ago

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

MuhammadAsadJaved commented 4 years ago

@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 commented 4 years ago

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

MuhammadAsadJaved commented 4 years ago

I have sent these pictures to your personal email address sir.

On Fri, Dec 6, 2019 at 3:37 AM qzane notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Engineering-Course/CIHP_PGN/issues/38?email_source=notifications&email_token=AG4GR5EOFPU4275XVNUKN73QXFJ6PA5CNFSM4ITM6LNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGB4EAA#issuecomment-562283008, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG4GR5H54FVMAYXILJQL7W3QXFJ6PANCNFSM4ITM6LNA .

neonb88 commented 4 years ago

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

neonb88 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 3 years ago

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 _preparedataset.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_parsingmaps/

confifu commented 3 years ago

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

l-mengwei commented 2 years ago

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 _preparedataset.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_parsingmaps/

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~