11#! /bin/bash
22#
3- # This script sets up the complete environment for a computer vision project.
3+ # This script sets up the complete environment for a computer vision project
4+ # using a model ensemble approach of bounding box detection, segmentation,
5+ # and classification. The classification model is a pre-trained VIT model.
6+
7+ # The script performs the following steps:
48# It performs the following steps:
59# 1. Installs system-level dependencies.
610# 2. Creates a Python virtual environment.
711# 3. Installs PyTorch, GroundingDINO, SAM2, and other Python packages.
812# 4. Creates project directories and downloads required model checkpoints.
9- # 5. Installs, configures, and starts the Ollama service .
10- # 6. Pulls a specific LLM model for use with Ollama .
13+ # 5. Fetches the custom trained VIT classifier model .
14+ # 6. Fetches the scripts to run the pipeline .
1115
1216# Exit immediately if a command exits with a non-zero status.
1317set -o errexit
@@ -18,8 +22,7 @@ set -o pipefail
1822
1923# --- 1. Install System Dependencies ---
2024echo " 🔹 Starting: Install System Dependencies"
21- sudo apt-get update -qq -y > /dev/null 2>&1
22- sudo apt-get install -qq -y python3-venv python3-pip lsof > /dev/null 2>&1
25+ sudo apt-get install -y python3-venv python3-pip lsof
2326echo " ✅ Finished: Install System Dependencies"
2427echo " -----"
2528
@@ -33,22 +36,22 @@ echo "-----"
3336# --- 3. Install Compatible Torch version ---
3437echo " 🔹 Starting: Install Torch, Torchvision, Torchaudio"
3538pip uninstall -y torch torchvision torchaudio > /dev/null 2>&1 || true
36- pip install --quiet torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
39+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
3740echo " ✅ Finished: Install Torch, Torchvision, Torchaudio"
3841echo " -----"
3942
4043# --- 4. Install Grounding DINO ---
4144echo " 🔹 Starting: Install Grounding DINO"
42- git clone --quiet https://github.com/IDEA-Research/GroundingDINO.git
45+ git clone https://github.com/IDEA-Research/GroundingDINO.git
4346cd GroundingDINO
44- pip install --quiet - e .
47+ pip install -e .
4548cd ..
4649echo " ✅ Finished: Install Grounding DINO"
4750echo " -----"
4851
4952# --- 5. Install SAM2 and Required Packages ---
5053echo " 🔹 Starting: Install SAM2 and Required Python Packages"
51- pip install --quiet -- no-cache-dir \
54+ pip install --no-cache-dir \
5255 opencv-python \
5356 numpy \
5457 ollama \
@@ -69,18 +72,18 @@ echo "-----"
6972
7073# --- 7. Download Model Checkpoints ---
7174echo " 🔹 Starting: Download SAM2 Checkpoint"
72- wget -q - P ./milk_pouch_project/sam2_model https://dl.fbaipublicfiles.com/segment_anything_2/092824/sam2.1_hiera_large.pt
75+ wget -P ./milk_pouch_project/sam2_model https://dl.fbaipublicfiles.com/segment_anything_2/092824/sam2.1_hiera_large.pt
7376echo " ✅ Finished: Download SAM2 Checkpoint"
7477echo " -----"
7578
7679echo " 🔹 Starting: Download GroundingDINO Model and Config"
77- wget -q - P ./milk_pouch_project/grounding_dino_model https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
78- wget -q - P ./milk_pouch_project/grounding_dino_model https://raw.githubusercontent.com/IDEA-Research/GroundingDINO/refs/heads/main/groundingdino/config/GroundingDINO_SwinT_OGC.py
80+ wget -P ./milk_pouch_project/grounding_dino_model https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
81+ wget -P ./milk_pouch_project/grounding_dino_model https://raw.githubusercontent.com/IDEA-Research/GroundingDINO/refs/heads/main/groundingdino/config/GroundingDINO_SwinT_OGC.py
7982echo " ✅ Finished: Download GroundingDINO Model and Config"
8083echo " -----"
8184
8285echo " 🔹 Starting: Download Image Classifier Model"
83- wget -q - P ./milk_pouch_project/image_classifier_model https://storage.googleapis.com/tf_model_garden/vision/waste_identification_ml/dairy_product_packet_detection/best_vit_model_epoch_131.pt
86+ wget -P ./milk_pouch_project/image_classifier_model https://storage.googleapis.com/tf_model_garden/vision/waste_identification_ml/dairy_product_packet_detection/best_vit_model_epoch_131.pt
8487echo " ✅ Finished: Download Image Classifier Model"
8588echo " -----"
8689
0 commit comments