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

connecting seasoned-lynx #37

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ venv

# HPC output/error jobs
*.[oe][0-9]*

# seasoned_lynx model
/feedback/
/logs/
tmp_*.png
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "submodules/models/yolo_legend"]
path = submodules/models/yolo_legend
url = https://github.com/abodeuis/yolo_legend_model
[submodule "submodules/models/seasoned_lynx"]
path = submodules/models/seasoned_lynx
url = https://github.com/dou0000/DARPA_Seasoned_Lynx.git
50 changes: 50 additions & 0 deletions =0.1.9
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Looking in indexes: https://pypi.org/simple, https://test.pypi.org/simple/
Collecting git+https://github.com/DARPA-CRITICALMAAS/[email protected]+draft
Cloning https://github.com/DARPA-CRITICALMAAS/cdr_schemas.git (to revision v0.2.6+draft) to /tmp/pip-req-build-nu0p80e8
Resolved https://github.com/DARPA-CRITICALMAAS/cdr_schemas.git to commit f49d594157b39e1a7ff5d1c1d308a2c07adbb566
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting cmaas_utils
Downloading https://test-files.pythonhosted.org/packages/84/f8/ddc84026b19a4787fca31b21b3e4abd69fc798788d9ca96454c942c69d58/cmaas_utils-0.1.14-py3-none-any.whl.metadata (7.8 kB)
Requirement already satisfied: pydantic in ./venv/lib/python3.10/site-packages (2.8.2)
Requirement already satisfied: geopandas in ./venv/lib/python3.10/site-packages (from cmaas_utils) (1.0.1)
Requirement already satisfied: numpy in ./venv/lib/python3.10/site-packages (from cmaas_utils) (1.26.4)
Requirement already satisfied: rasterio in ./venv/lib/python3.10/site-packages (from cmaas_utils) (1.3.10)
Requirement already satisfied: annotated-types>=0.4.0 in ./venv/lib/python3.10/site-packages (from pydantic) (0.7.0)
Requirement already satisfied: pydantic-core==2.20.1 in ./venv/lib/python3.10/site-packages (from pydantic) (2.20.1)
Requirement already satisfied: typing-extensions>=4.6.1 in ./venv/lib/python3.10/site-packages (from pydantic) (4.12.2)
Requirement already satisfied: pyogrio>=0.7.2 in ./venv/lib/python3.10/site-packages (from geopandas->cmaas_utils) (0.9.0)
Requirement already satisfied: packaging in ./venv/lib/python3.10/site-packages (from geopandas->cmaas_utils) (24.1)
Requirement already satisfied: pandas>=1.4.0 in ./venv/lib/python3.10/site-packages (from geopandas->cmaas_utils) (2.2.2)
Requirement already satisfied: pyproj>=3.3.0 in ./venv/lib/python3.10/site-packages (from geopandas->cmaas_utils) (3.6.1)
Requirement already satisfied: shapely>=2.0.0 in ./venv/lib/python3.10/site-packages (from geopandas->cmaas_utils) (2.0.6)
Requirement already satisfied: affine in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (2.4.0)
Requirement already satisfied: attrs in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (24.2.0)
Requirement already satisfied: certifi in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (2024.7.4)
Requirement already satisfied: click>=4.0 in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (8.1.7)
Requirement already satisfied: cligj>=0.5 in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (0.7.2)
Requirement already satisfied: snuggs>=1.4.1 in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (1.4.7)
Requirement already satisfied: click-plugins in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (1.1.1)
Requirement already satisfied: setuptools in ./venv/lib/python3.10/site-packages (from rasterio->cmaas_utils) (65.5.0)
Requirement already satisfied: python-dateutil>=2.8.2 in ./venv/lib/python3.10/site-packages (from pandas>=1.4.0->geopandas->cmaas_utils) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.10/site-packages (from pandas>=1.4.0->geopandas->cmaas_utils) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in ./venv/lib/python3.10/site-packages (from pandas>=1.4.0->geopandas->cmaas_utils) (2024.1)
Requirement already satisfied: pyparsing>=2.1.6 in ./venv/lib/python3.10/site-packages (from snuggs>=1.4.1->rasterio->cmaas_utils) (3.1.4)
Requirement already satisfied: six>=1.5 in ./venv/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas>=1.4.0->geopandas->cmaas_utils) (1.16.0)
Downloading https://test-files.pythonhosted.org/packages/84/f8/ddc84026b19a4787fca31b21b3e4abd69fc798788d9ca96454c942c69d58/cmaas_utils-0.1.14-py3-none-any.whl (17 kB)
Building wheels for collected packages: cdr_schemas
Building wheel for cdr_schemas (pyproject.toml): started
Building wheel for cdr_schemas (pyproject.toml): finished with status 'done'
Created wheel for cdr_schemas: filename=cdr_schemas-0.2.6+draft-py3-none-any.whl size=17254 sha256=112a1c8bee97fd2125aff01dba3992b4c0f093072bac4f95eef46f49de7df9cb
Stored in directory: /tmp/pip-ephem-wheel-cache-sgp3fcx0/wheels/72/58/31/75d1ae21f832e4bca4b96ed0f27bc2c9320e1fe0b5045698e4
Successfully built cdr_schemas
Installing collected packages: cdr_schemas, cmaas_utils
Attempting uninstall: cdr_schemas
Found existing installation: cdr_schemas 0.4.2
Uninstalling cdr_schemas-0.4.2:
Successfully uninstalled cdr_schemas-0.4.2
Successfully installed cdr_schemas-0.2.6+draft cmaas_utils-0.1.14
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.4.6] - 2024-08-28
- Adding seasoned-lynx model.

