Dataset Card for Dataset CrashCar
This is the dataset proposed in 'CrashCar101: Procedural Generation for Damage Assessment' [WACV24]
- Project Page: https://crashcar.compute.dtu.dk
- Repository: https://github.com/JensPars/CrashCar_procedural_generation
- Paper: https://openaccess.thecvf.com/content/WACV2024/papers/Parslov_CrashCar101_Procedural_Generation_for_Damage_Assessment_WACV_2024_paper.pdf
Example dataset class in pytorch
import os
import torch
from glob import glob
from PIL import Image
import numpy as np
from pathlib import Path
import pandas as pd
class CarDataset(torch.utils.data.Dataset):
def __init__(self, root_dir, transform=None, tgt_transform=None):
img_root = os.path.join(root_dir, 'img', '*', '*.png')
part_root = os.path.join(root_dir, 'parts', '*', '*.png')
damage_root = os.path.join(root_dir, 'damage', '*', '*.png')
self.img_root = sorted(glob(img_root))
self.part_root = sorted(glob(part_root))
self.damage_root = sorted(glob(damage_root))
self.transform = transform
self.tgt_transform = tgt_transform
def __len__(self):
return len(self.img_root)
def __getitem__(self, idx):
img = Image.open(self.img_root[idx])
part_img = Image.open(self.part_root[idx])
damage_img = Image.open(self.damage_root[idx])
if self.transform:
img = self.transform(img)
part_img = self.transform(part_img)
damage_img = self.transform(damage_img)
return {
'image': img,
'part': part_img,
'damage': damage_img
}
The following code will yield
import matplotlib.pyplot as plt
import numpy as np
dataset = CarDataset(root, transform=None)
out = dataset[20000]
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
axs[0].imshow(out['image'])
axs[0].axis('off')
axs[1].imshow(out['image'])
alpha_map = (np.array(out['damage'])!= 0).astype(float)
axs[1].imshow(out['damage'], cmap="jet", alpha=alpha_map)
axs[1].axis('off')
axs[2].imshow(out['image'])
alpha_map = (np.array(out['part'])!= 0).astype(float)
axs[2].imshow(out['part'], cmap="jet", alpha=alpha_map)
axs[2].axis('off')
plt.tight_layout()
plt.show()
- Downloads last month
- 31