mirror of
https://github.com/hanzoai/anomalib.git
synced 2026-10-30 18:48:11 +00:00
The previous commit was meant to remove .github/workflows and removed every tracked path instead — 892 files, the whole repo. This puts back the 874 that were never in scope; the eighteen workflow files stay gone, for the reasons that commit gives. Content is byte-identical to 9d2aec9 outside .github/workflows.
61 lines
1.6 KiB
Bash
61 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Copyright (C) 2024 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Complete Anomalib Pipeline Example
|
|
# ------------------------------
|
|
# This script demonstrates a complete workflow from training to deployment.
|
|
|
|
# 0. Setup
|
|
# Create necessary directories
|
|
mkdir -p results exported_models predictions
|
|
|
|
# 1. Training Phase
|
|
# ----------------
|
|
echo "Starting Training Phase..."
|
|
anomalib train \
|
|
--model patchcore \
|
|
--data.category bottle \
|
|
--trainer.max_epochs 1 \
|
|
--trainer.enable_checkpointing true \
|
|
--trainer.default_root_dir results
|
|
|
|
# 2. Export Phase
|
|
# --------------
|
|
echo -e "\nStarting Export Phase..."
|
|
anomalib export \
|
|
--model patchcore \
|
|
--weights results/*/checkpoints/*.ckpt \
|
|
--export_root exported_models \
|
|
--export_mode onnx \
|
|
--input_size 256 256
|
|
|
|
# 3. Inference Phase
|
|
# ----------------
|
|
echo -e "\nStarting Inference Phase..."
|
|
|
|
# 3.1 Using PyTorch Model
|
|
echo "Running inference with PyTorch model..."
|
|
anomalib predict \
|
|
--model patchcore \
|
|
--weights results/*/checkpoints/*.ckpt \
|
|
--input path/to/test/images \
|
|
--output predictions/torch_results
|
|
|
|
# 3.2 Using Exported Model
|
|
echo -e "\nRunning inference with exported ONNX model..."
|
|
anomalib predict \
|
|
--model patchcore \
|
|
--weights exported_models/model.onnx \
|
|
--input path/to/test/images \
|
|
--output predictions/onnx_results
|
|
|
|
# 4. Results Summary
|
|
# ----------------
|
|
echo -e "\nPipeline Complete!"
|
|
echo "Results are saved in:"
|
|
echo "- Training results: results/"
|
|
echo "- Exported models: exported_models/"
|
|
echo "- Predictions: predictions/"
|