File size: 690 Bytes
871ff87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Generation backend Protocol."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Protocol

from PIL import Image


@dataclass(frozen=True)
class GenerationResult:
    image: Image.Image
    backend: str
    model_id: str
    prompt: str
    negative_prompt: str | None
    seed: int
    num_inference_steps: int
    guidance_scale: float
    height: int
    width: int


class GenerationBackend(Protocol):
    name: str

    def load(self) -> None: ...

    def generate(
        self,
        *,
        prompt: str,
        negative_prompt: str | None,
        seed: int,
        height: int,
        width: int,
    ) -> GenerationResult: ...