Skip to content

Commit

Permalink
fix: correct check for parent of bound volumes and pass through args …
Browse files Browse the repository at this point in the history
…to download_crop_pipeline.py
  • Loading branch information
danellecline committed Nov 7, 2024
1 parent 443a43a commit 9906488
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
19 changes: 13 additions & 6 deletions aipipeline/prediction/download_crop_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def run_pipeline(argv=None):
parser = argparse.ArgumentParser(description="Download and crop unknown images.")
parser.add_argument("--config", required=True, help="Config file path")
parser.add_argument("--labels", required=True, help="Comma separated list of labels to download")
parser.add_argument("--download_args", required=False, default=[""], help="Additional arguments for download")
parser.add_argument("--download_dir", required=True, help="Directory to download images")
parser.add_argument("--skip_clean", required=False, default=False,
parser.add_argument("--download-args", required=False, default=[""], help="Additional arguments for download")
parser.add_argument("--download-dir", required=True, help="Directory to download images")
parser.add_argument("--skip-clean", required=False, default=False,
help="Skip cleaning of previously downloaded data")
args, beam_args = parser.parse_known_args(argv)
options = PipelineOptions(beam_args)
Expand Down Expand Up @@ -72,9 +72,16 @@ def run_pipeline(argv=None):

# Make sure the download directory is not a child of the processed directory - this is a safety check
# Otherwise, the processed data could be deleted
processed_dir = config_dict["data"]["processed_path"]
if Path(args.download_dir).is_relative_to(processed_dir):
raise ValueError(f"Download directory {args.download_dir} is a child of the processed directory {processed_dir}")
bind_volumes = config_dict["docker"]["bind_volumes"].keys()
# Check if the download directory is a child of any of the bind volumes in the docker config
found = False
for volume in bind_volumes:
if Path(args.download_dir).is_relative_to(volume):
found = True
break
if not found:
raise ValueError(
f"Download directory {args.download_dir} is not a child of any of the bind volumes in the docker config")

if not args.skip_clean:
clean(args.download_dir)
Expand Down
27 changes: 17 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ list:
@just --list --unsorted

# Setup the environment
install: update
install: update_trackers
conda run -n aipipeline pip install https://github.com/redis/redis-py/archive/refs/tags/v5.0.9.zip
git clone http://github.com/mbari-org/aidata.git deps/aidata
git clone https://github.com/facebookresearch/co-tracker deps/co-tracker
Expand All @@ -17,8 +17,8 @@ install: update
cd .. && mkdir checkpoints && cd checkpoints && wget https://huggingface.co/facebook/cotracker3/resolve/main/scaled_offline.pth

# Update the environment. Run this command after checking out any code changes
update:
conda env update --file environment.yml --prune
update_trackers:
conda env update_trackers --file environment.yml --prune

# Generate a tsne plot of the VSS database
plot-tsne-vss project='uav':
Expand Down Expand Up @@ -137,7 +137,7 @@ fix-uav-metadata:
export PYTHONPATH=.:deps/aidata
time conda run -n aipipeline --no-capture-output python3 $PROJECT_DIR/fix_metadata.py
# Compute saliency for downloaded VOC data and update the Tator database
# Compute saliency for downloaded VOC data and update_trackers the Tator database
compute-saliency project='uav' *more_args="":
#!/usr/bin/env bash
export PROJECT_DIR=./aipipeline/projects/{{project}}
Expand All @@ -155,14 +155,15 @@ crop project='uav' *more_args="":
{{more_args}}
# Download and crop Unknown detections
download-crop-unknowns project='uav' label='Unknown' download_dir='/tmp/download':
download-crop-unknowns project='uav' labels='Unknown' download-dir='/tmp/download' *more_args="":
#!/usr/bin/env bash
export PYTHONPATH=.
time conda run -n aipipeline --no-capture-output python3 aipipeline/prediction/download_crop_pipeline.py \
--config ./aipipeline/projects/{{project}}/config/config_unknown.yml \
--config ./aipipeline/projects/{{project}}/config/config.yml \
--skip_clean True \
--label {{label}} \
--download_dir {{download_dir}}
--labels {{labels}} \
--download-dir {{download-dir}} \
{{more_args}}
# Download only
download project='uav':
Expand Down Expand Up @@ -213,6 +214,12 @@ run-mega-inference:
--skip-load \
--remove-vignette \
--min-confidence 0.2 \
--max-seconds 120 \
--max-seconds 300 \
--stride 1 \
--endpoint_url http://FastAP-FastA-0RIu3xAfMhUa-337062127.us-west-2.elb.amazonaws.com/predict \
--video /mnt/M3/mezzanine/Ventana/2020/12/4318/V4318_20201208T203419Z_h264.mp4
--video /mnt/M3/mezzanine/Ventana/2020/12/4318/V4318_20201208T203419Z_h264.mp4
run-mega-update_trackers:
#!/usr/bin/env bash
export PYTHONPATH=.
time conda run -n aipipeline --no-capture-output python3 aipipeline/projects/bio/run_strided_track.py

0 comments on commit 9906488

Please sign in to comment.