Downloads · 30 days
0
fcsaba/carcassonne-resnet18-tile-classifier
carcassonne-resnet18-tile-classifier is a image classification model from fcsaba. Use it when you need a label for an image. The card lists the license as mit.
A fine-tuned ResNet18 model trained on a synthetic dataset of Carcassonne board game tiles extracted from Board Game Arena (BGA).
Downloads · 30 days
0
Access
Public
Updated Sep 20, 2026
Repo size
44.8 MB
Likes
0
Public
Click a slice to open those files.
.pth44.8 MB · 100%
From the Hugging Face model README
A fine-tuned ResNet18 model trained on a synthetic dataset of Carcassonne board game tiles extracted from Board Game Arena (BGA).
import json
import torch
import torch.nn as nn
from torchvision import transforms, models
from huggingface_hub import hf_hub_download
from PIL import Image
REPO_ID = "fcsaba/carcassonne-resnet18-tile-classifier"
# Download weights and class index mapping from Hugging Face Hub
model_path = hf_hub_download(repo_id=REPO_ID, filename="carcassonne_model.pth")
classes_path = hf_hub_download(repo_id=REPO_ID, filename="class_names.json")
with open(classes_path, "r") as f:
idx_to_class = json.load(f)
# Reconstruct ResNet18 architecture
model = models.resnet18(weights=None)
model.fc = nn.Sequential(
nn.Dropout(0.3),
nn.Linear(model.fc.in_features, len(idx_to_class))
)
model.load_state_dict(torch.load(model_path, map_location="cpu"))
model.eval()
# Inference transformation
transform = transforms.Compose([
transforms.Resize((64, 64)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
img = Image.open("tile_sample.png").convert("RGB")
input_tensor = transform(img).unsqueeze(0)
with torch.no_grad():
outputs = model(input_tensor)
pred_idx = torch.argmax(outputs, dim=1).item()
print(f"Predicted Tile Class: {idx_to_class[str(pred_idx)]}")