Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Cards Image Classification Model
|
| 3 |
+
|
| 4 |
+
This model is trained to classify images of cards using a custom dataset.
|
| 5 |
+
|
| 6 |
+
## Model Details
|
| 7 |
+
|
| 8 |
+
- Architecture: ResNet18
|
| 9 |
+
- Dataset: Cards Image Dataset-Classification
|
| 10 |
+
- Number of Classes: 53
|
| 11 |
+
- Training Epochs: 25
|
| 12 |
+
- Optimizer: Adam
|
| 13 |
+
- Loss Function: CrossEntropyLoss
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
To use this model, follow the example code below:
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
|
| 21 |
+
from PIL import Image
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
model_name = "sabrilben/cards_image_classification"
|
| 25 |
+
model = AutoModelForImageClassification.from_pretrained(model_name)
|
| 26 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
| 27 |
+
|
| 28 |
+
url = "path/to/image.jpg"
|
| 29 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
| 30 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
| 31 |
+
outputs = model(**inputs)
|
| 32 |
+
logits = outputs.logits
|
| 33 |
+
predicted_class_idx = logits.argmax(-1).item()
|
| 34 |
+
print("Predicted class:", model.config.id2label[predicted_class_idx])```
|
| 35 |
+
|