3.png

WikiArt-Genre

WikiArt-Genre is a vision model fine-tuned from google/siglip2-base-patch16-224 using the SiglipForImageClassification architecture. It classifies artwork images into one of 43 genre categories from the WikiArt dataset.

Classification Report:
                          precision    recall  f1-score   support

                    None     0.7222    0.0518    0.0967      1254
                abstract     0.8268    0.9280    0.8745      9498
           advertisement     0.0000    0.0000    0.0000        82
    allegorical painting     0.4576    0.0522    0.0938      1034
         animal painting     0.6474    0.6569    0.6521      1571
         battle painting     0.4755    0.1899    0.2715       358
                 bijinga     0.4737    0.0947    0.1579        95
bird-and-flower painting     0.5410    0.5546    0.5477       119
             calligraphy     0.7989    0.8938    0.8437       160
               capriccio     1.0000    0.0169    0.0333       236
              caricature     0.9412    0.2078    0.3404       231
               cityscape     0.7335    0.7556    0.7444      5348
              cloudscape     0.7949    0.1490    0.2510       208
                  design     0.5811    0.5593    0.5700      2024
              figurative     0.4517    0.3124    0.3693      2244
         flower painting     0.7846    0.8574    0.8194      1606
          genre painting     0.6442    0.7460    0.6914     14260
        history painting     0.4623    0.1115    0.1797       879
            illustration     0.5557    0.6156    0.5841      3202
                interior     0.6495    0.4896    0.5583       670
               landscape     0.8068    0.8876    0.8453     15006
       literary painting     0.7000    0.0125    0.0246       558
                  marina     0.6790    0.7429    0.7095      1805
               miniature     0.0000    0.0000    0.0000       118
   mythological painting     0.4949    0.3565    0.4145      1910
      nude painting (nu)     0.6639    0.7926    0.7225      2290
                panorama     0.0000    0.0000    0.0000        19
               pastorale     0.0000    0.0000    0.0000       125
                portrait     0.7518    0.8867    0.8137     16847
                  poster     0.4338    0.2063    0.2796       286
              quadratura     0.0000    0.0000    0.0000        22
      religious painting     0.7543    0.7530    0.7537      7429
           self-portrait     0.6058    0.1365    0.2228      1531
               shan shui     0.0000    0.0000    0.0000        33
        sketch and study     0.6475    0.4361    0.5212      3644
              still life     0.7923    0.7953    0.7938      3132
       symbolic painting     0.5231    0.4629    0.4911      2545
            tessellation     0.8583    0.5860    0.6965       186
                urushi-e     0.0000    0.0000    0.0000         1
                 vanitas     0.0000    0.0000    0.0000        32
                  veduta     0.8043    0.1588    0.2652       233
       wildlife painting     0.5833    0.5138    0.5463       327
               yakusha-e     0.6250    0.0543    0.1000        92

                accuracy                         0.7183    103250
               macro avg     0.5411    0.3727    0.3925    103250
            weighted avg     0.7044    0.7183    0.6945    103250
from datasets import load_dataset

# Load the dataset
dataset = load_dataset("Artificio/WikiArt")

# Extract unique masterCategory values (assuming it's a string field)
labels = sorted(set(example["genre"] for example in dataset["train"]))

# Create id2label mapping
id2label = {str(i): label for i, label in enumerate(labels)}

# Print the mapping
print(id2label)
{'0': 'None', '1': 'abstract', '2': 'advertisement', '3': 'allegorical painting', '4': 'animal painting', '5': 'battle painting', '6': 'bijinga', '7': 'bird-and-flower painting', '8': 'calligraphy', '9': 'capriccio', '10': 'caricature', '11': 'cityscape', '12': 'cloudscape', '13': 'design', '14': 'figurative', '15': 'flower painting', '16': 'genre painting', '17': 'history painting', '18': 'illustration', '19': 'interior', '20': 'landscape', '21': 'literary painting', '22': 'marina', '23': 'miniature', '24': 'mythological painting', '25': 'nude painting (nu)', '26': 'panorama', '27': 'pastorale', '28': 'portrait', '29': 'poster', '30': 'quadratura', '31': 'religious painting', '32': 'self-portrait', '33': 'shan shui', '34': 'sketch and study', '35': 'still life', '36': 'symbolic painting', '37': 'tessellation', '38': 'urushi-e', '39': 'vanitas', '40': 'veduta', '41': 'wildlife painting', '42': 'yakusha-e'}

Model Details

The model predicts one of the following genre categories for artworks:

ID Genre ID Genre
0 None 22 Marina
1 Abstract 23 Miniature
2 Advertisement 24 Mythological Painting
3 Allegorical Painting 25 Nude Painting (Nu)
4 Animal Painting 26 Panorama
5 Battle Painting 27 Pastorale
6 Bijinga 28 Portrait
7 Bird-and-Flower Painting 29 Poster
8 Calligraphy 30 Quadratura
9 Capriccio 31 Religious Painting
10 Caricature 32 Self-Portrait
11 Cityscape 33 Shan Shui
12 Cloudscape 34 Sketch and Study
13 Design 35 Still Life
14 Figurative 36 Symbolic Painting
15 Flower Painting 37 Tessellation
16 Genre Painting 38 Urushi-e
17 History Painting 39 Vanitas
18 Illustration 40 Veduta
19 Interior 41 Wildlife Painting
20 Landscape 42 Yakusha-e
21 Literary Painting

Run with Transformers πŸ€—

pip install -q transformers torch pillow gradio
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/WikiArt-Genre"  # Replace with your actual model path
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# Label mapping
id2label = {
    0: "None", 1: "abstract", 2: "advertisement", 3: "allegorical painting", 4: "animal painting",
    5: "battle painting", 6: "bijinga", 7: "bird-and-flower painting", 8: "calligraphy",
    9: "capriccio", 10: "caricature", 11: "cityscape", 12: "cloudscape", 13: "design",
    14: "figurative", 15: "flower painting", 16: "genre painting", 17: "history painting",
    18: "illustration", 19: "interior", 20: "landscape", 21: "literary painting", 22: "marina",
    23: "miniature", 24: "mythological painting", 25: "nude painting (nu)", 26: "panorama",
    27: "pastorale", 28: "portrait", 29: "poster", 30: "quadratura", 31: "religious painting",
    32: "self-portrait", 33: "shan shui", 34: "sketch and study", 35: "still life",
    36: "symbolic painting", 37: "tessellation", 38: "urushi-e", 39: "vanitas",
    40: "veduta", 41: "wildlife painting", 42: "yakusha-e"
}

def classify_genre(image):
    """Predicts the genre category for an artwork."""
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
    return predictions

# Gradio interface
iface = gr.Interface(
    fn=classify_genre,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(label="Genre Prediction Scores"),
    title="WikiArt-Genre",
    description="Upload an artwork image to predict its genre (e.g., landscape, portrait, calligraphy, still life, etc.)."
)

# Launch the app
if __name__ == "__main__":
    iface.launch()

Intended Use

This model is best suited for:

  • Art classification and analysis
  • Museum and gallery cataloging systems
  • Art history research tools
  • Training data enrichment for AI art models
  • Art-themed e-commerce filtering and tagging
Downloads last month
8
Safetensors
Model size
92.9M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for prithivMLmods/WikiArt-Genre

Finetuned
(53)
this model

Dataset used to train prithivMLmods/WikiArt-Genre

Collection including prithivMLmods/WikiArt-Genre