stylsteer-vlm / src /methods /captionsmiths.py
abka03's picture
Deploy StyleSteer-VLM demo
e6f24ae verified
"""M1 — CaptionSmiths: Fine-tuned LLaVA-1.5 with structural style conditioning.
Uses published numbers only (CAPTIONSMITHS_USE_PUBLISHED=true).
Valid comparison for Track D only.
"""
from typing import Optional
import numpy as np
from src.methods.base import SteeringMethod
class CaptionSmiths(SteeringMethod):
"""CaptionSmiths — Fine-tuned baseline (ICCV 2025, Track D only)."""
def __init__(self, checkpoint_path: Optional[str] = None, use_published: bool = True, **kwargs):
self.checkpoint_path = checkpoint_path
self.use_published = use_published
@property
def name(self) -> str:
return "CaptionSmiths"
@property
def method_id(self) -> str:
return "M1"
@property
def is_training_free(self) -> bool:
return False
def extract_vector(
self,
h_pos: np.ndarray,
h_neg: np.ndarray,
**kwargs,
) -> Optional[np.ndarray]:
"""CaptionSmiths does not use activation steering — returns None."""
return None
def generate_caption(self, model, processor, image, style: str, **kwargs) -> str:
"""Generate a caption using the fine-tuned CaptionSmiths model.
If use_published=True, returns a placeholder indicating published
numbers should be used instead.
"""
if self.use_published:
return f"[PUBLISHED] CaptionSmiths published result for style={style}"
if self.checkpoint_path is None:
raise NotImplementedError(
"CaptionSmiths requires a checkpoint. "
"Set CAPTIONSMITHS_USE_PUBLISHED=true to use published numbers."
)
raise NotImplementedError("CaptionSmiths inference not yet implemented.")