gbaydin commited on
Commit
fe96f18
·
verified ·
1 Parent(s): 96f48cb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -1
README.md CHANGED
@@ -91,7 +91,7 @@ dataset = load_dataset("oxai4science/sdoml-lite", streaming=True)
91
  channels = ['hmi_m', 'aia_0131', 'aia_0171', 'aia_0193', 'aia_0211', 'aia_1600']
92
 
93
  def process(data):
94
- timestamp = datetime.strptime(data['__key__'], "%Y/%m/%d/%H%M")
95
  d = []
96
  for c in map(lambda x: x+'.npy', channels):
97
  d.append(np.array(data[c]) if c in data else np.zeros((512, 512)))
@@ -119,6 +119,44 @@ plot(timestamp, data)
119
  <img src="https://huggingface.co/datasets/oxai4science/sdoml-lite/resolve/main/assets/usage_example_1.png">
120
  </div>
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  ## Data Generation and Processing
123
 
124
  The SDOML-lite dataset is generated using the pipeline detailed in the [sdoml-lite GitHub repository](https://github.com/oxai4science/sdoml-lite). The download and processing scripts were run in July 2024 using distributed computing resources provided by Google Cloud for FDL-X Heliolab 2024, which is a public-private partnership AI research initiative with NASA, Google Cloud and Nvidia and other leading research organizations.
 
91
  channels = ['hmi_m', 'aia_0131', 'aia_0171', 'aia_0193', 'aia_0211', 'aia_1600']
92
 
93
  def process(data):
94
+ timestamp = data['__key__']
95
  d = []
96
  for c in map(lambda x: x+'.npy', channels):
97
  d.append(np.array(data[c]) if c in data else np.zeros((512, 512)))
 
119
  <img src="https://huggingface.co/datasets/oxai4science/sdoml-lite/resolve/main/assets/usage_example_1.png">
120
  </div>
121
 
122
+ Here is another example showing how to put together a minimal PyTorch dataset and dataloader to train with SDOML-lite.
123
+
124
+ ```python
125
+ import torch
126
+ from torch.utils.data import IterableDataset, DataLoader
127
+
128
+ # PyTorch dataset
129
+ class SDOMLlite(IterableDataset):
130
+ def __init__(self, dataset_iter):
131
+ self.dataset_iter = dataset_iter
132
+
133
+ def __iter__(self):
134
+ for sample in self.dataset_iter:
135
+ t, d = process(sample)
136
+ yield t, torch.tensor(d, dtype=torch.float32)
137
+
138
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
139
+ batch_size = 8
140
+
141
+ # Create DataLoader
142
+ dataset_iter = iter(dataset['train'])
143
+ torch_dataset = SDOMLlite(dataset_iter)
144
+ loader = DataLoader(torch_dataset, batch_size=batch_size)
145
+
146
+ # Training loop
147
+ num_epochs = 1
148
+ for epoch in range(num_epochs):
149
+ for batch in loader:
150
+ times = batch[0] # Timestamps
151
+ images = batch[1].to(device) # Images with shape (batch_size, 6, 512, 512)
152
+ print(f"Batch with shape: {images.shape}")
153
+ # ...
154
+ # training code
155
+ # ...
156
+ break
157
+ break
158
+ ```
159
+
160
  ## Data Generation and Processing
161
 
162
  The SDOML-lite dataset is generated using the pipeline detailed in the [sdoml-lite GitHub repository](https://github.com/oxai4science/sdoml-lite). The download and processing scripts were run in July 2024 using distributed computing resources provided by Google Cloud for FDL-X Heliolab 2024, which is a public-private partnership AI research initiative with NASA, Google Cloud and Nvidia and other leading research organizations.