pub enum Modality {
Text {
data: String,
controls: Option<Vec<TextControl>>,
},
Image {
data: String,
x: Option<i32>,
y: Option<i32>,
size: Option<i32>,
controls: Option<Vec<ImageControl>>,
},
TokenIds {
data: Vec<u32>,
controls: Option<Vec<TokenControl>>,
},
}
Expand description
The prompt for models can be a combination of different modalities (Text and Image). The type of modalities which are supported depend on the Model in question.
Variants§
Text
The only type of prompt which can be used with pure language models
Image
An image input into the model. See Modality::from_image_path
.
Fields
data: String
An image send as part of a prompt to a model. The image is represented as base64.
Note: The models operate on square images. All non-square images are center-cropped before going to the model, so portions of the image may not be visible.
You can supply specific cropping parameters if you like, to choose a different area of the image than a center-crop. Or, you can always transform the image yourself to a square before sending it.
controls: Option<Vec<ImageControl>>
TokenIds
Implementations§
Source§impl Modality
impl Modality
Sourcepub fn from_text(
text: impl Into<String>,
controls: Option<Vec<TextControl>>,
) -> Self
pub fn from_text( text: impl Into<String>, controls: Option<Vec<TextControl>>, ) -> Self
Instantiates a text prompt
Sourcepub fn from_token_ids(
ids: Vec<u32>,
controls: Option<Vec<TokenControl>>,
) -> Self
pub fn from_token_ids( ids: Vec<u32>, controls: Option<Vec<TokenControl>>, ) -> Self
Instantiates a token_ids prompt
pub fn from_image_path(path: impl AsRef<Path>) -> Result<Self, LoadImageError>
Sourcepub fn from_image(image: &DynamicImage) -> Result<Self, LoadImageError>
pub fn from_image(image: &DynamicImage) -> Result<Self, LoadImageError>
Image input for model
The model can only see squared pictures. Images are centercropped. You may want to use this
method instead of Self::from_image_path
in case you have the image in memory already
and do not want to load it from a file again.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Modality
impl RefUnwindSafe for Modality
impl Send for Modality
impl Sync for Modality
impl Unpin for Modality
impl UnwindSafe for Modality
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more