kanezaki / pytorch-unsupervised-segmentation-tip

MIT License
259 stars 58 forks source link

About the evaluation metric mIoU. #2

Open forrestsz opened 4 years ago

forrestsz commented 4 years ago

Hi, thank for your nice work and job. After reading your code, i have a little question. can you share the code how to compute the mIoU in unsupervised way, because which is different from supervised segmentation. Thank you!👍

kanezaki commented 3 years ago

Thanks for your comment! The code is coming soon. The sample code and segments are currently in my Dropbox link here.

$ python miou_calculation.py --bsd500 --mode 1 --gt ./gt --input ./results

mode 1: "all" mode 2: "fine" mode 3: "coarse"

Before mIOU calculation, you need to distinguish unconnected segments that have the same class labels. I used this library to relabel connected components.

forrestsz commented 3 years ago

great thank for your reply!

euwern commented 3 years ago

Thanks for your comment! The code is coming soon. The sample code and segments are currently in my Dropbox link here.

$ python miou_calculation.py --bsd500 --mode 1 --gt ./gt --input ./results

mode 1: "all" mode 2: "fine" mode 3: "coarse"

Before mIOU calculation, you need to distinguish unconnected segments that have the same class labels. I used this library to relabel connected components.

Can you describe how you use the library (mentioned above) to relabel connected components? Assuming that I have just cloned the repo and compile the library, what's the next step? It will be helpful if you can share the command line to relabel the connected components.

kanezaki commented 3 years ago

I used the function SuperpixelTools::relabelConnectedSuperpixels(segmentation) in examples/cpp/evaluation.cpp. To obtain the output, I inserted the following lines in L151 and then used the executable bin/example_evaluation.

    for (int i = 0; i < segmentation.rows; ++i) {
        for (int j = 0; j < segmentation.cols-1; ++j) {
          std::cerr << segmentation.at<int>(i, j) << ",";
        }
        std::cerr << segmentation.at<int>(i, segmentation.cols-1) << std::endl;
    }
charleneolive commented 3 years ago

Regarding your code, what is the use of these lines?

gg = np.zeros(gt_array.shape) gt_mask = np.where(gt_array > 0, 1, gg) determinant_array = gt_mask * input_array label_list = np.unique(gt_array)

I saw that you have defined label_list already above.

lutfiex commented 2 years ago

Thanks for your comment! The code is coming soon. The sample code and segments are currently in my Dropbox link here.

$ python miou_calculation.py --bsd500 --mode 1 --gt ./gt --input ./results

mode 1: "all" mode 2: "fine" mode 3: "coarse"

Before mIOU calculation, you need to distinguish unconnected segments that have the same class labels. I used this library to relabel connected components.

have the other method to relabel connected components?