P-H3-Image

Pruna's image model built on MiniMax H3, eight steps to an 8-megapixel image, no classifier-free guidance. It expands your prompt into the full prompt the model renders best and returns it with the result, so you can read what the image model was actually given. Strongest at photorealism, film and editorial looks, and graphic styles with short quoted text.

Image generationrtx-pro-6000Pruna AIMiniMax H3 community licensePrunaAI/P-H3-Image

What runs

This is the whole app. The entry names the model and what serves it, and the build turns that into these files: there is nothing else to write.

model.py
"""P-H3-Image, generated from a declarative template."""

from __future__ import annotations

import base64
import io
from typing import Literal

from pydantic import BaseModel, ConfigDict, Field

from runware_serverless import serve

MODEL = "PrunaAI/P-H3-Image"
REVISION = "7f98acef503cf2bcfba821a78cb1cf1a9928b2df"
CACHE = "/weights"

SIZES = {
    "1:1": (2912, 2912),
    "4:3": (3360, 2496),
    "3:4": (2496, 3360),
    "3:2": (3552, 2368),
    "2:3": (2368, 3552),
    "16:9": (3872, 2176),
    "9:16": (2176, 3872),
}
"""The 8-megapixel sizes the model card recommends. Offered as a ratio rather
than a width and a height because the model is tuned at these, and the card
reports artifacts in faces and hands below them."""

WARMUP = SIZES["1:1"]


class Request(BaseModel):
    # An input this model does not read is a line the caller believed was doing
    # something, so it is refused rather than dropped. Without this, pydantic
    # ignores it: a width sent to a model of fixed size, or a misspelled seed,
    # both come back as a result that silently answered a different request.
    model_config = ConfigDict(extra="forbid")

    prompt: str = Field(
        description=(
            "What to generate. A short request is enough: the pipeline expands it into a full"
            " prompt before the image model reads it."
        ),
    )
    aspect: Literal["1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16"] = Field(
        default="1:1",
        description="Which of the model's 8-megapixel sizes to generate.",
    )
    seed: int | None = Field(default=None, description="Repeat a result by repeating its seed.")

    # No step count. The schedule is the checkpoint's own 9-entry sigma grid,
    # which is 8 steps, and the pipeline takes a replacement grid rather than a
    # number: anything else is a strictly decreasing list ending at zero, which
    # is not a knob to hand a caller.


class Generated(BaseModel):
    # JPEG and not PNG, which is what every other image entry here returns. At 8
    # megapixels a PNG is tens of megabytes, and this is a response body rather
    # than a file on disk.
    image: str = Field(description="The result as a base64 JPEG.")
    caption: str = Field(
        description="The full prompt the upsampler wrote, which is what the image model read.",
    )
    aspect: str
    seed: int | None


@serve
class GeneratedImage:
    def load(self) -> None:
        if hasattr(self, "pipeline"):
            return

        # Imported here rather than at the top of the file. The build imports
        # this file with the platform's own dependencies, so nothing above
        # exists until a worker runs.
        import torch
        from diffusers import ModularPipeline

        self.torch = torch

        # Two calls rather than one. from_pretrained builds the pipeline without
        # reading any weights, and load_components is what fetches them, so a
        # failure to resolve the repository and a failure to load it are
        # separate and report separately.
        self.pipeline = ModularPipeline.from_pretrained(
            MODEL, revision=REVISION, cache_dir=CACHE
        )

        from diffusers import MiniMaxH3Transformer3DModel, TorchAoConfig
        from transformers import Qwen3VLForConditionalGeneration
        from transformers import TorchAoConfig as TransformersTorchAoConfig
        from torchao.quantization import Int8WeightOnlyConfig

        self.pipeline.update_components(
            transformer=MiniMaxH3Transformer3DModel.from_pretrained(
                MODEL,
                subfolder="transformer",
                revision=REVISION,
                cache_dir=CACHE,
                dtype=torch.bfloat16,
                device_map="cuda",
                quantization_config=TorchAoConfig(
                    Int8WeightOnlyConfig(version=2),
                    modules_to_not_convert=[
                        "proj_in",
                        "audio_proj_in",
                        "context_embedder",
                        "time_embedder",
                        "time_proj",
                        "token_refiner",
                        "norm_out",
                        "proj_out",
                        "audio_proj_out",
                    ],
                ),
            ),
            text_encoder=Qwen3VLForConditionalGeneration.from_pretrained(
                MODEL,
                subfolder="text_encoder",
                revision=REVISION,
                cache_dir=CACHE,
                dtype=torch.bfloat16,
                device_map="cuda",
                quantization_config=TransformersTorchAoConfig(
                    Int8WeightOnlyConfig(version=2),
                    modules_to_not_convert=[
                        "model.visual",
                        "model.language_model.embed_tokens",
                        "model.language_model.norm",
                        "lm_head",
                    ],
                ),
            ),
        )
        # Every component lands on the card as it loads. Host RAM is half the
        # card's VRAM, so a pipeline assembled on the host and moved has a
        # ceiling well below the card's, and the kill arrives as the container's
        # exit 137 rather than as a CUDA error.
        self.pipeline.load_components(dtype=torch.bfloat16, device_map="cuda")

        # At a real size, because the canvas has a four-megapixel floor and a
        # token-cheap warmup would exercise a path no request takes. It moves a
        # failure into the readiness check, where it is reported, rather than
        # into somebody's first call.
        self.pipeline(
            prompt="warmup",
            width=WARMUP[0],
            height=WARMUP[1],
            output="images",
        )

    def predict(self, request: Request) -> Generated:
        generator = None
        if request.seed is not None:
            generator = self.torch.Generator().manual_seed(request.seed)

        width, height = SIZES[request.aspect]

        # A modular pipeline returns its whole state and you name what you want
        # out of it, rather than an object with an images attribute.
        result = self.pipeline(
            prompt=request.prompt,
            width=width,
            height=height,
            generator=generator,
            output=["images", "prompt"],
        )
        image = result["images"][0]
        caption = result["prompt"]

        buffer = io.BytesIO()
        image.save(buffer, format="JPEG", quality=95)

        return Generated(
            image=base64.b64encode(buffer.getvalue()).decode("ascii"),
            caption=caption,
            aspect=request.aspect,
            seed=request.seed,
        )
runware.yaml
configVersion: 1
id: p-h3-image
name: P-H3-Image
source:
  type: code
  entry: model.py
compute:
  gpuType: rtx-pro-6000
build:
  requirements:
    - torch==2.14.1
    - torchvision==0.29.1
    - diffusers @
      git+https://github.com/huggingface/diffusers@8c54b38fea3d624d23d0e43c0c96037f080a79f9
    - transformers==5.22.2
    - accelerate==1.15.0
    - torchao==0.18.0
    - pillow==13.0.0
  baseImage: python:3.12
volumes:
  - /weights

Deploying

Deploy it as it is, or take the files above and deploy your own copy. Nothing you change reaches back to this page.

p-h3-imagertx-pro-6000source
From a URL
runware serverless deploy --from https://runware.ai/docs/serverless/examples/p-h3-image.zip
From a clone
runware serverless deploy model.py \
  --id p-h3-image \
  --gpu-type rtx-pro-6000 \
  --base-image python:3.12 \
  --requirement torch==2.14.1 \
  --requirement torchvision==0.29.1 \
  --requirement diffusers @ git+https://github.com/huggingface/diffusers@8c54b38fea3d624d23d0e43c0c96037f080a79f9 \
  --requirement transformers==5.22.2 \
  --requirement accelerate==1.15.0 \
  --requirement torchao==0.18.0 \
  --requirement pillow==13.0.0 \
  --volume /weights

Calling it

One request that works, against the app you just deployed. The fields are the ones the entry declares above, and anything it does not declare is refused rather than ignored.

import { createClient } from '@runware/sdk'

const client = await createClient({ apiKey: process.env.RUNWARE_API_KEY })

const task = await client.invoke({
  appId: 'p-h3-image',
  endpointPath: 'predict',
  payload: {
    request: {
      prompt: 'A paper boat drifting down a rain gutter, close up'
    }
  }
})
import asyncio
import os

from runware import Runware


async def main():
    client = Runware(api_key=os.environ["RUNWARE_API_KEY"])
    try:
        task = await client.invoke(
            "p-h3-image",
            "predict",
            {
                "request": {
                    "prompt": "A paper boat drifting down a rain gutter, close up"
                }
            },
        )
    finally:
        await client.close()


asyncio.run(main())
curl https://api.serverless.runware.ai/v1/apps/p-h3-image/invoke-async/predict \
  -H "Authorization: Bearer $RUNWARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "taskId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "payload": {
      "request": {
        "prompt": "A paper boat drifting down a rain gutter, close up"
      }
    }
  }'
cat <<'EOF' | runware serverless apps invoke p-h3-image predict -f -
{
  "request": {
    "prompt": "A paper boat drifting down a rain gutter, close up"
  }
}
EOF
{
  "taskId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "payload": {
    "request": {
      "prompt": "A paper boat drifting down a rain gutter, close up"
    }
  }
}

What it costs

This entry is pinned to rtx-pro-6000, which is the card it was tested on rather than the only one it runs on: --gpu-typedeploys it somewhere else. You pay for that card by the second while a worker holds it, and for nothing else. Pricing covers what meters, and the rates are published per GPU-second.