-
Notifications
You must be signed in to change notification settings - Fork 228
/
movi_f.py
1679 lines (1582 loc) · 126 KB
/
movi_f.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2024 The Kubric Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=line-too-long, unexpected-keyword-arg
import dataclasses
import json
import logging
from typing import List, Dict, Union
from etils import epath
import imageio
import numpy as np
import png
import tensorflow as tf
import tensorflow_datasets.public_api as tfds
_DESCRIPTION = """
Very similar to MOVi-E, except that it adds a random amount of motion blur.
A simple rigid-body simulation with GSO objects and an HDRI background.
The scene consists of a dome (half-sphere) onto which a random HDRI is projected,
which acts as background, floor and lighting.
The scene contains between 10 and 20 random static objects, and between 1 and 3
dynamic objects (tossed onto the others).
The camera moves on a straight line with constant velocity.
The starting point is sampled randomly in a half-sphere shell around the scene,
and from there the camera moves into a random direction with a random speed between 0 and 4.
This sampling process is repeated until a trajectory is found that starts and
ends within the specified half-sphere shell around the center of the scene.
The camera always points towards the origin.
Static objects are spawned without overlap in the region [(-7, -7, 0), (7, 7, 10)],
and are simulated to fall and settle before the first frame of the scene.
Dynamic objects are spawned without overlap in the region [(-5, -5, 1), (5, 5, 5)], and
initialized with a random velocity from the range [(-4, -4, 0), (4, 4, 0)]
minus the position of the object to bias their trajectory towards the center of
the scene.
The scene is simulated for 2 seconds, with the physical properties of the
objects kept at the default of friction=0.5, restitution=0.5 and density=1.0.
The dataset contains approx 6k videos rendered at 512x512 pixels and 12fps.
Each sample contains the following video-format data:
(s: sequence length, h: height, w: width)
- "video": (s, h, w, 3) [uint8]
The RGB frames.
- "segmentations": (s, h, w, 1) [uint8]
Instance segmentation as per-pixel object-id with background=0.
Note: because of this the instance IDs used here are one higher than their
corresponding index in sample["instances"].
- "depth": (s, h, w, 1) [uint16]
Distance of each pixel from the center of the camera.
(Note this is different from the z-value sometimes used, which measures the
distance to the camera *plane*.)
The values are stored as uint16 and span the range specified in
sample["metadata"]["depth_range"]. To convert them back to world-units
use:
minv, maxv = sample["metadata"]["depth_range"]
depth = sample["depth"] / 65535 * (maxv - minv) + minv
- "forward_flow": (s, h, w, 2) [uint16]
Forward optical flow in the form (delta_row, delta_column).
The values are stored as uint16 and span the range specified in
sample["metadata"]["forward_flow_range"]. To convert them back to pixels use:
minv, maxv = sample["metadata"]["forward_flow_range"]
depth = sample["forward_flow"] / 65535 * (maxv - minv) + minv
- "backward_flow": (s, h, w, 2) [uint16]
Backward optical flow in the form (delta_row, delta_column).
The values are stored as uint16 and span the range specified in
sample["metadata"]["backward_flow_range"]. To convert them back to pixels use:
minv, maxv = sample["metadata"]["backward_flow_range"]
depth = sample["backward_flow"] / 65535 * (maxv - minv) + minv
- "normal": (s, h, w, 3) [uint16]
Surface normals for each pixel in world coordinates.
- "object_coordinates": (s, h, w, 3) [uint16]
Object coordinates encode the position of each point relative to the objects
bounding box (i.e. back-left-top (X=Y=Z=1) corner is white,
while front-right-bottom (X=Y=Z=0) corner is black.)
Additionally there is rich instance-level information in sample["instances"]:
- "mass": [float32]
Mass of the object used for simulation.
- "friction": [float32]
Friction coefficient used for simulation.
- "restitution": [float32]
Restitution coefficient (bounciness) used for simulation.
- "positions": (s, 3) [float32]
Position of the object for each frame in world-coordinates.
- "quaternions": (s, 4) [float32]
Rotation of the object for each frame as quaternions.
- "velocities": (s, 3) [float32]
Velocity of the object for each frame.
- "angular_velocities": (s, 3) [float32]
Angular velocity of the object for each frame.
- "bboxes_3d": (s, 8, 3) [float32]
World-space corners of the 3D bounding box around the object.
- "image_positions": (s, 2) [float32]
Normalized (0, 1) image-space (2D) coordinates of the center of mass of the
object for each frame.
- "bboxes": (None, 4) [float32]
The normalized image-space (2D) coordinates of the bounding box
[ymin, xmin, ymax, xmax] for all the frames in which the object is visible
(as specified in bbox_frames).
- "bbox_frames": (None,) [int]
A list of all the frames the object is visible.
- "visibility": (s,) [uint16]
Visibility of the object in number of pixels for each frame (can be 0).
- "asset_id": [str] Asset id from Google Scanned Objects dataset.
- "category": ["Action Figures", "Bag", "Board Games",
"Bottles and Cans and Cups", "Camera", "Car Seat",
"Consumer Goods", "Hat", "Headphones", "Keyboard", "Legos",
"Media Cases", "Mouse", "None", "Shoe", "Stuffed Toys", "Toys"]
- "scale": float
- "is_dynamic": bool indicating whether (at the start of the scene) the object
is sitting on the floor or is being tossed.
Information about the camera in sample["camera"]
(given for each frame eventhough the camera is static, so as to stay
consistent with other variants of the dataset):
- "focal_length": [float32]
- "sensor_width": [float32]
- "field_of_view": [float32]
- "positions": (s, 3) [float32]
- "quaternions": (s, 4) [float32]
And finally information about collision events in sample["events"]["collisions"]:
- "instances": (2,)[uint16]
Indices of the two instance between which the collision happened.
Note that collisions with the floor/background objects are marked with 65535
- "frame": tf.int32,
Frame in which the collision happenend.
- "force": tf.float32,
The force (strength) of the collision.
- "position": tfds.features.Tensor(shape=(3,), dtype=tf.float32),
Position of the collision event in 3D world coordinates.
- "image_position": tfds.features.Tensor(shape=(2,), dtype=tf.float32),
Position of the collision event projected onto normalized 2D image coordinates.
- "contact_normal": tfds.features.Tensor(shape=(3,), dtype=tf.float32),
The normal-vector of the contact (direction of the force).
"""
_CITATION = """\
@inproceedings{greff2022kubric,
title = {Kubric: a scalable dataset generator},
author = {Klaus Greff and Francois Belletti and Lucas Beyer and Carl Doersch and
Yilun Du and Daniel Duckworth and David J Fleet and Dan Gnanapragasam and
Florian Golemo and Charles Herrmann and Thomas Kipf and Abhijit Kundu and
Dmitry Lagun and Issam Laradji and Hsueh-Ti (Derek) Liu and Henning Meyer and
Yishu Miao and Derek Nowrouzezahrai and Cengiz Oztireli and Etienne Pot and
Noha Radwan and Daniel Rebain and Sara Sabour and Mehdi S. M. Sajjadi and Matan Sela and
Vincent Sitzmann and Austin Stone and Deqing Sun and Suhani Vora and Ziyu Wang and
Tianhao Wu and Kwang Moo Yi and Fangcheng Zhong and Andrea Tagliasacchi},
booktitle = {{IEEE} Conference on Computer Vision and Pattern Recognition, {CVPR}},
year = {2022},
publisher = {Computer Vision Foundation / {IEEE}},
}"""
@dataclasses.dataclass
class MoviFConfig(tfds.core.BuilderConfig):
""""Configuration for Multi-Object Video (MoviF) dataset."""
height: int = 256
width: int = 256
num_frames: int = 24
validation_ratio: float = 0.1
train_val_path: str = None
test_split_paths: Dict[str, str] = dataclasses.field(default_factory=dict)
class MoviF(tfds.core.BeamBasedBuilder):
"""DatasetBuilder for MOVi-F dataset."""
VERSION = tfds.core.Version("1.0.0")
RELEASE_NOTES = {
"1.0.0": "initial release",
}
BUILDER_CONFIGS = [
MoviFConfig(
name="512x512",
description="Full resolution of 512x512",
height=512,
width=512,
validation_ratio=0.025,
train_val_path="gs://research-brain-kubric-xgcp/jobs/movid_flow_v2_600_1/",
test_split_paths={
}
),
MoviFConfig(
name="256x256",
description="Downscaled to 256x256",
height=256,
width=256,
validation_ratio=0.025,
train_val_path="gs://research-brain-kubric-xgcp/jobs/movid_flow_v2_600_1/",
test_split_paths={
}
),
MoviFConfig(
name="128x128",
description="Downscaled to 128x128",
height=128,
width=128,
validation_ratio=0.025,
train_val_path="gs://research-brain-kubric-xgcp/jobs/movid_flow_v2_600_1/",
test_split_paths={
}
),
]
def _info(self) -> tfds.core.DatasetInfo:
"""Returns the dataset metadata."""
h = self.builder_config.height
w = self.builder_config.width
s = self.builder_config.num_frames
def get_movi_f_instance_features(seq_length: int):
features = get_instance_features(seq_length)
features.update({
"asset_id": tfds.features.Text(),
"category": tfds.features.ClassLabel(
names=["Action Figures", "Bag", "Board Games",
"Bottles and Cans and Cups", "Camera",
"Car Seat", "Consumer Goods", "Hat",
"Headphones", "Keyboard", "Legos",
"Media Cases", "Mouse", "None", "Shoe",
"Stuffed Toys", "Toys"]),
"scale": tf.float32,
"is_dynamic": tf.bool,
})
return features
return tfds.core.DatasetInfo(
builder=self,
description=_DESCRIPTION,
features=tfds.features.FeaturesDict({
"metadata": {
"video_name": tfds.features.Text(),
"width": tf.int32,
"height": tf.int32,
"num_frames": tf.int32,
"num_instances": tf.uint16,
"depth_range": tfds.features.Tensor(shape=(2,),
dtype=tf.float32),
"forward_flow_range": tfds.features.Tensor(shape=(2,),
dtype=tf.float32),
"backward_flow_range": tfds.features.Tensor(shape=(2,),
dtype=tf.float32),
"motion_blur": tf.float32,
},
"background": tfds.features.Text(),
"instances": tfds.features.Sequence(
feature=get_movi_f_instance_features(seq_length=s)),
"camera": get_camera_features(s),
"events": get_events_features(),
# -----
"video": tfds.features.Video(shape=(s, h, w, 3)),
"segmentations": tfds.features.Sequence(
tfds.features.Image(shape=(h, w, 1), dtype=tf.uint8),
length=s),
"forward_flow": tfds.features.Sequence(
tfds.features.Tensor(shape=(h, w, 2), dtype=tf.uint16),
length=s),
"backward_flow": tfds.features.Sequence(
tfds.features.Tensor(shape=(h, w, 2), dtype=tf.uint16),
length=s),
"depth": tfds.features.Sequence(
tfds.features.Image(shape=(h, w, 1), dtype=tf.uint16),
length=s),
"normal": tfds.features.Video(shape=(s, h, w, 3), dtype=tf.uint16),
"object_coordinates": tfds.features.Video(shape=(s, h, w, 3),
dtype=tf.uint16),
}),
supervised_keys=None,
homepage="https://github.com/google-research/kubric",
citation=_CITATION)
def _split_generators(self, unused_dl_manager: tfds.download.DownloadManager):
"""Returns SplitGenerators."""
del unused_dl_manager
path = as_path(self.builder_config.train_val_path)
all_subdirs = [str(d) for d in path.iterdir()]
logging.info("Found %d sub-folders in master path: %s",
len(all_subdirs), path)
# shuffle
rng = np.random.RandomState(seed=42)
rng.shuffle(all_subdirs)
validation_ratio = self.builder_config.validation_ratio
validation_examples = max(1, round(len(all_subdirs) * validation_ratio))
training_examples = len(all_subdirs) - validation_examples
logging.info("Using %f of examples for validation for a total of %d",
validation_ratio, validation_examples)
logging.info("Using the other %d examples for training", training_examples)
splits = {
tfds.Split.TRAIN: self._generate_examples(all_subdirs[:training_examples]),
tfds.Split.VALIDATION: self._generate_examples(all_subdirs[training_examples:]),
}
for key, path in self.builder_config.test_split_paths.items():
path = as_path(path)
split_dirs = [d for d in path.iterdir()]
# sort the directories by their integer number
split_dirs = sorted(split_dirs, key=lambda x: int(x.name))
logging.info("Found %d sub-folders in '%s' path: %s",
len(split_dirs), key, path)
splits[key] = self._generate_examples([str(d) for d in split_dirs])
return splits
def _generate_examples(self, directories: List[str]):
"""Yields examples."""
target_size = (self.builder_config.height, self.builder_config.width)
def _process_example(video_dir):
key, result, metadata = load_scene_directory(video_dir, target_size)
# add MoviF-D specific instance information:
for i, obj in enumerate(result["instances"]):
obj["asset_id"] = metadata["instances"][i]["asset_id"]
scale_factor, category = get_scale_and_category(obj["asset_id"] )
obj["category"] = category
obj["scale"] = metadata["instances"][i]["scale"] * scale_factor
obj["is_dynamic"] = metadata["instances"][i]["is_dynamic"]
return key, result
beam = tfds.core.lazy_imports.apache_beam
return (beam.Create(directories) |
beam.Filter(is_complete_dir) |
beam.Map(_process_example))
DEFAULT_LAYERS = ("rgba", "segmentation", "forward_flow", "backward_flow",
"depth", "normal", "object_coordinates")
def load_scene_directory(scene_dir, target_size, layers=DEFAULT_LAYERS):
scene_dir = as_path(scene_dir)
example_key = f"{scene_dir.name}"
with tf.io.gfile.GFile(str(scene_dir / "data_ranges.json"), "r") as fp:
data_ranges = json.load(fp)
with tf.io.gfile.GFile(str(scene_dir / "metadata.json"), "r") as fp:
metadata = json.load(fp)
with tf.io.gfile.GFile(str(scene_dir / "events.json"), "r") as fp:
events = json.load(fp)
num_frames = metadata["metadata"]["num_frames"]
result = {
"metadata": {
"video_name": example_key,
"width": target_size[1],
"height": target_size[0],
"num_frames": num_frames,
"num_instances": metadata["metadata"]["num_instances"],
"motion_blur": metadata["metadata"]["motion_blur"]
},
"background": metadata["metadata"]["background"],
"instances": [format_instance_information(obj)
for obj in metadata["instances"]],
"camera": format_camera_information(metadata),
"events": format_events_information(events),
}
resolution = metadata["metadata"]["height"], metadata["metadata"]["width"]
assert resolution[1] / target_size[0] == resolution[0] / target_size[1]
scale = resolution[1] / target_size[0]
assert scale == resolution[1] // target_size[0]
paths = {
key: [scene_dir / f"{key}_{f:05d}.png" for f in range(num_frames)]
for key in layers if key != "depth"
}
if "depth" in layers:
depth_paths = [scene_dir / f"depth_{f:05d}.tiff" for f in range(num_frames)]
depth_frames = np.array([
subsample_nearest_neighbor(read_tiff(frame_path), target_size)
for frame_path in depth_paths])
depth_min, depth_max = np.min(depth_frames), np.max(depth_frames)
result["depth"] = convert_float_to_uint16(depth_frames, depth_min, depth_max)
result["metadata"]["depth_range"] = [depth_min, depth_max]
if "forward_flow" in layers:
result["metadata"]["forward_flow_range"] = [
data_ranges["forward_flow"]["min"] / scale * 512,
data_ranges["forward_flow"]["max"] / scale * 512]
result["forward_flow"] = [
subsample_nearest_neighbor(read_png(frame_path)[..., :2],
target_size)
for frame_path in paths["forward_flow"]]
if "backward_flow" in layers:
result["metadata"]["backward_flow_range"] = [
data_ranges["backward_flow"]["min"] / scale * 512,
data_ranges["backward_flow"]["max"] / scale * 512]
result["backward_flow"] = [
subsample_nearest_neighbor(read_png(frame_path)[..., :2],
target_size)
for frame_path in paths["backward_flow"]]
for key in ["normal", "object_coordinates", "uv"]:
if key in layers:
result[key] = [
subsample_nearest_neighbor(read_png(frame_path),
target_size)
for frame_path in paths[key]]
if "segmentation" in layers:
# somehow we ended up calling this "segmentations" in TFDS and
# "segmentation" in kubric. So we have to treat it separately.
result["segmentations"] = [
subsample_nearest_neighbor(read_png(frame_path),
target_size)
for frame_path in paths["segmentation"]]
if "rgba" in layers:
result["video"] = [
subsample_avg(read_png(frame_path), target_size)[..., :3]
for frame_path in paths["rgba"]]
return example_key, result, metadata
def get_camera_features(seq_length):
return {
"focal_length": tf.float32,
"sensor_width": tf.float32,
"field_of_view": tf.float32,
"positions": tfds.features.Tensor(shape=(seq_length, 3),
dtype=tf.float32),
"quaternions": tfds.features.Tensor(shape=(seq_length, 4),
dtype=tf.float32),
}
def format_camera_information(metadata):
return {
"focal_length": metadata["camera"]["focal_length"],
"sensor_width": metadata["camera"]["sensor_width"],
"field_of_view": metadata["camera"]["field_of_view"],
"positions": np.array(metadata["camera"]["positions"], np.float32),
"quaternions": np.array(metadata["camera"]["quaternions"], np.float32),
}
def get_events_features():
return {
"collisions": tfds.features.Sequence({
"instances": tfds.features.Tensor(shape=(2,), dtype=tf.uint16),
"frame": tf.int32,
"force": tf.float32,
"position": tfds.features.Tensor(shape=(3,), dtype=tf.float32),
"image_position": tfds.features.Tensor(shape=(2,), dtype=tf.float32),
"contact_normal": tfds.features.Tensor(shape=(3,), dtype=tf.float32),
})
}
def format_events_information(events):
return {
"collisions": [{
"instances": np.array(c["instances"], dtype=np.uint16),
"frame": c["frame"],
"force": c["force"],
"position": np.array(c["position"], dtype=np.float32),
"image_position": np.array(c["image_position"], dtype=np.float32),
"contact_normal": np.array(c["contact_normal"], dtype=np.float32),
} for c in events["collisions"]],
}
def get_instance_features(seq_length: int):
return {
"mass": tf.float32,
"friction": tf.float32,
"restitution": tf.float32,
"positions": tfds.features.Tensor(shape=(seq_length, 3),
dtype=tf.float32),
"quaternions": tfds.features.Tensor(shape=(seq_length, 4),
dtype=tf.float32),
"velocities": tfds.features.Tensor(shape=(seq_length, 3),
dtype=tf.float32),
"angular_velocities": tfds.features.Tensor(shape=(seq_length, 3),
dtype=tf.float32),
"bboxes_3d": tfds.features.Tensor(shape=(seq_length, 8, 3),
dtype=tf.float32),
"image_positions": tfds.features.Tensor(shape=(seq_length, 2),
dtype=tf.float32),
"bboxes": tfds.features.Sequence(
tfds.features.BBoxFeature()),
"bbox_frames": tfds.features.Sequence(
tfds.features.Tensor(shape=(), dtype=tf.int32)),
"visibility": tfds.features.Tensor(shape=(seq_length,), dtype=tf.uint16),
}
def format_instance_information(obj):
return {
"mass": obj["mass"],
"friction": obj["friction"],
"restitution": obj["restitution"],
"positions": np.array(obj["positions"], np.float32),
"quaternions": np.array(obj["quaternions"], np.float32),
"velocities": np.array(obj["velocities"], np.float32),
"angular_velocities": np.array(obj["angular_velocities"], np.float32),
"bboxes_3d": np.array(obj["bboxes_3d"], np.float32),
"image_positions": np.array(obj["image_positions"], np.float32),
"bboxes": [tfds.features.BBox(*bbox) for bbox in obj["bboxes"]],
"bbox_frames": np.array(obj["bbox_frames"], dtype=np.uint16),
"visibility": np.array(obj["visibility"], dtype=np.uint16),
}
def subsample_nearest_neighbor(arr, size):
src_height, src_width, _ = arr.shape
dst_height, dst_width = size
height_step = src_height // dst_height
width_step = src_width // dst_width
assert height_step * dst_height == src_height
assert width_step * dst_width == src_width
height_offset = int(np.floor((height_step-1)/2))
width_offset = int(np.floor((width_step-1)/2))
subsampled = arr[height_offset::height_step, width_offset::width_step, :]
return subsampled
def convert_float_to_uint16(array, min_val, max_val):
return np.round((array - min_val) / (max_val - min_val) * 65535
).astype(np.uint16)
def subsample_avg(arr, size):
src_height, src_width, channels = arr.shape
dst_height, dst_width = size
height_bin = src_height // dst_height
width_bin = src_width // dst_width
return np.round(arr.reshape((dst_height, height_bin,
dst_width, width_bin,
channels)).mean(axis=(1, 3))).astype(np.uint8)
def is_complete_dir(video_dir, layers=DEFAULT_LAYERS):
video_dir = as_path(video_dir)
filenames = [d.name for d in video_dir.iterdir()]
if not ("data_ranges.json" in filenames and
"metadata.json" in filenames and
"events.json" in filenames):
return False
nr_frames_per_category = {
key: len([fn for fn in filenames if fn.startswith(key)])
for key in layers}
nr_expected_frames = nr_frames_per_category["rgba"]
if nr_expected_frames == 0:
return False
if not all(nr_frames == nr_expected_frames
for nr_frames in nr_frames_per_category.values()):
return False
return True
PathLike = Union[str, epath.Path]
def as_path(path: PathLike) -> epath.Path:
"""Convert str or pathlike object to epath.Path.
Instead of pathlib.Paths, we use the TFDS path because they transparently
support paths to GCS buckets such as "gs://kubric-public/GSO".
"""
return tfds.core.as_path(path)
def read_png(filename, rescale_range=None) -> np.ndarray:
filename = as_path(filename)
png_reader = png.Reader(bytes=filename.read_bytes())
width, height, pngdata, info = png_reader.read()
del png_reader
bitdepth = info["bitdepth"]
if bitdepth == 8:
dtype = np.uint8
elif bitdepth == 16:
dtype = np.uint16
else:
raise NotImplementedError(f"Unsupported bitdepth: {bitdepth}")
plane_count = info["planes"]
pngdata = np.vstack(list(map(dtype, pngdata)))
if rescale_range is not None:
minv, maxv = rescale_range
pngdata = pngdata / 2**bitdepth * (maxv - minv) + minv
return pngdata.reshape((height, width, plane_count))
def write_tiff(data: np.ndarray, filename: PathLike):
"""Save data as as tif image (which natively supports float values)."""
assert data.ndim == 3, data.shape
assert data.shape[2] in [1, 3, 4], "Must be grayscale, RGB, or RGBA"
img_as_bytes = imageio.imwrite("<bytes>", data, format="tiff")
filename = as_path(filename)
filename.write_bytes(img_as_bytes)
def read_tiff(filename: PathLike) -> np.ndarray:
filename = as_path(filename)
img = imageio.imread(filename.read_bytes(), format="tiff")
if img.ndim == 2:
img = img[:, :, None]
return img
def get_scale_and_category(asset_id):
conversion_dict = {
'11pro_SL_TRX_FG': {'scale_factor': 0.290936, 'category': 'Shoe'},
'2_of_Jenga_Classic_Game': {'scale_factor': 0.292098, 'category': 'Consumer Goods'},
'30_CONSTRUCTION_SET': {'scale_factor': 0.26941899999999996, 'category': 'Toys'},
'3D_Dollhouse_Happy_Brother': {'scale_factor': 0.0955, 'category': 'Consumer Goods'},
'3D_Dollhouse_Lamp': {'scale_factor': 0.166821, 'category': 'Toys'},
'3D_Dollhouse_Refrigerator': {'scale_factor': 0.209969, 'category': 'Toys'},
'3D_Dollhouse_Sink': {'scale_factor': 0.131078, 'category': 'Toys'},
'3D_Dollhouse_Sofa': {'scale_factor': 0.209633, 'category': 'Toys'},
'3D_Dollhouse_Swing': {'scale_factor': 0.104819, 'category': 'Toys'},
'3D_Dollhouse_TablePurple': {'scale_factor': 0.09798799999999999, 'category': 'Toys'},
'3M_Antislip_Surfacing_Light_Duty_White': {'scale_factor': 0.154701, 'category': 'None'},
'3M_Vinyl_Tape_Green_1_x_36_yd': {'scale_factor': 0.110786, 'category': 'None'},
'45oz_RAMEKIN_ASST_DEEP_COLORS': {'scale_factor': 0.089988, 'category': 'Consumer Goods'},
'50_BLOCKS': {'scale_factor': 0.355794, 'category': 'Toys'},
'5_HTP': {'scale_factor': 0.08882299999999999, 'category': 'Bottles and Cans and Cups'},
'60_CONSTRUCTION_SET': {'scale_factor': 0.343594, 'category': 'Toys'},
'ACE_Coffee_Mug_Kristen_16_oz_cup': {'scale_factor': 0.134936, 'category': 'Consumer Goods'},
'ALPHABET_AZ_GRADIENT': {'scale_factor': 0.332328, 'category': 'Toys'},
'ALPHABET_AZ_GRADIENT_WQb1ufEycSj': {'scale_factor': 0.331944, 'category': 'Toys'},
'AMBERLIGHT_UP_W': {'scale_factor': 0.245312, 'category': 'Shoe'},
'ASICS_GEL1140V_WhiteBlackSilver': {'scale_factor': 0.280768, 'category': 'Shoe'},
'ASICS_GEL1140V_WhiteRoyalSilver': {'scale_factor': 0.28071500000000005, 'category': 'Shoe'},
'ASICS_GELAce_Pro_Pearl_WhitePink': {'scale_factor': 0.290163, 'category': 'Shoe'},
'ASICS_GELBlur33_20_GS_BlackWhiteSafety_Orange': {'scale_factor': 0.254278, 'category': 'Shoe'},
'ASICS_GELBlur33_20_GS_Flash_YellowHot_PunchSilver': {'scale_factor': 0.25366999999999995, 'category': 'Shoe'},
'ASICS_GELChallenger_9_Royal_BlueWhiteBlack': {'scale_factor': 0.298461, 'category': 'Shoe'},
'ASICS_GELDirt_Dog_4_SunFlameBlack': {'scale_factor': 0.284277, 'category': 'Shoe'},
'ASICS_GELLinksmaster_WhiteCoffeeSand': {'scale_factor': 0.299169, 'category': 'Shoe'},
'ASICS_GELLinksmaster_WhiteRasberryGunmetal': {'scale_factor': 0.27285000000000004, 'category': 'Shoe'},
'ASICS_GELLinksmaster_WhiteSilverCarolina_Blue': {'scale_factor': 0.272868, 'category': 'Shoe'},
'ASICS_GELResolution_5_Flash_YellowBlackSilver': {'scale_factor': 0.2993, 'category': 'Shoe'},
'ASICS_GELTour_Lyte_WhiteOrchidSilver': {'scale_factor': 0.26630600000000004, 'category': 'Shoe'},
'ASICS_HyperRocketgirl_SP_5_WhiteMalibu_BlueBlack': {'scale_factor': 0.24914599999999998, 'category': 'Shoe'},
'ASSORTED_VEGETABLE_SET': {'scale_factor': 0.230192, 'category': 'Toys'},
'Adrenaline_GTS_13_Color_DrkDenimWhtBachlorBttnSlvr_Size_50_yfK40TNjq0V': {'scale_factor': 0.288056, 'category': 'Shoe'},
'Adrenaline_GTS_13_Color_WhtObsdianBlckOlmpcSlvr_Size_70': {'scale_factor': 0.30678300000000003, 'category': 'Shoe'},
'Air_Hogs_Wind_Flyers_Set_Airplane_Red': {'scale_factor': 0.272032, 'category': 'None'},
'AllergenFree_JarroDophilus': {'scale_factor': 0.095997, 'category': 'Bottles and Cans and Cups'},
'Android_Figure_Chrome': {'scale_factor': 0.081451, 'category': 'Consumer Goods'},
'Android_Figure_Orange': {'scale_factor': 0.080687, 'category': 'Consumer Goods'},
'Android_Figure_Panda': {'scale_factor': 0.075739, 'category': 'Consumer Goods'},
'Android_Lego': {'scale_factor': 0.106349, 'category': 'Legos'},
'Animal_Crossing_New_Leaf_Nintendo_3DS_Game': {'scale_factor': 0.13718000000000002, 'category': 'Media Cases'},
'Animal_Planet_Foam_2Headed_Dragon': {'scale_factor': 0.40190299999999995, 'category': 'Toys'},
'Apples_to_Apples_Kids_Edition': {'scale_factor': 0.269371, 'category': 'Consumer Goods'},
'Arm_Hammer_Diaper_Pail_Refills_12_Pack_MFWkmoweejt': {'scale_factor': 0.169219, 'category': 'Consumer Goods'},
'Aroma_Stainless_Steel_Milk_Frother_2_Cup': {'scale_factor': 0.157677, 'category': 'Consumer Goods'},
'Asus_80211ac_DualBand_Gigabit_Wireless_Router_RTAC68R': {'scale_factor': 0.318751, 'category': 'None'},
'Asus_M5A78LMUSB3_Motherboard_Micro_ATX_Socket_AM3': {'scale_factor': 0.276686, 'category': 'None'},
'Asus_M5A99FX_PRO_R20_Motherboard_ATX_Socket_AM3': {'scale_factor': 0.334631, 'category': 'None'},
'Asus_Sabertooth_990FX_20_Motherboard_ATX_Socket_AM3': {'scale_factor': 0.350201, 'category': 'None'},
'Asus_Sabertooth_Z97_MARK_1_Motherboard_ATX_LGA1150_Socket': {'scale_factor': 0.350557, 'category': 'None'},
'Asus_X99Deluxe_Motherboard_ATX_LGA2011v3_Socket': {'scale_factor': 0.350274, 'category': 'None'},
'Asus_Z87PRO_Motherboard_ATX_LGA1150_Socket': {'scale_factor': 0.33416500000000005, 'category': 'None'},
'Asus_Z97AR_LGA_1150_Intel_ATX_Motherboard': {'scale_factor': 0.33413499999999996, 'category': 'None'},
'Asus_Z97IPLUS_Motherboard_Mini_ITX_LGA1150_Socket': {'scale_factor': 0.231536, 'category': 'None'},
'Avengers_Gamma_Green_Smash_Fists': {'scale_factor': 0.360015, 'category': 'Toys'},
'Avengers_Thor_PLlrpYniaeB': {'scale_factor': 0.28297300000000003, 'category': 'Action Figures'},
'Azure_Snake_Tieks_Leather_Snake_Print_Ballet_Flats': {'scale_factor': 0.242954, 'category': 'Shoe'},
'BABY_CAR': {'scale_factor': 0.096854, 'category': 'Toys'},
'BAGEL_WITH_CHEESE': {'scale_factor': 0.133645, 'category': 'Toys'},
'BAKING_UTENSILS': {'scale_factor': 0.32602400000000004, 'category': 'Toys'},
'BALANCING_CACTUS': {'scale_factor': 0.263536, 'category': 'Toys'},
'BATHROOM_CLASSIC': {'scale_factor': 0.185214, 'category': 'Toys'},
'BATHROOM_FURNITURE_SET_1': {'scale_factor': 0.210252, 'category': 'Toys'},
'BEDROOM_CLASSIC': {'scale_factor': 0.314955, 'category': 'Toys'},
'BEDROOM_CLASSIC_Gi22DjScTVS': {'scale_factor': 0.343402, 'category': 'Toys'},
'BEDROOM_NEO': {'scale_factor': 0.262714, 'category': 'Toys'},
'BIA_Cordon_Bleu_White_Porcelain_Utensil_Holder_900028': {'scale_factor': 0.175195, 'category': 'None'},
'BIA_Porcelain_Ramekin_With_Glazed_Rim_35_45_oz_cup': {'scale_factor': 0.08867900000000001, 'category': 'None'},
'BIRD_RATTLE': {'scale_factor': 0.11119000000000001, 'category': 'Toys'},
'BRAILLE_ALPHABET_AZ': {'scale_factor': 0.333027, 'category': 'Toys'},
'BREAKFAST_MENU': {'scale_factor': 0.25312999999999997, 'category': 'Toys'},
'BUILD_A_ROBOT': {'scale_factor': 0.292531, 'category': 'Toys'},
'BUILD_A_ZOO': {'scale_factor': 0.218314, 'category': 'Toys'},
'BUNNY_RACER': {'scale_factor': 0.11154800000000001, 'category': 'Toys'},
'BUNNY_RATTLE': {'scale_factor': 0.11466300000000001, 'category': 'Toys'},
'Baby_Elements_Stacking_Cups': {'scale_factor': 0.346337, 'category': 'None'},
'Balderdash_Game': {'scale_factor': 0.268966, 'category': 'Board Games'},
'Beetle_Adventure_Racing_Nintendo_64': {'scale_factor': 0.116505, 'category': 'Consumer Goods'},
'Beta_Glucan': {'scale_factor': 0.09761600000000001, 'category': 'Bottles and Cans and Cups'},
'Beyonc_Life_is_But_a_Dream_DVD': {'scale_factor': 0.188517, 'category': 'Consumer Goods'},
'Bifidus_Balance_FOS': {'scale_factor': 0.096467, 'category': 'Bottles and Cans and Cups'},
'Big_Dot_Aqua_Pencil_Case': {'scale_factor': 0.208131, 'category': 'Bag'},
'Big_Dot_Pink_Pencil_Case': {'scale_factor': 0.21375, 'category': 'Bag'},
'Big_O_Sponges_Assorted_Cellulose_12_pack': {'scale_factor': 0.12575399999999998, 'category': 'Consumer Goods'},
'BlackBlack_Nintendo_3DSXL': {'scale_factor': 0.15554, 'category': 'None'},
'Black_Decker_CM2035B_12Cup_Thermal_Coffeemaker': {'scale_factor': 0.336937, 'category': 'None'},
'Black_Decker_Stainless_Steel_Toaster_4_Slice': {'scale_factor': 0.318299, 'category': 'None'},
'Black_Elderberry_Syrup_54_oz_Gaia_Herbs': {'scale_factor': 0.145106, 'category': 'Consumer Goods'},
'Black_Forest_Fruit_Snacks_28_Pack_Grape': {'scale_factor': 0.257416, 'category': 'Consumer Goods'},
'Black_Forest_Fruit_Snacks_Juicy_Filled_Centers_10_pouches_9_oz_total': {'scale_factor': 0.212087, 'category': 'Consumer Goods'},
'Black_and_Decker_PBJ2000_FusionBlade_Blender_Jars': {'scale_factor': 0.299714, 'category': 'None'},
'Black_and_Decker_TR3500SD_2Slice_Toaster': {'scale_factor': 0.295277, 'category': 'None'},
'Blackcurrant_Lutein': {'scale_factor': 0.097312, 'category': 'Bottles and Cans and Cups'},
'BlueBlack_Nintendo_3DSXL': {'scale_factor': 0.156599, 'category': 'None'},
'Blue_Jasmine_Includes_Digital_Copy_UltraViolet_DVD': {'scale_factor': 0.192975, 'category': 'Media Cases'},
'Borage_GLA240Gamma_Tocopherol': {'scale_factor': 0.11094899999999999, 'category': 'Bottles and Cans and Cups'},
'Bradshaw_International_11642_7_Qt_MP_Plastic_Bowl': {'scale_factor': 0.28509, 'category': 'None'},
'Breyer_Horse_Of_The_Year_2015': {'scale_factor': 0.23114099999999999, 'category': 'None'},
'Brisk_Iced_Tea_Lemon_12_12_fl_oz_355_ml_cans_144_fl_oz_426_lt': {'scale_factor': 0.40285, 'category': 'Consumer Goods'},
'Brother_Ink_Cartridge_Magenta_LC75M': {'scale_factor': 0.14715899999999998, 'category': 'Consumer Goods'},
'Brother_LC_1053PKS_Ink_Cartridge_CyanMagentaYellow_1pack': {'scale_factor': 0.14492, 'category': 'Consumer Goods'},
'Brother_Printing_Cartridge_PC501': {'scale_factor': 0.25587499999999996, 'category': 'Consumer Goods'},
'CARSII': {'scale_factor': 0.122813, 'category': 'Toys'},
'CAR_CARRIER_TRAIN': {'scale_factor': 0.22295399999999999, 'category': 'Toys'},
'CASTLE_BLOCKS': {'scale_factor': 0.302403, 'category': 'Toys'},
'CHICKEN_NESTING': {'scale_factor': 0.19498900000000002, 'category': 'Toys'},
'CHICKEN_RACER': {'scale_factor': 0.099457, 'category': 'Toys'},
'CHILDRENS_ROOM_NEO': {'scale_factor': 0.2017, 'category': 'Toys'},
'CHILDREN_BEDROOM_CLASSIC': {'scale_factor': 0.224682, 'category': 'Toys'},
'CITY_TAXI_POLICE_CAR': {'scale_factor': 0.126338, 'category': 'Toys'},
'CLIMACOOL_BOAT_BREEZE_IE6CyqSaDwN': {'scale_factor': 0.293272, 'category': 'Shoe'},
'COAST_GUARD_BOAT': {'scale_factor': 0.116176, 'category': 'Toys'},
'CONE_SORTING': {'scale_factor': 0.269663, 'category': 'Toys'},
'CONE_SORTING_kg5fbARBwts': {'scale_factor': 0.390906, 'category': 'Toys'},
'CREATIVE_BLOCKS_35_MM': {'scale_factor': 0.281776, 'category': 'Toys'},
'California_Navy_Tieks_Italian_Leather_Ballet_Flats': {'scale_factor': 0.24167100000000002, 'category': 'Shoe'},
'Calphalon_Kitchen_Essentials_12_Cast_Iron_Fry_Pan_Black': {'scale_factor': 0.323628, 'category': 'None'},
'Canon_225226_Ink_Cartridges_BlackColor_Cyan_Magenta_Yellow_6_count': {'scale_factor': 0.169147, 'category': 'Consumer Goods'},
'Canon_Ink_Cartridge_Green_6': {'scale_factor': 0.146077, 'category': 'Consumer Goods'},
'Canon_Pixma_Chromalife_100_Magenta_8': {'scale_factor': 0.11405399999999999, 'category': 'Consumer Goods'},
'Canon_Pixma_Ink_Cartridge_251_M': {'scale_factor': 0.111867, 'category': 'Consumer Goods'},
'Canon_Pixma_Ink_Cartridge_8': {'scale_factor': 0.11460300000000001, 'category': 'Consumer Goods'},
'Canon_Pixma_Ink_Cartridge_8_Green': {'scale_factor': 0.114856, 'category': 'Consumer Goods'},
'Canon_Pixma_Ink_Cartridge_8_Red': {'scale_factor': 0.11458399999999999, 'category': 'Consumer Goods'},
'Canon_Pixma_Ink_Cartridge_Cyan_251': {'scale_factor': 0.111039, 'category': 'Consumer Goods'},
'Cascadia_8_Color_AquariusHibscsBearingSeaBlk_Size_50': {'scale_factor': 0.254417, 'category': 'Shoe'},
'Central_Garden_Flower_Pot_Goo_425': {'scale_factor': 0.115311, 'category': 'Consumer Goods'},
'Chef_Style_Round_Cake_Pan_9_inch_pan': {'scale_factor': 0.246, 'category': 'None'},
'Chefmate_8_Frypan': {'scale_factor': 0.35577499999999995, 'category': 'None'},
'Chelsea_BlkHeelPMP_DwxLtZNxLZZ': {'scale_factor': 0.24076000000000003, 'category': 'Shoe'},
'Chelsea_lo_fl_rdheel_nQ0LPNF1oMw': {'scale_factor': 0.256529, 'category': 'Shoe'},
'Chelsea_lo_fl_rdheel_zAQrnhlEfw8': {'scale_factor': 0.256361, 'category': 'Shoe'},
'Circo_Fish_Toothbrush_Holder_14995988': {'scale_factor': 0.154691, 'category': 'Consumer Goods'},
'ClimaCool_Aerate_2_W_Wide': {'scale_factor': 0.268432, 'category': 'Shoe'},
'Clorox_Premium_Choice_Gloves_SM_1_pair': {'scale_factor': 0.326326, 'category': 'None'},
'Closetmaid_Premium_Fabric_Cube_Red': {'scale_factor': 0.32167, 'category': 'None'},
'Clue_Board_Game_Classic_Edition': {'scale_factor': 0.496927, 'category': 'Board Games'},
'CoQ10': {'scale_factor': 0.084399, 'category': 'Bottles and Cans and Cups'},
'CoQ10_BjTLbuRVt1t': {'scale_factor': 0.083729, 'category': 'Bottles and Cans and Cups'},
'CoQ10_wSSVoxVppVD': {'scale_factor': 0.08402000000000001, 'category': 'Bottles and Cans and Cups'},
'Cole_Hardware_Antislip_Surfacing_Material_White': {'scale_factor': 0.154879, 'category': 'None'},
'Cole_Hardware_Antislip_Surfacing_White_2_x_60': {'scale_factor': 0.157827, 'category': 'None'},
'Cole_Hardware_Bowl_Scirocco_YellowBlue': {'scale_factor': 0.114898, 'category': 'None'},
'Cole_Hardware_Butter_Dish_Square_Red': {'scale_factor': 0.115217, 'category': 'Consumer Goods'},
'Cole_Hardware_Deep_Bowl_Good_Earth_1075': {'scale_factor': 0.284281, 'category': 'None'},
'Cole_Hardware_Dishtowel_Blue': {'scale_factor': 0.23432399999999998, 'category': 'None'},
'Cole_Hardware_Dishtowel_BlueWhite': {'scale_factor': 0.235778, 'category': 'None'},
'Cole_Hardware_Dishtowel_Multicolors': {'scale_factor': 0.24363599999999996, 'category': 'None'},
'Cole_Hardware_Dishtowel_Red': {'scale_factor': 0.236506, 'category': 'None'},
'Cole_Hardware_Dishtowel_Stripe': {'scale_factor': 0.234402, 'category': 'None'},
'Cole_Hardware_Electric_Pot_Assortment_55': {'scale_factor': 0.142984, 'category': 'None'},
'Cole_Hardware_Electric_Pot_Cabana_55': {'scale_factor': 0.141934, 'category': 'None'},
'Cole_Hardware_Flower_Pot_1025': {'scale_factor': 0.249862, 'category': 'None'},
'Cole_Hardware_Hammer_Black': {'scale_factor': 0.291707, 'category': 'None'},
'Cole_Hardware_Mini_Honey_Dipper': {'scale_factor': 0.11050700000000001, 'category': 'Consumer Goods'},
'Cole_Hardware_Mug_Classic_Blue': {'scale_factor': 0.165662, 'category': 'None'},
'Cole_Hardware_Orchid_Pot_85': {'scale_factor': 0.21143299999999998, 'category': 'None'},
'Cole_Hardware_Plant_Saucer_Brown_125': {'scale_factor': 0.310668, 'category': 'None'},
'Cole_Hardware_Plant_Saucer_Glazed_9': {'scale_factor': 0.228736, 'category': 'None'},
'Cole_Hardware_Saucer_Electric': {'scale_factor': 0.124293, 'category': 'None'},
'Cole_Hardware_Saucer_Glazed_6': {'scale_factor': 0.15989799999999998, 'category': 'None'},
'Cole_Hardware_School_Bell_Solid_Brass_38': {'scale_factor': 0.15964899999999999, 'category': 'Consumer Goods'},
'Colton_Wntr_Chukka_y4jO0I8JQFW': {'scale_factor': 0.32694599999999996, 'category': 'Shoe'},
'Connect_4_Launchers': {'scale_factor': 0.275444, 'category': 'Board Games'},
'Cootie_Game': {'scale_factor': 0.341183, 'category': 'Consumer Goods'},
'Cootie_Game_tDhURNbfU5J': {'scale_factor': 0.269659, 'category': 'Consumer Goods'},
'Copperhead_Snake_Tieks_Brown_Snake_Print_Ballet_Flats': {'scale_factor': 0.24607, 'category': 'Shoe'},
'Corningware_CW_by_Corningware_3qt_Oblong_Casserole_Dish_Blue': {'scale_factor': 0.368499, 'category': 'None'},
'Court_Attitude': {'scale_factor': 0.290111, 'category': 'Shoe'},
'Craftsman_Grip_Screwdriver_Phillips_Cushion': {'scale_factor': 0.260432, 'category': 'None'},
'Crayola_Bonus_64_Crayons': {'scale_factor': 0.147247, 'category': 'None'},
'Crayola_Crayons_120_crayons': {'scale_factor': 0.23077799999999998, 'category': 'Consumer Goods'},
'Crayola_Crayons_24_count': {'scale_factor': 0.116595, 'category': 'Consumer Goods'},
'Crayola_Crayons_Washable_24_crayons': {'scale_factor': 0.11608500000000002, 'category': 'Consumer Goods'},
'Crayola_Model_Magic_Modeling_Material_Single_Packs_6_pack_05_oz_packs': {'scale_factor': 0.217536, 'category': 'Consumer Goods'},
'Crayola_Model_Magic_Modeling_Material_White_3_oz': {'scale_factor': 0.217501, 'category': 'Consumer Goods'},
'Crayola_Washable_Fingerpaint_Red_Blue_Yellow_3_count_8_fl_oz_bottes_each': {'scale_factor': 0.177037, 'category': 'None'},
'Crayola_Washable_Sidewalk_Chalk_16_pack': {'scale_factor': 0.14836699999999997, 'category': 'Consumer Goods'},
'Crayola_Washable_Sidewalk_Chalk_16_pack_wDZECiw7J6s': {'scale_factor': 0.148148, 'category': 'Consumer Goods'},
'Crazy_8': {'scale_factor': 0.305855, 'category': 'Shoe'},
'Crazy_Shadow_2': {'scale_factor': 0.296205, 'category': 'Shoe'},
'Crazy_Shadow_2_oW4Jd10HFFr': {'scale_factor': 0.296153, 'category': 'Shoe'},
'Cream_Tieks_Italian_Leather_Ballet_Flats': {'scale_factor': 0.245575, 'category': 'Shoe'},
'Creatine_Monohydrate': {'scale_factor': 0.183814, 'category': 'Bottles and Cans and Cups'},
'Crosley_Alarm_Clock_Vintage_Metal': {'scale_factor': 0.162287, 'category': 'Consumer Goods'},
'Crunch_Girl_Scouts_Candy_Bars_Peanut_Butter_Creme_78_oz_box': {'scale_factor': 0.163966, 'category': 'Consumer Goods'},
'Curver_Storage_Bin_Black_Small': {'scale_factor': 0.285864, 'category': 'None'},
'DANCING_ALLIGATOR': {'scale_factor': 0.294873, 'category': 'Toys'},
'DANCING_ALLIGATOR_zoWBjc0jbTs': {'scale_factor': 0.322298, 'category': 'Toys'},
'DIM_CDG': {'scale_factor': 0.08427199999999999, 'category': 'Bottles and Cans and Cups'},
'DINING_ROOM_CLASSIC': {'scale_factor': 0.234514, 'category': 'Toys'},
'DINING_ROOM_CLASSIC_UJuxQ0hv5XU': {'scale_factor': 0.227929, 'category': 'Toys'},
'DINNING_ROOM_FURNITURE_SET_1': {'scale_factor': 0.190768, 'category': 'Toys'},
'DOLL_FAMILY': {'scale_factor': 0.231017, 'category': 'Toys'},
'DPC_Handmade_Hat_Brown': {'scale_factor': 0.35390299999999997, 'category': 'Hat'},
'DPC_Thinsulate_Isolate_Gloves_Brown': {'scale_factor': 0.301094, 'category': 'None'},
'DPC_tropical_Trends_Hat': {'scale_factor': 0.403856, 'category': 'Hat'},
'DRAGON_W': {'scale_factor': 0.262775, 'category': 'Shoe'},
'D_ROSE_45': {'scale_factor': 0.29872, 'category': 'Shoe'},
'D_ROSE_773_II_Kqclsph05pE': {'scale_factor': 0.297332, 'category': 'Shoe'},
'D_ROSE_773_II_hvInJwJ5HUD': {'scale_factor': 0.297851, 'category': 'Shoe'},
'D_ROSE_ENGLEWOOD_II': {'scale_factor': 0.307426, 'category': 'Shoe'},
'Dell_Ink_Cartridge': {'scale_factor': 0.139935, 'category': 'Consumer Goods'},
'Dell_Ink_Cartridge_Yellow_31': {'scale_factor': 0.140117, 'category': 'Consumer Goods'},
'Dell_Series_9_Color_Ink_Cartridge_MK993_High_Yield': {'scale_factor': 0.134106, 'category': 'Consumer Goods'},
'Design_Ideas_Drawer_Store_Organizer': {'scale_factor': 0.307115, 'category': 'None'},
'Deskstar_Desk_Top_Hard_Drive_1_TB': {'scale_factor': 0.199376, 'category': 'Consumer Goods'},
'Diamond_Visions_Scissors_Red': {'scale_factor': 0.20956899999999998, 'category': 'Consumer Goods'},
'Diet_Pepsi_Soda_Cola12_Pack_12_oz_Cans': {'scale_factor': 0.406395, 'category': 'Consumer Goods'},
'Digital_Camo_Double_Decker_Lunch_Bag': {'scale_factor': 0.260741, 'category': 'Bag'},
'Dino_3': {'scale_factor': 0.288729, 'category': 'Action Figures'},
'Dino_4': {'scale_factor': 0.13681500000000002, 'category': 'Action Figures'},
'Dino_5': {'scale_factor': 0.21971000000000002, 'category': 'Action Figures'},
'Dixie_10_ounce_Bowls_35_ct': {'scale_factor': 0.152169, 'category': 'None'},
'Dog': {'scale_factor': 0.231991, 'category': 'None'},
'Don_Franciscos_Gourmet_Coffee_Medium_Decaf_100_Colombian_12_oz_340_g': {'scale_factor': 0.141041, 'category': 'Bottles and Cans and Cups'},
'Down_To_Earth_Ceramic_Orchid_Pot_Asst_Blue': {'scale_factor': 0.13273400000000002, 'category': 'None'},
'Down_To_Earth_Orchid_Pot_Ceramic_Lime': {'scale_factor': 0.140098, 'category': 'Consumer Goods'},
'Down_To_Earth_Orchid_Pot_Ceramic_Red': {'scale_factor': 0.131359, 'category': 'Consumer Goods'},
'ENFR_MID_ENFORCER': {'scale_factor': 0.293078, 'category': 'Shoe'},
'Eat_to_Live_The_Amazing_NutrientRich_Program_for_Fast_and_Sustained_Weight_Loss_Revised_Edition_Book': {'scale_factor': 0.210368, 'category': 'Consumer Goods'},
'Ecoforms_Cup_B4_SAN': {'scale_factor': 0.09998599999999999, 'category': 'None'},
'Ecoforms_Garden_Pot_GP16ATurquois': {'scale_factor': 0.16426800000000003, 'category': 'None'},
'Ecoforms_Plant_Bowl_Atlas_Low': {'scale_factor': 0.32199900000000004, 'category': 'None'},
'Ecoforms_Plant_Bowl_Turquoise_7': {'scale_factor': 0.181971, 'category': 'None'},
'Ecoforms_Plant_Container_12_Pot_Nova': {'scale_factor': 0.297374, 'category': 'None'},
'Ecoforms_Plant_Container_B4_Har': {'scale_factor': 0.100927, 'category': 'None'},
'Ecoforms_Plant_Container_FB6_Tur': {'scale_factor': 0.16166000000000003, 'category': 'None'},
'Ecoforms_Plant_Container_GP16AMOCHA': {'scale_factor': 0.162711, 'category': 'None'},
'Ecoforms_Plant_Container_GP16A_Coral': {'scale_factor': 0.164742, 'category': 'None'},
'Ecoforms_Plant_Container_QP6CORAL': {'scale_factor': 0.19124999999999998, 'category': 'None'},
'Ecoforms_Plant_Container_QP6HARVEST': {'scale_factor': 0.190191, 'category': 'None'},
'Ecoforms_Plant_Container_QP_Harvest': {'scale_factor': 0.08998899999999999, 'category': 'None'},
'Ecoforms_Plant_Container_QP_Turquoise': {'scale_factor': 0.089812, 'category': 'None'},
'Ecoforms_Plant_Container_Quadra_Sand_QP6': {'scale_factor': 0.190355, 'category': 'None'},
'Ecoforms_Plant_Container_Quadra_Turquoise_QP12': {'scale_factor': 0.282694, 'category': 'None'},
'Ecoforms_Plant_Container_S14Turquoise': {'scale_factor': 0.147529, 'category': 'None'},
'Ecoforms_Plant_Container_S24NATURAL': {'scale_factor': 0.241269, 'category': 'None'},
'Ecoforms_Plant_Container_S24Turquoise': {'scale_factor': 0.241894, 'category': 'None'},
'Ecoforms_Plant_Container_SB9Turquoise': {'scale_factor': 0.29974500000000004, 'category': 'None'},
'Ecoforms_Plant_Container_URN_NAT': {'scale_factor': 0.15993200000000002, 'category': 'Consumer Goods'},
'Ecoforms_Plant_Container_URN_SAN': {'scale_factor': 0.159359, 'category': 'Consumer Goods'},
'Ecoforms_Plant_Container_Urn_55_Avocado': {'scale_factor': 0.159915, 'category': 'None'},
'Ecoforms_Plant_Container_Urn_55_Mocha': {'scale_factor': 0.159915, 'category': 'None'},
'Ecoforms_Plant_Plate_S11Turquoise': {'scale_factor': 0.118147, 'category': 'None'},
'Ecoforms_Plant_Pot_GP9AAvocado': {'scale_factor': 0.094238, 'category': 'None'},
'Ecoforms_Plant_Pot_GP9_SAND': {'scale_factor': 0.094213, 'category': 'None'},
'Ecoforms_Plant_Saucer_S14MOCHA': {'scale_factor': 0.147928, 'category': 'None'},
'Ecoforms_Plant_Saucer_S14NATURAL': {'scale_factor': 0.14758700000000002, 'category': 'None'},
'Ecoforms_Plant_Saucer_S17MOCHA': {'scale_factor': 0.17692, 'category': 'None'},
'Ecoforms_Plant_Saucer_S20MOCHA': {'scale_factor': 0.206587, 'category': 'None'},
'Ecoforms_Plant_Saucer_SQ1HARVEST': {'scale_factor': 0.086505, 'category': 'None'},
'Ecoforms_Plant_Saucer_SQ8COR': {'scale_factor': 0.180842, 'category': 'None'},
'Ecoforms_Planter_Bowl_Cole_Hardware': {'scale_factor': 0.18074400000000002, 'category': 'None'},
'Ecoforms_Planter_Pot_GP12AAvocado': {'scale_factor': 0.118599, 'category': 'None'},
'Ecoforms_Planter_Pot_QP6Ebony': {'scale_factor': 0.189654, 'category': 'None'},
'Ecoforms_Plate_S20Avocado': {'scale_factor': 0.207011, 'category': 'None'},
'Ecoforms_Pot_Nova_6_Turquoise': {'scale_factor': 0.18079499999999998, 'category': 'None'},
'Ecoforms_Quadra_Saucer_SQ1_Avocado': {'scale_factor': 0.087083, 'category': 'None'},
'Ecoforms_Saucer_SQ3_Turquoise': {'scale_factor': 0.26184, 'category': 'None'},
'Elephant': {'scale_factor': 0.270548, 'category': 'None'},
'Embark_Lunch_Cooler_Blue': {'scale_factor': 0.295574, 'category': 'None'},
'Envision_Home_Dish_Drying_Mat_Red_6_x_18': {'scale_factor': 0.40988199999999997, 'category': 'None'},
'Epson_273XL_Ink_Cartridge_Magenta': {'scale_factor': 0.160327, 'category': 'Consumer Goods'},
'Epson_DURABrite_Ultra_786_Black_Ink_Cartridge_T786120S': {'scale_factor': 0.181693, 'category': 'Consumer Goods'},
'Epson_Ink_Cartridge_126_Yellow': {'scale_factor': 0.11465800000000001, 'category': 'Consumer Goods'},
'Epson_Ink_Cartridge_Black_200': {'scale_factor': 0.11465800000000001, 'category': 'Consumer Goods'},
'Epson_LabelWorks_LC4WBN9_Tape_reel_labels_047_x_295_Roll_Black_on_White': {'scale_factor': 0.123004, 'category': 'Consumer Goods'},
'Epson_LabelWorks_LC5WBN9_Tape_reel_labels_071_x_295_Roll_Black_on_White': {'scale_factor': 0.123356, 'category': 'Consumer Goods'},
'Epson_T5803_Ink_Cartridge_Magenta_1pack': {'scale_factor': 0.102123, 'category': 'Consumer Goods'},
'Epson_UltraChrome_T0543_Ink_Cartridge_Magenta_1pack': {'scale_factor': 0.115055, 'category': 'Consumer Goods'},
'Epson_UltraChrome_T0548_Ink_Cartridge_Matte_Black_1pack': {'scale_factor': 0.11535699999999999, 'category': 'Consumer Goods'},
'F10_TRX_FG_ssscuo9tGxb': {'scale_factor': 0.282471, 'category': 'Shoe'},
'F10_TRX_TF_rH7tmKCdUJq': {'scale_factor': 0.289659, 'category': 'Shoe'},
'F5_TRX_FG': {'scale_factor': 0.28303, 'category': 'Shoe'},
'FAIRY_TALE_BLOCKS': {'scale_factor': 0.26503899999999997, 'category': 'Toys'},
'FARM_ANIMAL': {'scale_factor': 0.176346, 'category': 'Toys'},
'FARM_ANIMAL_9GyfdcPyESK': {'scale_factor': 0.182681, 'category': 'Toys'},
'FIRE_ENGINE': {'scale_factor': 0.137119, 'category': 'Toys'},
'FIRE_TRUCK': {'scale_factor': 0.124043, 'category': 'Toys'},
'FISHING_GAME': {'scale_factor': 0.393482, 'category': 'Toys'},
'FOOD_BEVERAGE_SET': {'scale_factor': 0.267115, 'category': 'Toys'},
'FRACTION_FUN_n4h4qte23QR': {'scale_factor': 0.189145, 'category': 'Toys'},
'FRUIT_VEGGIE_DOMINO_GRADIENT': {'scale_factor': 0.347707, 'category': 'Toys'},
'FRUIT_VEGGIE_MEMO_GRADIENT': {'scale_factor': 0.268224, 'category': 'Toys'},
'FYW_ALTERNATION': {'scale_factor': 0.306532, 'category': 'Shoe'},
'FYW_DIVISION': {'scale_factor': 0.306284, 'category': 'Shoe'},
'FemDophilus': {'scale_factor': 0.114582, 'category': 'Consumer Goods'},
'Final_Fantasy_XIV_A_Realm_Reborn_60Day_Subscription': {'scale_factor': 0.190407, 'category': 'Media Cases'},
'Firefly_Clue_Board_Game': {'scale_factor': 0.404104, 'category': 'Consumer Goods'},
'FisherPrice_Make_A_Match_Game_Thomas_Friends': {'scale_factor': 0.267802, 'category': 'Consumer Goods'},
'Fisher_price_Classic_Toys_Buzzy_Bee': {'scale_factor': 0.205903, 'category': 'None'},
'Focus_8643_Lime_Squeezer_10x35x188_Enamelled_Aluminum_Light': {'scale_factor': 0.33557800000000004, 'category': 'None'},
'Folic_Acid': {'scale_factor': 0.083858, 'category': 'Bottles and Cans and Cups'},
'Footed_Bowl_Sand': {'scale_factor': 0.161543, 'category': 'Consumer Goods'},
'Fresca_Peach_Citrus_Sparkling_Flavored_Soda_12_PK': {'scale_factor': 0.40788599999999997, 'category': 'Consumer Goods'},
'Frozen_Olafs_In_Trouble_PopOMatic_Game': {'scale_factor': 0.27336, 'category': 'Board Games'},
'Frozen_Olafs_In_Trouble_PopOMatic_Game_OEu83W9T8pD': {'scale_factor': 0.26062399999999997, 'category': 'Board Games'},
'Frozen_Scrabble_Jr': {'scale_factor': 0.271804, 'category': 'Board Games'},
'Fruity_Friends': {'scale_factor': 0.172669, 'category': 'Consumer Goods'},
'Fujifilm_instax_SHARE_SP1_10_photos': {'scale_factor': 0.12373300000000001, 'category': 'None'},
'Full_Circle_Happy_Scraps_Out_Collector_Gray': {'scale_factor': 0.213046, 'category': 'None'},
'GARDEN_SWING': {'scale_factor': 0.16647, 'category': 'Toys'},
'GEARS_PUZZLES_STANDARD_gcYxhNHhKlI': {'scale_factor': 0.311234, 'category': 'Toys'},
'GEOMETRIC_PEG_BOARD': {'scale_factor': 0.174989, 'category': 'Toys'},
'GEOMETRIC_SORTING_BOARD': {'scale_factor': 0.174722, 'category': 'Toys'},
'GEOMETRIC_SORTING_BOARD_MNi4Rbuz9vj': {'scale_factor': 0.36226499999999995, 'category': 'Toys'},
'GIRLS_DECKHAND': {'scale_factor': 0.25479300000000005, 'category': 'Shoe'},
'GRANDFATHER_DOLL': {'scale_factor': 0.129042, 'category': 'Toys'},
'GRANDMOTHER': {'scale_factor': 0.12684800000000002, 'category': 'Toys'},
'Germanium_GE132': {'scale_factor': 0.077376, 'category': 'Bottles and Cans and Cups'},
'Ghost_6_Color_BlckWhtLavaSlvrCitrus_Size_80': {'scale_factor': 0.298198, 'category': 'Shoe'},
'Ghost_6_Color_MdngtDenmPomBrtePnkSlvBlk_Size_50': {'scale_factor': 0.284107, 'category': 'Shoe'},
'Ghost_6_GTX_Color_AnthBlckSlvrFernSulphSprng_Size_80': {'scale_factor': 0.29041799999999995, 'category': 'Shoe'},
'Gigabyte_GA78LMTUSB3_50_Motherboard_Micro_ATX_Socket_AM3': {'scale_factor': 0.271574, 'category': 'None'},
'Gigabyte_GA970AUD3P_10_Motherboard_ATX_Socket_AM3': {'scale_factor': 0.334386, 'category': 'None'},
'Gigabyte_GAZ97XSLI_10_motherboard_ATX_LGA1150_Socket_Z97': {'scale_factor': 0.334685, 'category': 'None'},
'Glycerin_11_Color_AqrsDrsdnBluBlkSlvShckOrng_Size_50': {'scale_factor': 0.28794600000000004, 'category': 'Shoe'},
'Glycerin_11_Color_BrllntBluSkydvrSlvrBlckWht_Size_80': {'scale_factor': 0.304977, 'category': 'Shoe'},
'GoPro_HERO3_Composite_Cable': {'scale_factor': 0.098623, 'category': 'None'},
'Google_Cardboard_Original_package': {'scale_factor': 0.214329, 'category': 'Consumer Goods'},
'Grand_Prix': {'scale_factor': 0.285006, 'category': 'Shoe'},
'Granimals_20_Wooden_ABC_Blocks_Wagon': {'scale_factor': 0.190035, 'category': 'None'},
'Granimals_20_Wooden_ABC_Blocks_Wagon_85VdSftGsLi': {'scale_factor': 0.031189, 'category': 'None'},
'Granimals_20_Wooden_ABC_Blocks_Wagon_g2TinmUGGHI': {'scale_factor': 0.191824, 'category': 'None'},
'Great_Dinos_Triceratops_Toy': {'scale_factor': 0.079184, 'category': 'None'},
'Great_Jones_Wingtip': {'scale_factor': 0.31214, 'category': 'Shoe'},
'Great_Jones_Wingtip_j5NV8GRnitM': {'scale_factor': 0.316897, 'category': 'Shoe'},
'Great_Jones_Wingtip_kAqSg6EgG0I': {'scale_factor': 0.312017, 'category': 'Shoe'},
'Great_Jones_Wingtip_wxH3dbtlvBC': {'scale_factor': 0.316946, 'category': 'Shoe'},
'Grreat_Choice_Dog_Double_Dish_Plastic_Blue': {'scale_factor': 0.338102, 'category': 'None'},
'Grreatv_Choice_Dog_Bowl_Gray_Bones_Plastic_20_fl_oz_total': {'scale_factor': 0.183525, 'category': 'None'},
'Guardians_of_the_Galaxy_Galactic_Battlers_Rocket_Raccoon_Figure': {'scale_factor': 0.101443, 'category': 'Action Figures'},
'HAMMER_BALL': {'scale_factor': 0.28392, 'category': 'Toys'},
'HAMMER_PEG': {'scale_factor': 0.252371, 'category': 'Toys'},
'HAPPY_ENGINE': {'scale_factor': 0.26964600000000005, 'category': 'Toys'},
'HELICOPTER': {'scale_factor': 0.173153, 'category': 'Toys'},
'HP_1800_Tablet_8GB_7': {'scale_factor': 0.19339, 'category': 'None'},
'HP_Card_Invitation_Kit': {'scale_factor': 0.19645200000000002, 'category': 'Consumer Goods'},
'Hasbro_Cranium_Performance_and_Acting_Game': {'scale_factor': 0.272031, 'category': 'Consumer Goods'},
'Hasbro_Dont_Wake_Daddy_Board_Game': {'scale_factor': 0.40583199999999997, 'category': 'Consumer Goods'},
'Hasbro_Dont_Wake_Daddy_Board_Game_NJnjGna4u1a': {'scale_factor': 0.500453, 'category': 'Consumer Goods'},
'Hasbro_Life_Board_Game': {'scale_factor': 0.404874, 'category': 'Consumer Goods'},
'Hasbro_Monopoly_Hotels_Game': {'scale_factor': 0.27975300000000003, 'category': 'Board Games'},
'Hasbro_Trivial_Pursuit_Family_Edition_Game': {'scale_factor': 0.271042, 'category': 'Board Games'},
'HeavyDuty_Flashlight': {'scale_factor': 0.229205, 'category': 'None'},
'Hefty_Waste_Basket_Decorative_Bronze_85_liter': {'scale_factor': 0.300217, 'category': 'None'},
'Hey_You_Pikachu_Nintendo_64': {'scale_factor': 0.116535, 'category': 'Consumer Goods'},
'Hilary': {'scale_factor': 0.23549899999999999, 'category': 'Shoe'},
'Home_Fashions_Washcloth_Linen': {'scale_factor': 0.17948799999999998, 'category': 'None'},
'Home_Fashions_Washcloth_Olive_Green': {'scale_factor': 0.176647, 'category': 'None'},
'Horse_Dreams_Pencil_Case': {'scale_factor': 0.21861999999999998, 'category': 'Bag'},
'Horses_in_Pink_Pencil_Case': {'scale_factor': 0.21417, 'category': 'Bag'},
'House_of_Cards_The_Complete_First_Season_4_Discs_DVD': {'scale_factor': 0.19093, 'category': 'Media Cases'},
'Hyaluronic_Acid': {'scale_factor': 0.097981, 'category': 'Bottles and Cans and Cups'},