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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is copied from
// https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform2/odml/mojom/mantis_processor.mojom
// Doc: go/mantis-bl-dd
module mantis.mojom;
// A specific error Mantis encountered when processing the request.
[Stable, Extensible]
enum MantisError {
[Default] kUnknownError,
[MinVersion=1] kProcessorNotInitialized,
[MinVersion=1] kInputError,
[MinVersion=1] kProcessFailed,
[MinVersion=2] kMissingSegmenter,
[MinVersion=3] kInputSafetyError,
[MinVersion=3] kOutputSafetyError,
[MinVersion=3] kPromptSafetyError,
};
// The result of image after processed by Mantis, or an error if any.
[Stable]
union MantisResult {
MantisError error;
array<uint8> result_image;
};
// This enum type identifies the result of Trust & Safety checking.
[Stable, Extensible]
enum SafetyClassifierVerdict {
kPass,
[Default] kFail,
[MinVersion=3] kFailedText,
[MinVersion=3] kFailedImage,
[MinVersion=4] kServiceNotAvailable,
[MinVersion=5] kNoInternetConnection,
};
// Struct that is used to represent a single point (x, y) in a
// stroke for use in e.g. handwriting recognition. (x, y) are coordinates
// in world space, with units in Density-Independent Pixels (DIP).
// The event fields are defined in:
// http://google3/third_party/sketchology/proto/scene_change.proto;l=123;rcl=693325121
[Stable]
struct TouchPoint {
float x@0;
float y@1;
};
// This enum type identifies the segmentation mode.
[Stable, Extensible]
enum SegmentationMode {
[Default] kScribble,
kLasso,
};
// Interface for processing images. The processor should already be initialized
// by `MantisService`.
//
// This interface is served by `odmld` process in CrOS to be used by image
// editing UI (e.g. Media App WebUI).
[Stable]
interface MantisProcessor {
// Inpaints the image based on the mask and seed. Pass the same `seed` across
// method calls to get identical result. The `image`, `mask`, and `result` are
// byte arrays containing the encoded format of an image (e.g., PNG, JPEG).
Inpainting@0(array<uint8> image, array<uint8> mask, uint32 seed)
=> (MantisResult result);
// Fills the image generatively based on the text and seed. Pass the same
// `seed` across method calls to get identical result. The `image`, `mask`,
// and `result` are byte arrays containing the encoded format of an image
// (e.g., PNG, JPEG).
GenerativeFill@1(
array<uint8> image, array<uint8> mask, uint32 seed, string prompt)
=> (MantisResult result);
// Performs image segmentation on the image based on the prior selection.
// The `image`, `prior`, and `result` are byte arrays containing the
// encoded format of an image (e.g., PNG, JPEG).
[MinVersion=1]
Segmentation@2(array<uint8> image, array<uint8> prior)
=> (MantisResult result);
// Classifies image for Trust & Safety checking.
[MinVersion=2]
ClassifyImageSafety@3(array<uint8> image)
=> (SafetyClassifierVerdict verdict);
// Outpaints the image based on the mask and seed. Pass the same `seed` across
// method calls to get identical result. The `image`, `mask`, and `result` are
// byte arrays containing the encoded format of an image (e.g., PNG, JPEG).
[MinVersion=6]
Outpainting@4(array<uint8> image, array<uint8> mask, uint32 seed)
=> (MantisResult result);
// Infers the segmentation mode (e.g., scribble or lasso) from a list of
// touch events.
[MinVersion=7]
InferSegmentationMode@5(array<TouchPoint> gesture)
=> (SegmentationMode mode);
};
|