Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perform this conversion from tensors #8

Open
github-actions bot opened this issue Nov 26, 2024 · 0 comments
Open

perform this conversion from tensors #8

github-actions bot opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels

Comments

@github-actions
Copy link

// TODO: perform this conversion from tensors

}


#[cfg(feature = "web")]
mod web {
    use std::cell::RefCell;

    use image::{
        DynamicImage,
        RgbImage,
        RgbaImage,
    };
    use wasm_bindgen::prelude::*;

    thread_local! {
        pub static SAMPLE_RECEIVER: RefCell<Option<RgbImage>> = RefCell::new(None);
    }

    #[wasm_bindgen]
    pub fn frame_input(pixel_data: &[u8], width: u32, height: u32) {
        let rgba_image = RgbaImage::from_raw(width, height, pixel_data.to_vec())
            .expect("failed to create RgbImage");

        // TODO: perform video element -> burn's webgpu texture conversion directly
        // TODO: perform this conversion from tensors
        let dynamic_image = DynamicImage::ImageRgba8(rgba_image);
        let rgb_image: RgbImage = dynamic_image.to_rgb8();

        SAMPLE_RECEIVER.with(|receiver| {
            *receiver.borrow_mut() = Some(rgb_image);
        });
    }
}


#[derive(Resource)]
struct DinoModel<B: Backend> {
    config: DinoVisionTransformerConfig,
    device: B::Device,
    model: Arc<Mutex<DinoVisionTransformer<B>>>,
}

#[derive(Resource)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant