Metadata-Version: 2.4
Name: plot_boundary_extractor
Version: 0.3.3
Summary: Plot boundary extractor using segment anything model
Author: Hansae Kim
Author-email: kim4012@purdue.edu
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10, <3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: d2spy
Requires-Dist: fiona
Requires-Dist: geojson
Requires-Dist: geopandas
Requires-Dist: jupyter
Requires-Dist: leafmap
Requires-Dist: numpy
Requires-Dist: opencv-python
Requires-Dist: pandas
Requires-Dist: pyproj
Requires-Dist: rasterio
Requires-Dist: scikit-image
Requires-Dist: scikit-learn
Requires-Dist: shapely
Requires-Dist: openrs-python
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# `plot-boundary-extractor` module

This module is to extract field experiment plot boundary for agricultural applications.

---

*Developed by [Hansae Kim](https://gdsl.org/team/hansae-kim/) and [Jinha Jung](https://gdsl.org/team/jinha-jung/)*

## `plot-boundary-extractor` installation

### Set up a virtual environment

First, we need to install `plot-boundary-extractor` on the machine you would like to run this example tutorial. We will set up a new Python Virtual Environment called `pbe`. 

```bash
$ conda create -n pbe -c conda-forge gdal python=3.10 -y
```

We need to activate the newly created virtual environment before proceeding.

```bash
$ conda activate pbe
```

### Install `plot-boundary-extractor` module

Now we need to install `plot-boundary-extractor` module using `pip`.

```bash
$ pip install plot-boundary-extractor
```

### Install torch

The `plot-boundary-extractor` module uses `torch` module, so we need to install it on the machine you would like to run this example tutorial. 

#### CPU version

If your machine is not equipoped with NVIDIA GPU, then you will have to install the `torch` without GPU support.

```bash
$ pip install torch torchvision
```

#### GPU version

If your machine is equipped with NVIDIA GPU, then you will have to install the `torch` with GPU support.

```bash
$ pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
```

### Install `SAM`

The `plot-boundary-extractor` uses `SAM` to detect plot boundary automatically, so you have to install `SAM` using the below command.

```bash
$ pip install git+https://github.com/facebookresearch/segment-anything.git
```

You also have to download a pre-trained model using the below command. Please make a note where you're downloading the pre-trained model. We will need this path information in the later tutorial.

```bash
$ wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
```

Now the installation is done, and you're ready to extract plot boundaries using the `plot-boundary-extractor` module. An example [Jupyter Notebook](./plot_boundary_extractor_demo.ipynb) is available for your reference.


## Citation

If you use this repository in your research, please cite the following paper:

> Kim, H.S., Olaniyi, I., Chang, A., & Jung, J. (2025).  
> *Developing a segment anything model-based framework for automated plot extraction*.  
> Precision Agriculture, 26(3), 53. Springer.  

```bibtex
@article{kim2025developing,
  title={Developing a segment anything model-based framework for automated plot extraction},
  author={Kim, Han Sae and Olaniyi, Ismail and Chang, Anjin and Jung, Jinha},
  journal={Precision Agriculture},
  volume={26},
  number={3},
  pages={53},
  year={2025},
  publisher={Springer}
}
