5 unstable releases

0.3.2 Aug 14, 2024
0.3.0 Aug 13, 2024
0.2.1 Feb 28, 2024
0.2.0 Feb 18, 2024
0.1.0 Dec 16, 2023

#485 in Images

Download history 10/week @ 2024-07-28 246/week @ 2024-08-11 22/week @ 2024-08-18 7/week @ 2024-08-25 3/week @ 2024-09-01 5/week @ 2024-09-08 145/week @ 2024-09-15 82/week @ 2024-09-22 89/week @ 2024-09-29 46/week @ 2024-10-06 69/week @ 2024-10-13 31/week @ 2024-10-20 44/week @ 2024-10-27 32/week @ 2024-11-03 16/week @ 2024-11-10

128 downloads per month
Used in kalosm

MIT/Apache

145KB
1.5K SLoC

Kalosm Vision

Kalosm Vision is a collection of image models and utilities for the Kalosm framework. It includes utilities for generating images from text and segmenting images into objects.

Image Generation

You can use the Wuerstchen model to generate images from text:

use futures_util::StreamExt;
use kalosm_vision::{Wuerstchen, WuerstchenInferenceSettings};

#[tokio::main]
async fn main() {
    let model = Wuerstchen::builder().build().await.unwrap();
    let settings = WuerstchenInferenceSettings::new(
        "a cute cat with a hat in a room covered with fur with incredible detail",
    );

    if let Ok(mut images) = model.run(settings) {
        while let Some(image) = images.next().await {
            if let Some(buf) = image.generated_image() {
                buf.save(&format!("{}.png", image.sample_num())).unwrap();
            }
        }
    }
}

Image Segmentation

Kalosm supports image segmentation with the SegmentAnything model. You can use the SegmentAnything::segment_everything method to segment an image into objects or the SegmentAnything::segment_from_points method to segment an image into objects at specific points:

use kalosm::vision::*;

let model = SegmentAnything::builder().build().unwrap();
let image = image::open("examples/landscape.jpg").unwrap();
let x = image.width() / 2;
let y = image.height() / 4;
let images = model
    .segment_from_points(
        SegmentAnythingInferenceSettings::new(image)
            .unwrap()
            .add_goal_point(x, y),
    )
    .unwrap();

images.save("out.png").unwrap();

Dependencies

~35–53MB
~1M SLoC