Skip to content

Commit 01b25aa

Browse files
No public description
PiperOrigin-RevId: 858967668
1 parent d1951c7 commit 01b25aa

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Summary
4+
cat << EOF
5+
This script sets up the environment for running ML models by ensuring Bash
6+
execution, installing system dependencies, setting up a virtual environment,
7+
installing ML packages, and cloning TensorFlow Model Garden.
8+
EOF
9+
10+
# Ensure the script is executed with /bin/bash
11+
if [ -z "$BASH_VERSION" ]; then
12+
exec /bin/bash "$0" "$@"
13+
fi
14+
15+
sudo apt-get update -y
16+
17+
# Install Docker if not already installed
18+
if ! command -v docker &> /dev/null
19+
then
20+
echo "Docker is not installed. Installing Docker..."
21+
curl -fsSL https://get.docker.com -o get-docker.sh
22+
sudo sh get-docker.sh
23+
rm -f get-docker.sh
24+
echo "Docker installation completed."
25+
else
26+
echo "Docker is already installed. Skipping Docker installation."
27+
fi
28+
29+
# Create a virtual environment and install packages
30+
sudo apt-get install -y python3-venv python3-pip
31+
32+
python3.10 -m venv myenv
33+
source myenv/bin/activate
34+
35+
pip install --no-cache-dir natsort absl-py opencv-python pandas pandas-gbq \
36+
google-cloud-bigquery google-auth trackpy google-cloud-storage \
37+
scikit-image scikit-learn webcolors==1.13 ffmpeg-python tritonclient[all] \
38+
supervision==0.26.1 pillow==12.0.0
39+
40+
# Clone TensorFlow Model Garden if the 'models' directory does not exist
41+
if [ ! -d "models" ]; then
42+
git clone --depth 1 https://github.com/tensorflow/models.git
43+
else
44+
echo "'models' directory already exists. Skipping cloning."
45+
fi
46+
47+
deactivate
48+
echo "Environment setup is complete."
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
cat << EOF
4+
This script automates the execution of an Circularnet pipeline for image
5+
processing.
6+
Steps Performed:
7+
1. Activates the Python virtual environment named 'myenv'.
8+
2. Validates successful activation of the virtual environment.
9+
3. Executes the 'pipeline_images.py' script with the following parameters:
10+
Parameters:
11+
--input_directory : GCS directory where the input images are stored for
12+
inference.
13+
--output_directory : GCS directory where the model inference outputs will be
14+
saved.
15+
--height : Height to which input images are resized for the Mask
16+
R-CNN model.
17+
--width : Width to which input images are resized for the Mask
18+
R-CNN model.
19+
--model : Name of the model to download and use for inference.
20+
--score : Confidence threshold for detections during
21+
inference.
22+
--search_range_x : Max pixel movement allowed in the X direction for
23+
object tracking between missed frames.
24+
--search_range_y : Max pixel movement allowed in the Y direction for
25+
object tracking between missed frames.
26+
--memory : Number of frames an object can be missed and still
27+
be tracked.
28+
--project_id : Google Cloud Project ID for BigQuery operations.
29+
--bq_dataset_id : BigQuery Dataset ID where results will be stored.
30+
--bq_table_id : BigQuery Table ID where results will be stored.
31+
--overwrite : If set to True, overwrites the pre-existing
32+
BigQuery table.
33+
--tracking_visualization : If set to True, visualizes the tracking results
34+
from the tracking algorithm.
35+
--cropped_objects : If set to True, crops the objects per category
36+
according to the prediction and tracking results.
37+
EOF
38+
#Activate the virtual environment
39+
source myenv/bin/activate
40+
# Check if the virtual environment is activated
41+
if [[ "$VIRTUAL_ENV" != "" ]]; then
42+
echo "Virtual environment 'myenv' activated successfully."
43+
else
44+
echo "Failed to activate virtual environment. Exiting."
45+
exit 1
46+
fi
47+
python inference_pipeline.py \
48+
--input_directory=gs://recykal/TestData/SmallTestData \
49+
--output_directory=gs://recykal/TestData/SmallTestData \
50+
--model=detr_seg \
51+
--score=0.50 \
52+
--search_range_x=150 \
53+
--search_range_y=20 \
54+
--memory=3 \
55+
--project_id=waste-identification-ml-330916 \
56+
--bq_dataset_id=circularnet_dataset \
57+
--bq_table_id=vinit_test_table1 \
58+
--overwrite=True

0 commit comments

Comments
 (0)