Javiai commited on
Commit
d3c4073
·
1 Parent(s): 9889cab

Updating the Readme

Browse files
Files changed (1) hide show
  1. README.md +51 -1
README.md CHANGED
@@ -34,4 +34,54 @@ size_categories:
34
  - n<1K
35
  ---
36
 
37
- # tiutolo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  - n<1K
35
  ---
36
 
37
+ # Failures in 3D printing Dataset
38
+
39
+ This is a small dataset of images from failures in 3D print
40
+
41
+ ## Structure
42
+
43
+ The structure of the dataset is
44
+
45
+ - **image_id:** Id of the image
46
+ - **image:** Image instance in PIL format
47
+ - **width:** Width of the image in pixels
48
+ - **height:** Height of the image in pixels
49
+ - **objects:** bounding boxes in the images
50
+ - **bbox:** coordinates of the bounding box. The coordinates are [x_center, y_center, bbox width, bbox height]
51
+ - **categories:** category of the bounding box. The categories are 0: error, 1: extrusor, 2: part and 3: spaghetti
52
+
53
+
54
+
55
+ ## Download the dataset
56
+
57
+ '''
58
+ from datasets import load_dataset
59
+
60
+ dataset = load_dataset('Javiai/failures-3D-print')
61
+ '''
62
+
63
+ ## Show the Bounding Boxes
64
+
65
+ '''
66
+ import numpy as np
67
+ import os
68
+ from PIL import Image, ImageDraw
69
+
70
+ image = dataset["train"][0]["image"]
71
+ annotations = dataset["train"][0]["objects"]
72
+ draw = ImageDraw.Draw(image)
73
+
74
+ categories = ['error','extrusor','part','spagheti']
75
+
76
+ id2label = {index: x for index, x in enumerate(categories, start=0)}
77
+ label2id = {v: k for k, v in id2label.items()}
78
+
79
+ for i in range(len(annotations["categories"])):
80
+ box = annotations["bbox"][i]
81
+ class_idx = annotations["categories"][i]
82
+ x, y, w, h = tuple(box)
83
+ draw.rectangle((x - w/2, y - h/2, x + w/2, y + h/2), outline="red", width=1)
84
+ draw.text((x - w/2, y - h/2), id2label[class_idx], fill="white")
85
+
86
+ image
87
+ '''