Datasets:

Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
aakashtripathi commited on
Commit
91ba11c
·
verified ·
1 Parent(s): 26cb791

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -0
README.md CHANGED
@@ -48,6 +48,39 @@ wsi_dataset = load_dataset("Lab-Rasool/TCGA", "wsi", split="train")
48
  molecular_dataset = load_dataset("Lab-Rasool/TCGA", "molecular", split="train")
49
  ```
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ## Dataset Creation
52
 
53
  #### Data Collection and Processing
 
48
  molecular_dataset = load_dataset("Lab-Rasool/TCGA", "molecular", split="train")
49
  ```
50
 
51
+ Example code for loading HF dataset into a PyTorch Dataloader.
52
+ **Note**: Some embeddings are stored as buffers due to their multi-dimensional shape.
53
+
54
+ ```python
55
+ from datasets import load_dataset
56
+ import os
57
+ from torch.utils.data import Dataset
58
+ import numpy as np
59
+
60
+ class CustomDataset(Dataset):
61
+ def __init__(self, hf_dataset):
62
+ self.hf_dataset = hf_dataset
63
+
64
+ def __len__(self):
65
+ return len(self.hf_dataset)
66
+
67
+ def __getitem__(self, idx):
68
+ hf_item = self.hf_dataset[idx]
69
+ embedding = np.frombuffer(hf_item["embedding"], dtype=np.float32)
70
+ embedding_shape = hf_item["embedding_shape"]
71
+ embedding = embedding.reshape(embedding_shape)
72
+ return embedding
73
+
74
+ if __name__ == "__main__":
75
+
76
+ clinical_dataset = load_dataset("Lab-Rasool/TCGA", "clinical", split="train")
77
+ wsi_dataset = load_dataset("Lab-Rasool/TCGA", "wsi", split="train")
78
+
79
+ for index, item in enumerate(clinical_dataset):
80
+ print(np.frombuffer(item.get("embedding"), dtype=np.float32).reshape(item.get("embedding_shape")).shape)
81
+ break
82
+ ```
83
+
84
  ## Dataset Creation
85
 
86
  #### Data Collection and Processing