text_plain_output_1.png
from PIL import Image

import matplotlib.pyplot as plt

import os

import pandas as pd

import random

root_dir = '/kaggle/input/image-matching-challenge-2023'
train_labels_file = os.path.join(root_dir, 'train/train_labels.csv')
train_labels = pd.read_csv(train_labels_file)

train_labels.columns

dataset_counts = train_labels['dataset'].value_counts()
scene_counts = train_labels['scene'].value_counts()

num_images_to_show = 5
random_image_indices = random.sample(range(len(train_labels)), num_images_to_show)
fig, axes = plt.subplots(1, num_images_to_show, figsize=(20, 5))
train_folder = os.path.join(root_dir, 'train')
for i, image_index in enumerate(random_image_indices):
    relative_image_path = train_labels.iloc[image_index]['image_path']
    image_path = os.path.join(train_folder, relative_image_path)
    img = Image.open(image_path)
    axes[i].imshow(img)
    axes[i].set_title(f"Dataset: {train_labels.iloc[image_index]['dataset']} | Scene: {train_labels.iloc[image_index]['scene']}")
    axes[i].axis('off')
plt.show()