Introduce unsqueeze for first dimension
Browse files
unsplash25k-image-embeddings.py
CHANGED
@@ -49,7 +49,7 @@ class Unsplash25kImageEmbeddingsDataset(datasets.GeneratorBasedBuilder):
|
|
49 |
{
|
50 |
"image_id": datasets.Value("string"),
|
51 |
# "image_embedding": datasets.Features({'x': datasets.Array2D(shape=(1, 512), dtype='float16')})
|
52 |
-
"image_embedding": datasets.Array2D(shape=(512), dtype='float16')
|
53 |
}
|
54 |
)
|
55 |
return datasets.DatasetInfo(
|
@@ -88,5 +88,5 @@ class Unsplash25kImageEmbeddingsDataset(datasets.GeneratorBasedBuilder):
|
|
88 |
for key in f.keys():
|
89 |
tensors[key] = f.get_tensor(key)
|
90 |
for num_id, image_id in enumerate(image_ids):
|
91 |
-
yield num_id, {"image_id": image_id, "image_embedding": tensors["embeddings"][num_id]}
|
92 |
|
|
|
49 |
{
|
50 |
"image_id": datasets.Value("string"),
|
51 |
# "image_embedding": datasets.Features({'x': datasets.Array2D(shape=(1, 512), dtype='float16')})
|
52 |
+
"image_embedding": datasets.Array2D(shape=(1, 512), dtype='float16')
|
53 |
}
|
54 |
)
|
55 |
return datasets.DatasetInfo(
|
|
|
88 |
for key in f.keys():
|
89 |
tensors[key] = f.get_tensor(key)
|
90 |
for num_id, image_id in enumerate(image_ids):
|
91 |
+
yield num_id, {"image_id": image_id, "image_embedding": tensors["embeddings"][num_id].unsqueeze(0)}
|
92 |
|