File size: 1,318 Bytes
6bcacf9
8c39361
6bcacf9
8c39361
6bcacf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c39361
 
 
 
 
 
415da73
8c39361
 
 
 
 
415da73
 
 
 
8c39361
 
 
 
 
 
 
 
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
from constants import DEVICE
from typing import List
import platform
from backend.device import is_openvino_device


def is_reshape_required(
    prev_width: int,
    cur_width: int,
    prev_height: int,
    cur_height: int,
    prev_model: int,
    cur_model: int,
    prev_num_of_images: int,
    cur_num_of_images: int,
) -> bool:
    reshape_required = False
    if (
        prev_width != cur_width
        or prev_height != cur_height
        or prev_model != cur_model
        or prev_num_of_images != cur_num_of_images
    ):
        print("Reshape and compile")
        reshape_required = True

    return reshape_required


def enable_openvino_controls() -> bool:
    return is_openvino_device() and platform.system().lower() != "darwin"


def get_valid_model_id(
    models: List,
    model_id: str,
    default_model: str = "",
) -> str:
    if len(models) == 0:
        print("Error: model configuration file is empty,please add some models.")
        return ""
    if model_id == "":
        if default_model:
            return default_model
        else:
            return models[0]

    if model_id in models:
        return model_id
    else:
        print(
            f"Error:{model_id} Model not found in configuration file,so using first model : {models[0]}"
        )
        return models[0]