Upload dataset.py
Browse files- AgriField3D/dataset.py +36 -0
AgriField3D/dataset.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
# Metadata and dataset folder paths
|
5 |
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
6 |
+
DATASET_DIR = BASE_DIR / "datasets"
|
7 |
+
|
8 |
+
def get_dataset_info():
|
9 |
+
"""Print information about available datasets."""
|
10 |
+
datasets = {
|
11 |
+
"Raw Point Clouds": [
|
12 |
+
"FielGrwon_ZeaMays_RawPCD_100k.zip",
|
13 |
+
"FielGrwon_ZeaMays_RawPCD_50k.zip",
|
14 |
+
"FielGrwon_ZeaMays_RawPCD_10k.zip",
|
15 |
+
],
|
16 |
+
"Segmented Point Clouds": [
|
17 |
+
"FielGrwon_ZeaMays_SegmentedPCD_100k.zip",
|
18 |
+
"FielGrwon_ZeaMays_SegmentedPCD_50k.zip",
|
19 |
+
"FielGrwon_ZeaMays_SegmentedPCD_10k.zip",
|
20 |
+
],
|
21 |
+
}
|
22 |
+
return datasets
|
23 |
+
|
24 |
+
def download_dataset(dataset_name, target_dir):
|
25 |
+
"""
|
26 |
+
Extract the specified dataset to the target directory.
|
27 |
+
"""
|
28 |
+
import zipfile
|
29 |
+
dataset_path = DATASET_DIR / dataset_name
|
30 |
+
|
31 |
+
if not dataset_path.exists():
|
32 |
+
raise FileNotFoundError(f"{dataset_name} not found in datasets folder.")
|
33 |
+
|
34 |
+
with zipfile.ZipFile(dataset_path, 'r') as zip_ref:
|
35 |
+
zip_ref.extractall(target_dir)
|
36 |
+
print(f"Dataset {dataset_name} extracted to {target_dir}.")
|