File size: 3,071 Bytes
8ab7118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ade60cb
 
 
 
 
 
 
 
 
 
 
 
8ab7118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Copyright (C) Intel Corporation
#
# Download the person detection and person attributes recognition models from
# the Open Model Zoo for the appearance-based-search use case, and download the
# sample retail-aisle video that the samples search for people matching a set
# of appearance attributes (e.g. carrying a bag).
# Usage: ./export_and_quantize.sh

set -euo pipefail

# Official Open Model Zoo public model storage (versioned, immutable).
OMZ_BASE="https://storage.openvinotoolkit.org/repositories/open_model_zoo/2023.0/models_bin/1"

echo "--- Installing dependencies ---"
pip install -qU openvino opencv-python numpy

# Download both the IR topology (.xml) and weights (.bin) for an OMZ model
# from the official storage into intel/<model>/<precision>/.
download_omz_model() {
    local model="$1"
    local precision="$2"
    local dest="intel/${model}/${precision}"
    mkdir -p "${dest}"
    local ext
    for ext in xml bin; do
        if [[ ! -f "${dest}/${model}.${ext}" ]]; then
            wget -q -O "${dest}/${model}.${ext}" \
                "${OMZ_BASE}/${model}/${precision}/${model}.${ext}"
        fi
    done
}

# Ask for approval before downloading models and sample files
echo ""
echo "This script will download:"
echo "  - Model weights and/or sample files"
echo ""
read -p "Continue with downloads? (yes/no): " APPROVAL
if [[ "${APPROVAL}" != "yes" ]]; then
    echo "Download cancelled by user."
    exit 0
fi

# Ping the HuggingFace repo to register a tracked download of config.json.
# This is best-effort: a failure (offline, or before the repo is published)
# must not stop the export.
echo "--- Registering HuggingFace download (tracking ping) ---"
HF_REPO_ID="Intel/appearance-based-search"
HF_CONFIG_URL="https://huggingface.co/${HF_REPO_ID}/resolve/main/config.json"
if curl -fsSL -o /dev/null "${HF_CONFIG_URL}"; then
    echo "Registered HuggingFace download for ${HF_REPO_ID}"
else
    echo "WARNING: HuggingFace tracking ping failed (offline?); continuing." >&2
fi
echo ""

echo "--- Downloading person-detection-retail-0013 (FP16) ---"
download_omz_model person-detection-retail-0013 FP16
echo "Ready: person-detection-retail-0013"

echo "--- Downloading person-attributes-recognition-crossroad-0230 (FP16) ---"
download_omz_model person-attributes-recognition-crossroad-0230 FP16
echo "Ready: person-attributes-recognition-crossroad-0230"

echo "--- Downloading sample retail-aisle video ---"
if [[ ! -f test_video.mp4 ]]; then
    wget -q -O test_video.mp4 \
        "https://github.com/intel-iot-devkit/sample-videos/raw/master/store-aisle-detection.mp4"
    echo "Downloaded: test_video.mp4"
else
    echo "Already present: test_video.mp4"
fi

echo "--- Done ---"
echo "Detector   : intel/person-detection-retail-0013/FP16/person-detection-retail-0013.xml"
echo "Attributes : intel/person-attributes-recognition-crossroad-0230/FP16/person-attributes-recognition-crossroad-0230.xml"
echo "Scene      : test_video.mp4 (retail-aisle clip with shoppers of varied appearance)"