docs(readme): document extraction script usage
#7
by
lucabaggi
- opened
README.md
CHANGED
@@ -146,4 +146,46 @@ ds = load_dataset("lucabaggi/animal-wildlife")
|
|
146 |
|
147 |
## How the data was generated
|
148 |
|
149 |
-
You can find the
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
## How the data was generated
|
148 |
|
149 |
+
You can find the source code for the extraction pipeline [here](./extract.py). Note: partly generated with Claude3 and Codestral 😎😅 Please feel free to open an issue in the discussion sction if you wish to improve the code.
|
150 |
+
|
151 |
+
```
|
152 |
+
$ uv run --python=3.11 -- python -m extract --help
|
153 |
+
|
154 |
+
usage: extract.py [-h] [--destination-dir DESTINATION_DIR] [--split-ratio SPLIT_RATIO] [--random-seed RANDOM_SEED] [--remove-zip] zip_file
|
155 |
+
|
156 |
+
Reorganize dataset.
|
157 |
+
|
158 |
+
positional arguments:
|
159 |
+
zip_file Path to the zip file.
|
160 |
+
|
161 |
+
options:
|
162 |
+
-h, --help show this help message and exit
|
163 |
+
--destination-dir DESTINATION_DIR
|
164 |
+
Path to the destination directory.
|
165 |
+
--split-ratio SPLIT_RATIO
|
166 |
+
Ratio of data to be used for training.
|
167 |
+
--random-seed RANDOM_SEED
|
168 |
+
Random seed for reproducibility.
|
169 |
+
--remove-zip Whether to remove the source zip archive file after extraction.
|
170 |
+
```
|
171 |
+
|
172 |
+
Example usage:
|
173 |
+
|
174 |
+
1. Download the data from Kaggle. You can use Kaggle Python SDK, but that might require an API key if you use it locally.
|
175 |
+
|
176 |
+
2. Invoke the script:
|
177 |
+
|
178 |
+
```bash
|
179 |
+
uv run --python=3.11 -- python -m extract -- archive.zip
|
180 |
+
```
|
181 |
+
|
182 |
+
This will explode the contents of the zip archive into a `data` directory, splitting the train and test dataset in a 80%/20% ratio.
|
183 |
+
|
184 |
+
3. Upload to the hub:
|
185 |
+
|
186 |
+
```python
|
187 |
+
from datasets import load_dataset
|
188 |
+
|
189 |
+
ds = load_datset("imagefolder", data_dir="data")
|
190 |
+
ds.push_to_hub()
|
191 |
+
```
|