## [0.4.5] - 2024-08-20

### Changed
Expand Down
21 changes: 17 additions & 4 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
'blaring_foundry',
'flat_iceberg',
'drab_volcano',
'icy_resin'
'icy_resin',
'seasoned_lynx',
]

# Lazy load only the model we are going to use
from src.models.pipeline_model import pipeline_model
def load_pipeline_model(model_dir : str, model_name : str, override_batch_size=None) -> pipeline_model :
def load_pipeline_model(model_dir : str, model_name : str, override_batch_size=None, override_patch_size=None) -> pipeline_model :
"""Utility function to only import and load the model we are going to use. Returns loaded model"""
log.info(f'Loading model {model_name}')
model_stime = time()
Expand All @@ -52,6 +53,13 @@ def load_pipeline_model(model_dir : str, model_name : str, override_batch_size=N
if model_name == 'icy_resin':
from src.models.icy_resin_model import icy_resin_model
model = icy_resin_model()
if model_name == 'seasoned_lynx':
# from src.models.seasoned_lynx_model import seasoned_lynx_model
from src.models.seasoned_lynx_model_recolor import seasoned_lynx_model
patch_size = 1024 if override_patch_size is None else override_patch_size
model = seasoned_lynx_model(patch_size)


if not os.path.exists(os.path.join(model_dir, model._checkpoint)):
msg = f'Could not load {model_name}. Model checkpoint file "{model._checkpoint}" not found in model directory "{model_dir}"'
log.error(msg)
Expand Down Expand Up @@ -249,6 +257,11 @@ def post_parse_output_types(data : List[str]) -> List[str]:
type=str,
default=os.getenv("CDR_SYSTEM_VERSION", "0.3.0"),
help='The version of the cdr system that will be used to generate cdrs. Default is 1.0')
# for seasoned_lynx
optional_args.add_argument('--patch_size',
type=int,
default=None,
help='Option to override the default patch size for the seasoned lynx model. Default is 1024')

