Instructions to use hilmiatha/resnet18-flower-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hilmiatha/resnet18-flower-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="hilmiatha/resnet18-flower-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("hilmiatha/resnet18-flower-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload 3 files
Browse files- README (1).md +27 -0
- config.json +1 -0
- pytorch_model.bin +3 -0
README (1).md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ResNet18 Flower Classifier
|
| 2 |
+
This model classifies images into one of five flower types.
|
| 3 |
+
## Usage
|
| 4 |
+
```python
|
| 5 |
+
from torchvision import transforms
|
| 6 |
+
from PIL import Image
|
| 7 |
+
import torch
|
| 8 |
+
from torchvision.models import resnet18
|
| 9 |
+
|
| 10 |
+
model = resnet18(weights=None)
|
| 11 |
+
model.load_state_dict(torch.load('path_to_model/pytorch_model.bin'))
|
| 12 |
+
model.eval()
|
| 13 |
+
|
| 14 |
+
transform = transforms.Compose([
|
| 15 |
+
transforms.Resize((224, 224)),
|
| 16 |
+
transforms.ToTensor(),
|
| 17 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
| 18 |
+
])
|
| 19 |
+
|
| 20 |
+
image = Image.open('path_to_image.jpg')
|
| 21 |
+
image = transform(image).unsqueeze(0)
|
| 22 |
+
|
| 23 |
+
with torch.no_grad():
|
| 24 |
+
output = model(image)
|
| 25 |
+
_, predicted = torch.max(output.data, 1)
|
| 26 |
+
print(predicted.item())
|
| 27 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"architecture": "resnet18", "num_labels": 5}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:716e1d839aba5a49d9d1a95aa8e5b08de1c13bb71914da71a70763aa513b17c6
|
| 3 |
+
size 44795890
|