Skip to main content

Unified IAA inference SDK (PIAA + GIAA prior)

Project description


library_name: pytorch tags:

  • image-aesthetics
  • personalization
  • vit
  • swin
  • pt70

Unified IAA (PARA pt=70 + LAPIS pt=137)

This release includes:

  • PARA PIAA-MIR (pt=70)
    • best_model_vit_small_patch16_224_piaamir_super-yogurt-742.pth
    • best_model_swin_tiny_patch4_window7_224_piaamir_fanciful-blaze-742.pth
  • PARA PIAA-ICI (pt=70)
    • best_model_swin_tiny_patch4_window7_224_piaaici_ethereal-cherry-741.pth
    • best_model_vit_small_patch16_224_piaaici_laced-bird-742.pth
  • LAPIS PIAA-MIR (pt=137)
    • lapis_best_model_resnet50_piaamir_azure-gorge-1153.pth
  • LAPIS PIAA-ICI (pt=137)
    • lapis_best_model_resnet50_piaaici_dutiful-serenity-1076.pth
  • PARA GIAA prior vector (prior_mean_vector.pt, shape [70])

Scope and compatibility

  • API naming:

    • task: PIAA or GIAA
    • model: mir or ici
  • ✅ PARA supported: num_pt=70, disable_onehot=false

  • ✅ LAPIS supported: num_pt=137 (use direct trait vector input)

  • ✅ Supports both:

    • PARA GIAA prior inference (using uploaded prior_mean_vector.pt)
    • PARA PIAA personalized inference (user provides demographics + Big5)
    • LAPIS inference (user provides a trait vector)

See configs/compatibility.json for exact artifact mapping and hashes.

Files

  • models/best_model_vit_small_patch16_224_piaamir_super-yogurt-742.pth
  • models/best_model_swin_tiny_patch4_window7_224_piaamir_fanciful-blaze-742.pth
  • models/best_model_swin_tiny_patch4_window7_224_piaaici_ethereal-cherry-741.pth
  • models/best_model_vit_small_patch16_224_piaaici_laced-bird-742.pth
  • models/lapis_best_model_resnet50_piaamir_azure-gorge-1153.pth
  • models/lapis_best_model_resnet50_piaaici_dutiful-serenity-1076.pth
  • inference/prior_mean_vector.pt
  • inference/demographics_encoder.py
  • inference/predict_piaa.py
  • inference/prior_giaa.py
  • infer_unified_iaa.sh
  • run_LAPIS_PIAA.sh

Python SDK (pip style)

pip install unified-iaa
# or local editable
# pip install -e .
from unified_iaa import UnifiedIAA

m = UnifiedIAA.from_pretrained("stupidog04/Unified_IAA")

score_piaa = m.predict_piaa(
    image="/path/to/test.jpg",
    demographics={
        "age": "30-34",
        "gender": "female",
        "EducationalLevel": "junior_college",
        "artExperience": "proficient",
        "photographyExperience": "proficient",
    },
    big5={
        "personality-E": 6,
        "personality-A": 7,
        "personality-N": 4,
        "personality-O": 8,
        "personality-C": 6,
    },
    task="PIAA",
    model="mir",
    backbone="vit_small_patch16_224",
)

score_giaa = m.predict_giaa_prior(
    image="/path/to/test.jpg",
    task="GIAA",
    model="mir",
    backbone="vit_small_patch16_224",
)

# LAPIS (pt=137) with direct trait vector
lapis_traits = [0.0] * 137
score_lapis = m.predict_with_traits(
    image="/path/to/test.jpg",
    traits=lapis_traits,
    task="PIAA",   # or "GIAA"
    model="mir",   # or "ici"
    backbone="resnet50",
    dataset="lapis",
)

Quick usage

1) Build demographics encoder

python inference/demographics_encoder.py \
  --userinfo_csv /mnt/d/datasets/PARA/annotation/PARA-UserInfo.csv \
  --out_json inference/demographics_encoder.json

2) Personalized PIAA inference (user demographics input)

python inference/predict_piaa.py \
  --task mir \
  --backbone vit_small_patch16_224 \
  --checkpoint models/best_model_vit_small_patch16_224_piaamir_super-yogurt-742.pth \
  --image /path/to/image.jpg \
  --encoder_json inference/demographics_encoder.json \
  --demographics_json /path/to/user_demo.json

3) GIAA prior inference (uploaded prior vector)

