MultimodalAnalyzer Pipeline

Bias analysis of image and text pairs.

1. Import:

from fairly import MultimodalAnalyzer

2. Initialize the Module:

multimodal_pipeline = MultimodalAnalyzer()

3. Format Image as PIL

# image formatting
from PIL import Image
img_path = "/content/random_person.jpg"
img = Image.open(img_path)

4. Run Multimodal Bias Analysis

result = multimodal_pipeline.analyze(text="Top 10 Smartest People Ever", image=img)

5. Example Output

{
    'text': 'Top 10 Smartest People Ever', 
    'image': <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1200x1499 at 0x7A82D0295360>, 
    'prob': 0.5121262669563293, 
    'label': 'Biased'
}

Last updated