🏰 Carcassonne ResNet18 Tile Classifier

A fine-tuned ResNet18 model trained on a synthetic dataset of Carcassonne board game tiles extracted from Board Game Arena (BGA).

πŸ“Œ Model Details

  • Architecture: ResNet18 (PyTorch)
  • Input Resolution: 64x64 RGBA/RGB PNG
  • Classes (24): CCCS, RRRR, CCCF, CCCFS, CCCR, CCCRS, RRRF, CFCF, CFCFS, RFRF, CCFF, CCFFS, CCRR, CCRRS, RRFF, CCFF2, CFCF2, RFFF, FFFF, CFFF, CRRF, CFRR, CRRR, CRFR.

πŸš€ How to Use in PyTorch

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)]}")
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using fcsaba/carcassonne-resnet18-tile-classifier 1