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/rexnet2_0x").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-2007-00992,
2 author = {Dongyoon Han and
3 Sangdoo Yun and
4 Byeongho Heo and
5 Young Joon Yoo},
6 title = {ReXNet: Diminishing Representational Bottleneck on Convolutional Neural
7 Network},
8 journal = {CoRR},
9 volume = {abs/2007.00992},
10 year = {2020},
11 url = {https://arxiv.org/abs/2007.00992},
12 eprinttype = {arXiv},
13 eprint = {2007.00992},
14 timestamp = {Mon, 06 Jul 2020 15:26:01 +0200},
15 biburl = {https://dblp.org/rec/journals/corr/abs-2007-00992.bib},
16 bibsource = {dblp computer science bibliography, https://dblp.org}
17}1@software{Fernandez_Holocron_2020,
2author = {Fernandez, François-Guillaume},
3month = {5},
4title = {{Holocron}},
5url = {https://github.com/frgfm/Holocron},
6year = {2020}
7}