shivahanifi / SCDD-image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html
MIT License
0 stars 0 forks source link

Not detecting background #8

Closed shivahanifi closed 1 day ago

shivahanifi commented 2 days ago

For the models trained on dataset_20211104 the model detects all the background as the 21,feature,frame edge,Aqua marine,127,255,215,212 ARTS_00020_r5_c1 png_9_61514e254862b98160af

shivahanifi commented 1 day ago

For the background class (0,feature,bckgnd,Black,0,0,0,0) while it shows the 0.89054837 class_wise_IU there is no color black appearing in the predicted frames.

TO DO

shivahanifi commented 1 day ago

Solution

The problem was with the code not attributing the correct color codes to labels( found by tracking back up to visualize_segmentation function). Solved by making it read them through the provided `share/SCDD_20211104/ListOfClassesAndColorCodes_20211104.csv' file.

# CSV file for classes
csv_path = "/SCDD-image-segmentation-keras/share/SCDD_20211104/ListOfClassesAndColorCodes_20211104.csv"
df = pd.read_csv(csv_path)
colors = df[['Red', 'Green','Blue']].apply(lambda x: (x['Red'], x['Green'], x['Blue']), axis=1).tolist()
class_names = df['Desc'].tolist()
wandb.config.colors = colors
wandb.config.labels_Desc = class_names

The color code is used in the predict function. Also a legend is attached for better visualization.

# Predict segmentation
predictions = model.predict_multiple(
    inp_dir=test_image_path,
    out_dir=prediction_output_dir,
    class_names=class_names,
    show_legends=True,
    colors=colors,
)

media_images_predictions_CSIR_00201_r4_c6 png_26_df55403f7d5929b74dad