bob_sd35.itti_node ================== .. py:module:: bob_sd35.itti_node Classes ------- .. autoapisummary:: bob_sd35.itti_node.ITTINode Functions --------- .. autoapisummary:: bob_sd35.itti_node.main Module Contents --------------- .. py:class:: ITTINode Bases: :py:obj:`rclpy.node.Node` Text & image to image generator node. .. py:attribute:: _pipe :value: None .. py:attribute:: _cv_bridge .. py:attribute:: _prompt_sub .. py:attribute:: _image_pub .. py:method:: _prompt_callback(msg: std_msgs.msg.String) Callback for incoming prompt messages. Parses JSON if message contains 'role' key, otherwise uses message as prompt. .. py:method:: _publish_image(pil_image: PIL.Image.Image) Publishes a PIL Image as a ROS Image message if there are subscribers. .. py:method:: load_model() Downloads the model if necessary and loads the SD3.5 Img2Img pipeline. Returns the loaded pipeline. .. py:method:: generate_image(prompt: str, input_image_path: str, output_path: str) -> PIL.Image.Image | None Generates an image based on text prompt and an input image. Args: prompt: The text prompt describing the desired output. input_image_path: Path to the input image file. output_path: Path where the output image will be saved. Returns: The generated PIL Image if successful, None otherwise. .. py:method:: unload_model() Unloads the model from memory to free VRAM. .. py:method:: _generate_auto_filename(output_path: str) -> str Generates a unique filename when output_path ends with 'auto'. If output_path is 'auto' or ends with '/auto', generates a filename with pattern: itti_<4-digit-counter>_<8-char-random>.png Args: output_path: The output path parameter value. Returns: The generated unique filename, or original path if not 'auto'. .. py:method:: _run_generation() Runs the image generation using the configured parameters. If 'once' is True, shuts down the node after generation. .. py:method:: _schedule_shutdown(success: bool = True) Schedules a shutdown after keep_alive seconds using a ROS2 timer. This is non-blocking and allows the executor to continue processing. .. py:method:: _shutdown_callback() Timer callback that triggers the shutdown. .. py:function:: main(args=None)