| | --- |
| | library_name: transformers |
| | --- |
| | |
| | This is the HF transformers implementation for HGNet-V2 |
| |
|
| | Model: HGNet-V2 - B4 |
| |
|
| | A HGNet-V2 (High Performance GPU Net) image classification model. |
| |
|
| | Usage: |
| |
|
| | ```python |
| | import torch |
| | import requests |
| | |
| | from PIL import Image |
| | from transformers import HGNetV2ForImageClassification, AutoImageProcessor |
| | |
| | url = 'http://images.cocodataset.org/val2017/000000039769.jpg' |
| | image = Image.open(requests.get(url, stream=True).raw) |
| | |
| | image_processor = AutoImageProcessor.from_pretrained("ustc-community/hgnet-v2") |
| | model = HGNetV2ForImageClassification.from_pretrained("ustc-community/hgnet-v2") |
| | |
| | inputs = image_processor(images=image, return_tensors="pt") |
| | |
| | with torch.no_grad(): |
| | outputs = model(**inputs) |
| | outputs.logits.shape |
| | torch.Size([1, 2]) |