mirror of
https://github.com/senju1337/senju.git
synced 2025-12-23 23:39:27 +00:00
ci: automatic Python Formatter changes
This commit is contained in:
parent
bfd52423b7
commit
55b1c77ff8
1 changed files with 11 additions and 11 deletions
|
|
@ -2,12 +2,12 @@
|
|||
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.
|
||||
|
||||
This module leverages pre-trained vision-language models (specifically BLIP)
|
||||
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
|
||||
for the haiku generation process, enabling image-to-haiku functionality.
|
||||
|
||||
|
|
@ -46,12 +46,12 @@ from transformers import BlipProcessor, BlipForConditionalGeneration
|
|||
|
||||
class ImageDescriptionGenerator:
|
||||
"""
|
||||
A class for generating textual descriptions of images using
|
||||
A class for generating textual descriptions of images using
|
||||
a vision-language model.
|
||||
|
||||
This class handles the loading of a pre-trained BLIP model, image
|
||||
preprocessing, and caption generation. It provides an interface for
|
||||
converting raw image data into natural language descriptions that can
|
||||
This class handles the loading of a pre-trained BLIP model, image
|
||||
preprocessing, and caption generation. It provides an interface for
|
||||
converting raw image data into natural language descriptions that can
|
||||
be used for haiku inspiration.
|
||||
|
||||
:ivar processor: The BLIP processor for handling image inputs
|
||||
|
|
@ -80,15 +80,15 @@ class ImageDescriptionGenerator:
|
|||
"""
|
||||
Generate a descriptive caption for the given image.
|
||||
|
||||
This method processes the raw image data, runs inference with
|
||||
the BLIP model, and returns a structured response with the
|
||||
This method processes the raw image data, runs inference with
|
||||
the BLIP model, and returns a structured response with the
|
||||
generated description.
|
||||
|
||||
:param image_data: Raw binary image data
|
||||
:type image_data: bytes
|
||||
:param max_length: Maximum token length for the generated caption
|
||||
:type max_length: int
|
||||
:return: Dictionary containing the generated description and
|
||||
:return: Dictionary containing the generated description and
|
||||
confidence score
|
||||
:rtype: dict
|
||||
"""
|
||||
|
|
@ -127,12 +127,12 @@ def gen_response(image_data) -> dict:
|
|||
"""
|
||||
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.
|
||||
|
||||
:param image_data: Raw binary image data
|
||||
:type image_data: bytes
|
||||
:return: Dictionary containing the image description and
|
||||
:return: Dictionary containing the image description and
|
||||
confidence information
|
||||
:rtype: dict
|
||||
:raises Exception: If image processing or description generation fails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue