Shu1L0n9 commited on
Commit
7ecc1e6
·
verified ·
1 Parent(s): 3cc42a2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -12
README.md CHANGED
@@ -60,27 +60,78 @@ All images are 96x96 pixels and are provided in PNG format.
60
 
61
  ## 🧼 Clean STL-10 Dataset, 🔧 How to Load?
62
 
63
- 🎉 We uploaded our cleaned STL-10 dataset to Hugging Face! You can easily load and use it with the 🤗 `datasets` library.
64
 
 
65
 
66
- ### 🔍 Load with 🤗 `datasets`(Recommended)
67
-
68
- You can load the dataset just like any other Hugging Face dataset:
69
 
70
  ```python
71
- from datasets import load_dataset
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- dataset = load_dataset("Shu1L0n9/CleanSTL10-WebDataset", split="train")
 
 
 
 
 
 
 
 
 
 
74
  ```
75
 
76
- ### 🚀 Use as WebDataset (e.g. for PyTorch streaming training)
 
77
 
78
- ```python
79
- import webdataset as wds
 
 
 
80
 
81
- train_ds = wds.WebDataset("https://huggingface.co/datasets/Shu1L0n9/CleanSTL10/resolve/main/cleanstl10-train.tar").decode("pil").to_tuple("jpg", "cls")
82
- test_ds = wds.WebDataset("https://huggingface.co/datasets/Shu1L0n9/CleanSTL10/resolve/main/cleanstl10-test.tar").decode("pil").to_tuple("jpg", "cls")
83
- unlabeled_ds = wds.WebDataset("https://huggingface.co/datasets/Shu1L0n9/CleanSTL10/resolve/main/cleanstl10-unlabeled.tar").decode("pil").to_tuple("jpg", "cls")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  ```
85
 
86
  ## Citation
 
60
 
61
  ## 🧼 Clean STL-10 Dataset, 🔧 How to Load?
62
 
63
+ 🎉 We uploaded our cleaned STL-10 dataset to Hugging Face! You can easily load and use it with the 🤗 `webdataset` library.
64
 
65
+ ---
66
 
67
+ ### 🔧 Load with WebDataset
 
 
68
 
69
  ```python
70
+ from huggingface_hub import hf_hub_url, HfFileSystem
71
+ import webdataset as wds
72
+
73
+ # Replace with your actual Hugging Face token
74
+ token = "your_huggingface_token_here"
75
+ fs = HfFileSystem(token=token)
76
+
77
+ repo_id = "Shu1L0n9/CleanSTL-10"
78
+ splits = {
79
+ 'train': '**/train-*.tar',
80
+ 'test': '**/test-*.tar',
81
+ 'unlabeled': '**/unlabeled-*.tar'
82
+ }
83
 
84
+ def load_split(split):
85
+ pattern = f"hf://datasets/{repo_id}/{splits[split]}"
86
+ files = [fs.resolve_path(p) for p in fs.glob(pattern)]
87
+ urls = [hf_hub_url(f.repo_id, f.path_in_repo, repo_type="dataset") for f in files]
88
+ pipe_url = f"pipe: curl -s -L -H 'Authorization:Bearer {token}' {'::'.join(urls)}"
89
+ return wds.WebDataset(pipe_url, shardshuffle=False).decode("pil")
90
+
91
+ # Load the splits
92
+ train_ds = load_split("train")
93
+ test_ds = load_split("test")
94
+ unlabeled_ds = load_split("unlabeled")
95
  ```
96
 
97
+ > ℹ️ Requires: `webdataset`, `huggingface_hub`, `fsspec`
98
+ > Install with:
99
 
100
+ ```bash
101
+ pip install webdataset huggingface_hub fsspec
102
+ ```
103
+
104
+ ---
105
 
106
+ ### 🔑 How to Get Your Hugging Face Token
107
+
108
+ To download from Hugging Face with authentication, you’ll need a **User Access Token**:
109
+
110
+ 1. Visit [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)
111
+ 2. Click **“New token”**
112
+ 3. Choose a name and select **“Read”** permission
113
+ 4. Click **“Generate”**, then copy the token
114
+ 5. Paste it into your script:
115
+
116
+ ```python
117
+ token = "your_token_here"
118
+ ```
119
+
120
+ > ⚠️ **Keep your token private** and avoid hardcoding it in shared scripts.
121
+
122
+ #### 💡 Optional: Use Environment Variable
123
+
124
+ To avoid hardcoding your token:
125
+
126
+ ```bash
127
+ export HF_TOKEN=your_token_here
128
+ ```
129
+
130
+ Then in your Python script:
131
+
132
+ ```python
133
+ import os
134
+ token = os.getenv("HF_TOKEN")
135
  ```
136
 
137
  ## Citation