Instructions to use Straueri/ReptileAmphibianClassification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Straueri/ReptileAmphibianClassification with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Straueri/ReptileAmphibianClassification") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Straueri/ReptileAmphibianClassification", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,14 +6,14 @@ from PIL import Image
|
|
| 6 |
import json
|
| 7 |
|
| 8 |
# Load class names
|
| 9 |
-
with open('
|
| 10 |
class_names = json.load(f)
|
| 11 |
|
| 12 |
# Define model
|
| 13 |
def load_model():
|
| 14 |
model = models.resnet50(pretrained=False)
|
| 15 |
model.fc = nn.Linear(model.fc.in_features, len(class_names))
|
| 16 |
-
checkpoint = torch.load('
|
| 17 |
model.load_state_dict(checkpoint['model_state_dict'])
|
| 18 |
model.eval()
|
| 19 |
return model
|
|
|
|
| 6 |
import json
|
| 7 |
|
| 8 |
# Load class names
|
| 9 |
+
with open('class_names.json', 'r') as f:
|
| 10 |
class_names = json.load(f)
|
| 11 |
|
| 12 |
# Define model
|
| 13 |
def load_model():
|
| 14 |
model = models.resnet50(pretrained=False)
|
| 15 |
model.fc = nn.Linear(model.fc.in_features, len(class_names))
|
| 16 |
+
checkpoint = torch.load('reptile_classifier.pth', map_location=torch.device('cpu'))
|
| 17 |
model.load_state_dict(checkpoint['model_state_dict'])
|
| 18 |
model.eval()
|
| 19 |
return model
|