Bias Analysis¶
The module consists of APIs used to analyze the bias in text and images.
- analyze_text_for_bias(text_input, use_summarizer, progress=<gradio.helpers.Progress object>)[source]¶
Analyzes a given text for bias and provides a detailed analysis.
- Parameters:
- Returns:
A tuple containing the highlighted text with bias words and the detailed analysis.
- Return type:
Example
>>> highlighted, analysis = analyze_text_for_bias("This text may contain bias.", use_summarizer=True)
- analyze_image_for_bias(image, use_summarizer, progress=<gradio.helpers.Progress object>)[source]¶
Analyzes an image for bias by extracting text using OCR and by generating image caption.
- Parameters:
image (<module ‘PIL.Image’ from ‘/Users/mukundchettiar/Library/Caches/pypoetry/virtualenvs/fair-sense-ai-oZvE-iUE-py3.11/lib/python3.11/site-packages/PIL/Image.py’>) – The input image to analyze for bias.
use_summarizer (
bool
) – Whether to use the summarizer to condense the response.progress – A callback function to report progress.
- Returns:
A tuple containing the highlighted text with bias words and the detailed analysis.
- Return type:
Example
>>> image = Image.open("example.jpg") >>> highlighted, analysis = analyze_image_for_bias(image, use_summarizer=True)
- analyze_text_csv(file, use_summarizer, output_filename='analysis_results.csv')[source]¶
Analyzes a CSV file containing multiple text entries for bias.
- Parameters:
- Returns:
The HTML table containing results of batch analysis.
- Return type:
Examples
>>> csv_file = open("data.csv", mode='r', newline='', encoding='utf-8') >>> results_table_html = analyze_text_csv(csv_file, use_summarizer=True)
- analyze_images_batch(images, use_summarizer, output_filename='image_analysis_results.csv')[source]¶
Analyzes a batch of images for bias.
- Parameters:
- Returns:
The HTML table containing results of batch analysis.
- Return type:
Example
>>> results_table_html = analyze_images_batch(["image1.jpg", "image2.png"], use_summarizer=True)