# Copyright 2026 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0. See the LICENSE file in this repository. from diffusers.modular_pipelines import AutoPipelineBlocks, ModularPipeline, SequentialPipelineBlocks from diffusers.modular_pipelines.modular_pipeline_utils import InsertableDict, OutputParam # The remote-code loader only copies modules the entry module imports, so every module of this repository is named # here, including the ones only imported by others. from .components import JEVERATION_WEIGHTS_REPO from .decide import JeverationDecideStep from .decoders import JeverationDecodeStep, JeverationDensePostprocessStep, JeverationSourceDecodeStep from .dense import JeverationDensePredictStep from .encoders import JeverationDenseInputStep, JeverationImageInputStep, JeverationTextInputStep from .image_decoder_jeveration import JeverationImageDecoder # noqa: F401 from .prompts_jeveration import NYU13 # noqa: F401 from .transformer_jeveration import JeverationTransformer # noqa: F401 class JeverationText2ImageBlocks(SequentialPipelineBlocks): model_name = "jeveration" block_classes = [JeverationTextInputStep(), JeverationDecideStep(), JeverationDecodeStep()] block_names = ["text_input", "decide", "decode"] @property def description(self) -> str: return "Text-to-image: one forward pass decides the 128 codes of a 512 x 512 image, then the decoder draws it." @property def outputs(self): return [OutputParam("images", description="The generated images.")] class JeverationImage2ImageBlocks(SequentialPipelineBlocks): model_name = "jeveration" block_classes = [JeverationImageInputStep(), JeverationDecideStep(), JeverationSourceDecodeStep()] block_names = ["image_input", "decide", "decode"] @property def description(self) -> str: return ( "Image-to-image with one of the six trained tasks: edge map or depth map to image (`hed`, `depth`), " "`colorize`, or the `anime`, `ghibli` and `watercolor` styles." ) @property def outputs(self): return [OutputParam("images", description="The generated images.")] class JeverationDenseBlocks(SequentialPipelineBlocks): model_name = "jeveration" block_classes = [JeverationDenseInputStep(), JeverationDensePredictStep(), JeverationDensePostprocessStep()] block_names = ["dense_input", "predict", "postprocess"] @property def description(self) -> str: return "Dense prediction: indoor segmentation, depth and surface normals of a picture." @property def outputs(self): return [ OutputParam("predictions", description="Task -> the predicted maps."), OutputParam("prediction_images", description="Task -> pictures of the predictions."), ] JeverationBlocksDict = InsertableDict( [ ("dense", JeverationDenseBlocks()), ("image2image", JeverationImage2ImageBlocks()), ("text2image", JeverationText2ImageBlocks()), ] ) class JeverationBlocks(AutoPipelineBlocks): """Jeveration: text-to-image, image-to-image and dense prediction, each in one forward pass of one model.""" model_name = "jeveration" _requirements = {"diffusers": ">=0.41.0", "transformers": ">=5.14.0", "ftfy": ">=6.0"} block_classes = list(JeverationBlocksDict.values()) block_names = list(JeverationBlocksDict.keys()) block_trigger_inputs = ["dense_tasks", "image", None] def __init__(self): super().__init__() try: ModularPipeline.load_config(JEVERATION_WEIGHTS_REPO) except OSError: pass @property def description(self) -> str: return ( "Jeveration, a Qwen3.5-4B fine-tuned to answer in one forward pass. Pass `prompt` for " "text-to-image, `image` (+ `task`) for image-to-image, `image` + `dense_tasks` for dense prediction." )