Spaces:
Running
Running
from typing import * | |
import os | |
from examples import examples as exp_dict | |
MODEL_DIR = "models" | |
IMAGE_DIR = "images" | |
def get_models() -> List[str]: | |
"""List all model names in MODEL_DIR.""" | |
model_names = [] | |
for p in os.listdir(MODEL_DIR): | |
if os.path.isdir(os.path.join(MODEL_DIR, p)): | |
model_names.append(p) | |
return model_names | |
def populate_examples() -> List[Any]: | |
"""Populate example inputs into a list.""" | |
examples = [] | |
for m in get_models(): | |
if m in exp_dict: | |
for img, thres in exp_dict[m]: | |
examples.append([ | |
f"{IMAGE_DIR}/{m}/{img}", | |
thres, | |
"CPU", | |
f"{MODEL_DIR}/{m}" | |
]) | |
return examples | |