Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full_dask_inclusion #2

Merged
merged 33 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@ python geo_inference -a <args>
```
- `-a`, `--args`: Path to arguments stored in yaml, consult ./config/sample_config.yaml
```bash
python geo_inference -i <image> -m <model> -wd <work_dir> -bs <batch_size> -v <vec> -d <device> -id <gpu_id>
python geo_inference -i <image> -br <bands_requested> -m <model> -wd <work_dir> -ps <patch_size> -v <vec> -d <device> -id <gpu_id> -cls <classes> -mg <mgpu>
```
- `-i`, `--image`: Path to Geotiff
- `-bb`, `--bbox`: AOI bbox in this format "minx, miny, maxx, maxy" (Optional)
- `-br`, `--bands_requested`: The requested bands from provided Geotiff (if not provided, it uses all bands)
- `-m`, `--model`: Path or URL to the model file
- `-wd`, `--work_dir`: Working Directory
- `-bs`, `--batch_size`: The Batch Size
- `-ps`, `--patch_size`: The patch Size, the size of dask chunks, Default = 1024
- `-v`, `--vec`: Vector Conversion
- `-y`, `--yolo`: Yolo Conversion
- `-c`, `--coco`: Coco Conversion
- `-d`, `--device`: CPU or GPU Device
- `-id`, `--gpu_id`: GPU ID, Default = 0
- `-cls`, `--classes`: The number of classes that model outputs, Default = 5
- `-mg`, `--mgpu`: Whether to use multi-gpu processing or not, Default = False


You can also use the `-h` option to get a list of supported arguments:

Expand All @@ -63,18 +67,20 @@ from geo_inference.geo_inference import GeoInference
geo_inference = GeoInference(
model="/path/to/segformer_B5.pt",
work_dir="/path/to/work/dir",
batch_size=4,
patch_size=1024,
mask_to_vec=False,
vec_to_yolo=False,
vec_to_coco=False,
mask_to_yolo=False,
mask_to_coco=False,
device="gpu",
gpu_id=0
multi_gpu=False,
gpu_id=0,
num_classes=5
)

# Perform feature extraction on a TIFF image
image_path = "/path/to/image.tif"
patch_size = 512
geo_inference(tiff_image = image_path, patch_size = patch_size,)
geo_inference(tiff_image = image_path, bands_requested = bands_requested, patch_size = patch_size,)
```

## Parameters
Expand All @@ -83,13 +89,14 @@ The `GeoInference` class takes the following parameters:

- `model`: The path or URL to the model file (.pt for PyTorch models) to use for feature extraction.
- `work_dir`: The path to the working directory. Default is `"~/.cache"`.
- `batch_size`: The batch size to use for feature extraction. Default is `4`.
- `patch_size`: The patch size to use for feature extraction. Default is `4`.
- `mask_to_vec`: If set to `"True"`, vector data will be created from mask. Default is `"False"`
- `vec_to_yolo`: If set to `"True"`, vector data will be converted to YOLO format. Default is `"False"`
- `vec_to_coco`: If set to `"True"`, vector data will be converted to COCO format. Default is `"False"`
- `mask_to_yolo`: If set to `"True"`, vector data will be converted to YOLO format. Default is `"False"`
- `mask_to_coco`: If set to `"True"`, vector data will be converted to COCO format. Default is `"False"`
- `device`: The device to use for feature extraction. Can be `"cpu"` or `"gpu"`. Default is `"gpu"`.
- `multi_gpu`: If set to `"True"`, uses multi-gpu for running the inference. Default is `"False"`
- `gpu_id`: The ID of the GPU to use for feature extraction. Default is `0`.

- `num_classes`: The number of classes that the TorchScript model outputs. Default is `5`.
## Output

The `GeoInference` class outputs the following files:
Expand Down
14 changes: 9 additions & 5 deletions geo_inference/config/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
arguments:
image: "./data/areial.tiff" # Path to Geotiff
image: "./NB_PointEscuminac_WV02_20220615_A-017161374010_01_P001-WV02-R-G-B_clahe25.tif"
model: ./deep_learning_model/4cls_RGB_5_1_2_3_scripted.pt # Name of Extraction Model: str
bbox: None # "minx, miny, maxx, maxy"
model: "rgb-4class-segformer" # Name of Extraction Model: str
work_dir: None # Working Directory: str
batch_size: 1 # Batch size
work_dir: ./dask_geo_deep_learning/dask_geo_inference # Working Directory: str
bands_requested: '1,2,3' # requested Bands
vec: False # Vector Coversion: bool
vec: False # Vector Conversion: bool
yolo: False # YOLO Conversion: bool
coco: False # COCO Conversion: bool
device: "gpu" # cpu or gpu: str
gpu_id: 0 # GPU ID: int
gpu_id: 0
mgpu: False
classes : 5
patch_size: 1024
Loading
Loading