e98493bcfb
- imagegen.EditRequest.Mask -> sd-server img2img inpainting (white=repaint) - imagegen.Upscaler + BackgroundRemover, videogen.Interpolator, audio.DiarizationModel: new optional provider-minted surfaces - NEW meshgen leaf package (image->3D, glb/stl/obj) - provider/llamaswap: all five via the /upstream/<model>/<path> passthrough (upstreamPath helper, shared one-file multipart builder); binary success bodies validated (non-image, non-video, JSON-mesh rejection); diarization pins output=json (vtt/srt drop speaker labels) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
package imagegen
|
|
|
|
import "context"
|
|
|
|
// UpscaleRequest asks a super-resolution backend to enlarge an image. Zero
|
|
// values mean "backend default", mirroring EditRequest (ADR-0020).
|
|
type UpscaleRequest struct {
|
|
// Image is the image to upscale. Required.
|
|
Image Image
|
|
|
|
// Scale is the enlargement factor (2 or 4 on the reference backend);
|
|
// 0 = backend default.
|
|
Scale int
|
|
}
|
|
|
|
// UpscaleOption mutates an UpscaleRequest before it is sent.
|
|
type UpscaleOption func(*UpscaleRequest)
|
|
|
|
// WithUpscaleScale sets the enlargement factor.
|
|
func WithUpscaleScale(s int) UpscaleOption { return func(r *UpscaleRequest) { r.Scale = s } }
|
|
|
|
// Apply returns a copy of the request with all options applied.
|
|
func (r UpscaleRequest) Apply(opts ...UpscaleOption) UpscaleRequest {
|
|
for _, opt := range opts {
|
|
opt(&r)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// Upscaler enlarges images with a super-resolution model. It is its own
|
|
// small interface (not a method on Model) because upscalers are not
|
|
// diffusion models — they bind to a different backend id entirely.
|
|
type Upscaler interface {
|
|
// Upscale returns the enlarged image (a one-image Result).
|
|
Upscale(ctx context.Context, req UpscaleRequest, opts ...UpscaleOption) (*Result, error)
|
|
}
|
|
|
|
// UpscaleModelOption configures an Upscaler at construction time. Reserved
|
|
// for future per-model settings (mirrors ModelOption).
|
|
type UpscaleModelOption func(*UpscaleModelConfig)
|
|
|
|
// UpscaleModelConfig carries per-model construction settings.
|
|
type UpscaleModelConfig struct{}
|
|
|
|
// ApplyUpscaleModelOptions folds options into a config.
|
|
func ApplyUpscaleModelOptions(opts []UpscaleModelOption) UpscaleModelConfig {
|
|
var cfg UpscaleModelConfig
|
|
for _, opt := range opts {
|
|
opt(&cfg)
|
|
}
|
|
return cfg
|
|
}
|
|
|
|
// UpscaleProvider mints Upscalers bound to one backend.
|
|
type UpscaleProvider interface {
|
|
// Name is the registry identifier for the provider.
|
|
Name() string
|
|
|
|
// UpscaleModel returns an Upscaler bound to the given id (passed through
|
|
// to the backend verbatim; no catalog validation).
|
|
UpscaleModel(id string, opts ...UpscaleModelOption) (Upscaler, error)
|
|
}
|