Skip to content

Commit 8e80bed

Browse files
committed
hub sdk initial working
1 parent 44ee3c0 commit 8e80bed

25 files changed

Lines changed: 131 additions & 1562 deletions

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
./dask-worker-space/
2-
./cache
2+
./cache
3+
./data
4+
./dist
5+
./.pytest_cache
6+
./hub.egg-info

docker-compose.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
version: '2'
22

33
services:
4-
test-gpu:
5-
build:
6-
context: .
7-
volumes:
8-
- ./:/workspace/
9-
command: bash -c "
4+
test:
5+
build:
6+
context: .
7+
volumes:
8+
- ./:/workspace/
9+
command: bash -c "
1010
cd /workspace
1111
&& pytest ./"
12-
12+
13+
test-gpu:
14+
build:
15+
context: .
16+
volumes:
17+
- ./:/workspace/
18+
command: bash -c "
19+
cd /workspace
20+
&& pytest ./"
21+
1322
py3:
1423
build:
1524
context: .

examples/basic.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import hub
22
import numpy as np
3-
import sys, os, time, random, uuid, itertools, json, traceback, io
43

5-
# Create
6-
conn = hub.s3(
7-
'waymo-dataset-upload',
8-
aws_creds_filepath='.creds/aws.json'
9-
).connect()
4+
images = hub.tensor.from_array(np.zeros((4, 512, 512)))
5+
labels = hub.tensor.from_array(np.zeros((4, 512, 512)))
106

7+
# ds = hub.dataset.from_tensors({"images": images, "labels": labels})
8+
# ds.store("basic")
119

12-
x = conn.array_create(
13-
shape = (50000, 250, 250, 3),
14-
chunk=(4, 250, 250, 3),
15-
name= os.path.join('test', f'{int(time.time())}'),
16-
dtype='uint8',
17-
)
18-
19-
# Upload
20-
x[0] = np.ones((250, 250, 3), dtype='uint8')
21-
22-
# Download
23-
print(x[0].mean())
24-
print(x[1].mean())
25-
print(x.shape, x[1].shape)
10+
ds = hub.load("test/test3")
11+
print(ds["images"][0].compute())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def main():
4141
)
4242
print(images.shape, fine_labels.shape, coarse_labels.shape)
4343
Image.fromarray(images[1000].transpose(1, 2, 0)).save("./data/image.png")
44+
4445
images_t = tensor.from_array(images)
4546
fine_labels_t = tensor.from_array(fine_labels)
4647
coarse_labels_t = tensor.from_array(coarse_labels)
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ def load_mnist(dataset="training", digits=np.arange(10), path=".", size=60000):
4747
def main():
4848
parser = argparse.ArgumentParser()
4949
parser.add_argument(
50-
"dataset_path", type=str, help="Path to cifar dataset", default="./data/mnist",
50+
"-d",
51+
"--dataset_path",
52+
type=str,
53+
help="Path to cifar dataset",
54+
default="./data/mnist",
5155
)
5256
parser.add_argument(
53-
"output_name", type=str, help="Dataset output name", default="mnist",
57+
"-o", "--output_name", type=str, help="Dataset output name", default="mnist",
5458
)
5559
args = parser.parse_args()
5660
files = ["training", "testing"]
@@ -62,7 +66,7 @@ def main():
6266
# images = images.reshape((len(images), 3, 32, 32))
6367
labels = np.concatenate([np.array(d["labels"], dtype="int8") for d in dicts])
6468
print(images.shape, labels.shape)
65-
Image.fromarray(images[1000]).save("./data/image.png")
69+
# Image.fromarray(images[1000]).save("./data/image.png")
6670
images_t = tensor.from_array(images)
6771
labels_t = tensor.from_array(labels)
6872
# coarse_labels_t = tensor.from_array(coarse_labels)

0 commit comments

Comments
 (0)