# Flags
flag_group = parser.add_argument_group('Flags', '')
Expand Down Expand Up @@ -409,7 +422,7 @@ def construct_pipeline(args):
p = pipeline_manager()
legend_model = yolo_legend_model()
legend_model.load_model(args.checkpoint_dir)
segmentation_model = load_pipeline_model(args.checkpoint_dir, args.model, override_batch_size=args.batch_size)
segmentation_model = load_pipeline_model(args.checkpoint_dir, args.model, override_batch_size=args.batch_size, override_patch_size=args.patch_size)
drab_volcano_legend = False
if segmentation_model.name == 'drab volcano':
log.warning('Drab Volcano uses a pretrained set of map units for segmentation and is not promptable by the legend')
Expand Down Expand Up @@ -453,7 +466,7 @@ def construct_amqp_pipeline(args):
p = pipeline_manager(monitor=file_monitor())
legend_model = yolo_legend_model()
legend_model.load_model(args.checkpoint_dir)
segmentation_model = load_pipeline_model(args.checkpoint_dir, args.model, override_batch_size=args.batch_size)
segmentation_model = load_pipeline_model(args.checkpoint_dir, args.model, override_batch_size=args.batch_size, override_patch_size=args.patch_size)
drab_volcano_legend = False
if segmentation_model.name == 'drab volcano':
log.warning('Drab Volcano uses a pretrained set of map units for segmentation and is not promptable by the legend')
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ tqdm
rich>13.0
matplotlib==3.8.4


### Submodule Dependencies
# Legend-extraction
--extra-index-url https://pypi.nvidia.com
Expand All @@ -55,6 +56,14 @@ easyocr>=1.7.1
pandas>=2.1.3
joblib

# Seasoned Lynx
transformers
peft
pycocotools
onnx
onnxruntime
fvcore

### OLD ####
# mlflow
#mlflow>=2.8.1
Expand Down
25 changes: 25 additions & 0 deletions runTestPipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_256"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \
python pipeline.py \
-v --data ${SRC_DATA}/images \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 256
29 changes: 29 additions & 0 deletions runTestPipeline_1024.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_1024_recolor"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \

python pipeline.py \
-v --data ${SRC_DATA}/images \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 1024


# make sure to change the patch size to the desired size
29 changes: 29 additions & 0 deletions runTestPipeline_512.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_512"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \

python pipeline.py \
-v --data ${SRC_DATA}/images \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 512


# make sure to change the patch size to the desired size
29 changes: 29 additions & 0 deletions runTestPipeline_512_recolor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_512_update"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \

python pipeline.py \
-v --data ${SRC_DATA}/images \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 512


# make sure to change the patch size to the desired size
29 changes: 29 additions & 0 deletions runTestPipeline_512_recolor_this.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_512_update_recolor"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \

python pipeline.py \
-v --data ${SRC_DATA}/images \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 512


# make sure to change the patch size to the desired size
25 changes: 25 additions & 0 deletions runTestPipeline_debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#TAG="0.4.2" #TAG="0.4.2"
TAG="pr-26"
IMAGE="criticalmaas-pipeline_${TAG}.sif"
# apptainer pull ${IMAGE} docker://ncsa/criticalmaas-pipeline:${TAG}
TEST_MODEL="seasoned_lynx"
# DEST_DIR="/projects/bbym/shared/testingPR/${TAG}/${TEST_MODEL}/validation_w_layout"
DEST_DIR="/projects/bcxi/shared/seasoned_lynx_testing/patch_1024_recolor"
SRC_DATA="/projects/bcxi/shared/datasets/validation"
mkdir -p ${DEST_DIR}/feedback
mkdir -p ${DEST_DIR}/logs
mkdir -p ${DEST_DIR}/output

#srun -A bcxi-tgirails --time=4:00:00 --partition=gpu --ntasks-per-node=16 --gpus=4 --mem=50g --nodes=1 --pty /bin/bash

# apptainer run --nv -B ${SRC_DATA}:/data -B ${DEST_DIR}/feedback:/feedback \
# -B ${DEST_DIR}/logs:/logs -B ${DEST_DIR}/output:/output ${IMAGE} \
python pipeline.py -v \
--data /projects/bcxi/shared/datasets/validation/images/AR_Maumee.tif \
--legends ${SRC_DATA}/legends --output ${DEST_DIR}/output \
--layouts ${SRC_DATA}/layouts \
--feedback ${DEST_DIR}/feedback \
--log ${DEST_DIR}/logs/log.log --model ${TEST_MODEL} \
--validation ${SRC_DATA}/true_segmentations \
--output_types raster_masks \
--patch_size 1024
Loading
Loading