Code snippet to visualise the position of the box
import matplotlib.image as img
import matplotlib.pyplot as plt
from datasets import load_dataset
from matplotlib.patches import Rectangle
ds_name = "HuggingFaceM4/FGVC-Aircraft"
ds = load_dataset(ds_name, use_auth_token=True)
index = 300
sample = ds["train"][index]
box_coord = sample["bbox"]
xmin = box_coord["xmin"]
ymin = box_coord["ymin"]
xmax = box_coord["xmax"]
ymax = box_coord["ymax"]
img_path = sample["image"].filename
fig, ax = plt.subplots()
image = img.imread(img_path)
ax.imshow(image)
ax.add_patch(
Rectangle((xmin, ymin), xmax-xmin, ymax - ymin, fill=None)
)
plt.show()