| from datasets import load_dataset |
| import os |
| from PIL import Image |
| import matplotlib.pyplot as plt |
|
|
|
|
| |
| dataset = load_dataset( |
| 'json', |
| data_files={'test': 'data/test.jsonl'}, |
| split='test' |
| ) |
|
|
| v1_dataset = dataset.filter(lambda x: x['task'] == 4) |
| print(f"Total entries in V1: {len(v1_dataset)}") |
| if len(v1_dataset) > 0: |
| print(v1_dataset[0]) |
| item = v1_dataset[0] |
| |
| img_path = os.path.join('data', item['ground_truth']) |
| |
| print(f"Trying to open the image:{img_path}") |
| |
| if os.path.exists(img_path): |
| img = Image.open(img_path) |
| |
| plt.figure(figsize=(6, 6)) |
| plt.imshow(img, cmap='gray' if img.mode == 'L' else None) |
| plt.title(f"ID: {item['id']} | Task: {item['task']}") |
| plt.axis('off') |
| plt.show() |
| else: |
| print(f"file not found {img_path}") |
|
|
| |
| if "image1_path" in item.keys(): |
| img1_path = os.path.join('data', item['image1_path']) |
| print(f"Trying to open the image:{img1_path}") |
| |
| if os.path.exists(img1_path): |
| img1 = Image.open(img1_path) |
| plt.figure(figsize=(6, 6)) |
| plt.imshow(img1, cmap='gray' if img1.mode == 'L' else None) |
| plt.title(f"ID: {item['id']} | Task: {item['task']} - Image 1") |
| plt.axis('off') |
| plt.show() |
| else: |
| print(f"file not found {img1_path}") |