python inference/prior_giaa.py \
  --task ici \
  --backbone swin_tiny_patch4_window7_224 \
  --checkpoint models/best_model_swin_tiny_patch4_window7_224_piaaici_ethereal-cherry-741.pth \
  --image /path/to/image.jpg \
  --prior_vector_path inference/prior_mean_vector.pt

4) Run LAPIS PIAA eval pipeline

bash run_LAPIS_PIAA.sh

user_demo.json format

{
  "age": "30-34",
  "gender": "female",
  "EducationalLevel": "junior_college",
  "artExperience": "proficient",
  "photographyExperience": "proficient",
  "personality-E": 6,
  "personality-A": 7,
  "personality-N": 4,
  "personality-O": 8,
  "personality-C": 6
}

Category strings must match encoder categories produced from your PARA PARA-UserInfo.csv.

Pip inference calls (4 examples)

1) GIAA mode pretrained on PARA

from unified_iaa import UnifiedIAA

m = UnifiedIAA.from_pretrained("stupidog04/Unified_IAA", device="cuda")  # or "cpu"
score = m.predict_giaa_prior(
    image="/path/to/image.jpg",
    task="GIAA",
    model="mir",
    backbone="vit_small_patch16_224",
)
print(score)

2) PIAA mode pretrained on PARA

from unified_iaa import UnifiedIAA

m = UnifiedIAA.from_pretrained("stupidog04/Unified_IAA", device="cuda")  # or "cpu"
score = m.predict_piaa(
    image="/path/to/image.jpg",
    demographics={
        "age": "30-34",
        "gender": "female",
        "EducationalLevel": "junior_college",
        "artExperience": "proficient",
        "photographyExperience": "proficient",
    },
    big5={
        "personality-E": 6,
        "personality-A": 7,
        "personality-N": 4,
        "personality-O": 8,
        "personality-C": 6,
    },
    task="PIAA",
    model="mir",
    backbone="vit_small_patch16_224",
)
print(score)

3) GIAA mode pretrained on LAPIS

from unified_iaa import UnifiedIAA

m = UnifiedIAA.from_pretrained("stupidog04/Unified_IAA", device="cuda")  # or "cpu"

lapis_input = {
    "nationality": "british",
    "demo_gender": "female",
    "demo_edu": "Bachelor's or equivalent",
    "demo_colorblind": "No",
    "age": "28-38",
    "VAIAK1": 3, "VAIAK2": 3, "VAIAK3": 3, "VAIAK4": 3, "VAIAK5": 3, "VAIAK6": 3, "VAIAK7": 3,
    "2VAIAK1": 3, "2VAIAK2": 3, "2VAIAK3": 3, "2VAIAK4": 3,
}

score = m.predict_lapis(
    image="/path/to/image.jpg",
    lapis_input=lapis_input,
    task="GIAA",
    model="mir",
    backbone="resnet50",
)
print(score)

4) PIAA mode pretrained on LAPIS

from unified_iaa import UnifiedIAA

m = UnifiedIAA.from_pretrained("stupidog04/Unified_IAA", device="cuda")  # or "cpu"

lapis_input = {
    "nationality": "british",
    "demo_gender": "female",
    "demo_edu": "Bachelor's or equivalent",
    "demo_colorblind": "No",
    "age": "28-38",
    "VAIAK1": 3, "VAIAK2": 3, "VAIAK3": 3, "VAIAK4": 3, "VAIAK5": 3, "VAIAK6": 3, "VAIAK7": 3,
    "2VAIAK1": 3, "2VAIAK2": 3, "2VAIAK3": 3, "2VAIAK4": 3,
}

score = m.predict_lapis(
    image="/path/to/image.jpg",
    lapis_input=lapis_input,
    task="PIAA",
    model="mir",
    backbone="resnet50",
)
print(score)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unified_iaa-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unified_iaa-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file unified_iaa-0.1.0.tar.gz.

File metadata

  • Download URL: unified_iaa-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for unified_iaa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2be03b8218d9ed73adcf4ddf60ab6a2de1f58986167ce53d8f22bb476c39b265
MD5 07dbf57e9d83070e966e9d758e91ef78
BLAKE2b-256 39116c112e66faed47828bce9676bfcd7e953294e95c24325174175d0a36f47e

See more details on using hashes here.

File details

Details for the file unified_iaa-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: unified_iaa-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for unified_iaa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 020685b8f22bc8cffa8bcb1a7803f5905d52c2e12cca76ca4a1a2789562ace4e
MD5 25734fa04fc6ed70b3dd0d1bef093c7f
BLAKE2b-256 da6ac5bcc1819b5eb61a10cc49c90271fc01ce03fd2b8cb703b9ad7fb33755dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page