Views
No views yet
pip install pylocronconda install -c frgfm pylocron1git clone https://github.com/frgfm/Holocron.git
2pip install -e Holocron/.1from PIL import Image
2from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
3from torchvision.transforms.functional import InterpolationMode
4from holocron.models import model_from_hf_hub
5
6model = model_from_hf_hub("frgfm/repvgg_a1").eval()
7
8img = Image.open(path_to_an_image).convert("RGB")
9
10# Preprocessing
11config = model.default_cfg
12transform = Compose([
13 Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
14 PILToTensor(),
15 ConvertImageDtype(torch.float32),
16 Normalize(config['mean'], config['std'])
17])
18
19input_tensor = transform(img).unsqueeze(0)
20
21# Inference
22with torch.inference_mode():
23 output = model(input_tensor)
24probs = output.squeeze(0).softmax(dim=0)1@article{DBLP:journals/corr/abs-2101-03697,
2 author = {Xiaohan Ding and
3 Xiangyu Zhang and
4 Ningning Ma and
5 Jungong Han and
6 Guiguang Ding and
7 Jian Sun},
8 title = {RepVGG: Making VGG-style ConvNets Great Again},
9 journal = {CoRR},
10 volume = {abs/2101.03697},
11 year = {2021},
12 url = {https://arxiv.org/abs/2101.03697},
13 eprinttype = {arXiv},
14 eprint = {2101.03697},
15 timestamp = {Tue, 09 Feb 2021 15:29:34 +0100},
16 biburl = {https://dblp.org/rec/journals/corr/abs-2101-03697.bib},
17 bibsource = {dblp computer science bibliography, https://dblp.org}
18}1@software{Fernandez_Holocron_2020,
2author = {Fernandez, François-Guillaume},
3month = {5},
4title = {{Holocron}},
5url = {https://github.com/frgfm/Holocron},
6year = {2020}
7}