<jupyter_start><jupyter_text>Test and Show ParseOp<jupyter_code>import sys
sys.path.append('/opt/segelectri')
from test_parse_img_op import TestParseImgOp
import matplotlib.pyplot as plt
origin_img, mask_img = TestParseImgOp().parse_sample_file()
plt.imshow(origin_img)
origin_img[:3, :3, :], mask_img[:3, :3, :]<jupyter_output><empty_output><jupyter_text>Visualize segmentation result<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import os

from PIL import Image
def visualize_img(image_path: str, index: int):
    # VISUALIZE_MAPPER = {
    #     0: 2, # 其他
    #     1: 8, # 植被
    #     2: 16, # 建筑
    #     3: 32, # 水系
    # }
    VISUALIZE_MAPPER = np.array([[0, 64, 64], [64, 0, 64], [64, 64, 0], [64, 64, 64]], dtype=np.uint8)

    original_path = os.path.join(image_path, f'{index}.png')
    original_img = Image.open(original_path)

    mask_path = os.path.join(image_path, f'{index}_class.png')
    mask_img = Image.open(mask_path)

    original_img = np.array(original_img)
    mask_img = np.array(mask_img)[:, :, 0]
    mapped_mask_img = VISUALIZE_MAPPER[mask_img]
    plt.imshow(original_img)
    plt.imshow(mapped_mask_img, alpha=0.7)
    plt.show()

visualize_img('/opt/dataset/tr2_cropped/', 10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13946117274167988, 'fraction_numerical': 0.03328050713153724, 'mean_word_length': 4.397435897435898, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '417543', 'license': 'MIT', 'n_tokens_mistral': 543, 'n_tokens_neox': 507, 'n_words': 93, 'path': 'test/test_data_loader/test_utils/show_img.ipynb', 'repo_name': 'imabackstabber/segment-with-nn', 'size': '1262'}