ci: automatic Python Formatter changes

This commit is contained in:
github-actions[bot] 2025-03-27 14:37:06 +00:00
parent bfd52423b7
commit 55b1c77ff8

View file

@ -2,12 +2,12 @@
Senju Image Recognition Module Senju Image Recognition Module
============================= =============================
A module providing image description generation capabilities for the Senju A module providing image description generation capabilities for the Senju
haiku application. haiku application.
This module leverages pre-trained vision-language models (specifically BLIP) This module leverages pre-trained vision-language models (specifically BLIP)
to generate to generate
textual descriptions of uploaded images. These descriptions can then be textual descriptions of uploaded images. These descriptions can then be
used as input used as input
for the haiku generation process, enabling image-to-haiku functionality. for the haiku generation process, enabling image-to-haiku functionality.
@ -46,12 +46,12 @@ from transformers import BlipProcessor, BlipForConditionalGeneration
class ImageDescriptionGenerator: class ImageDescriptionGenerator:
""" """
A class for generating textual descriptions of images using A class for generating textual descriptions of images using
a vision-language model. a vision-language model.
This class handles the loading of a pre-trained BLIP model, image This class handles the loading of a pre-trained BLIP model, image
preprocessing, and caption generation. It provides an interface for preprocessing, and caption generation. It provides an interface for
converting raw image data into natural language descriptions that can converting raw image data into natural language descriptions that can
be used for haiku inspiration. be used for haiku inspiration.
:ivar processor: The BLIP processor for handling image inputs :ivar processor: The BLIP processor for handling image inputs
@ -80,15 +80,15 @@ class ImageDescriptionGenerator:
""" """
Generate a descriptive caption for the given image. Generate a descriptive caption for the given image.
This method processes the raw image data, runs inference with This method processes the raw image data, runs inference with
the BLIP model, and returns a structured response with the the BLIP model, and returns a structured response with the
generated description. generated description.
:param image_data: Raw binary image data :param image_data: Raw binary image data
:type image_data: bytes :type image_data: bytes
:param max_length: Maximum token length for the generated caption :param max_length: Maximum token length for the generated caption
:type max_length: int :type max_length: int
:return: Dictionary containing the generated description and :return: Dictionary containing the generated description and
confidence score confidence score
:rtype: dict :rtype: dict
""" """
@ -127,12 +127,12 @@ def gen_response(image_data) -> dict:
""" """
Generate a description for an image using the global description generator. Generate a description for an image using the global description generator.
This function provides a simplified interface to the image This function provides a simplified interface to the image
description functionality for use in API endpoints. description functionality for use in API endpoints.
:param image_data: Raw binary image data :param image_data: Raw binary image data
:type image_data: bytes :type image_data: bytes
:return: Dictionary containing the image description and :return: Dictionary containing the image description and
confidence information confidence information
:rtype: dict :rtype: dict
:raises Exception: If image processing or description generation fails :raises Exception: If image processing or description generation fails