Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Cannot Create pipeline. #4

Closed
sakura6264 opened this issue Dec 23, 2022 · 3 comments
Closed

Cannot Create pipeline. #4

sakura6264 opened this issue Dec 23, 2022 · 3 comments
Assignees
Labels
bug Something isn't working p: high

Comments

@sakura6264
Copy link

pipeline::new return an error when I try to create pipeline.
the error is "invalid type: map, expected u32". (maybe something about the "diffusers.json" file)
I use the python script "h2pyke.py" convert a model.
here is the "diffusers.json" in the converted model: (I format it use vscode.)

{
    "pipeline": "stable-diffusion",
    "framework": "onnx",
    "tokenizer": {
        "type": "CLIPTokenizer",
        "path": "tokenizer.json",
        "model-max-length": 77,
        "bos-token": 49406,
        "eos-token": 49407
    },
    "feature-extractor": {
        "resample": 3,
        "size": {
            "shortest_edge": 224
        },
        "crop": [
            {
                "height": 224,
                "width": 224
            },
            {
                "height": 224,
                "width": 224
            }
        ],
        "crop-center": true,
        "rgb": true,
        "normalize": true,
        "resize": true,
        "image-mean": [
            0.48145466,
            0.4578275,
            0.40821073
        ],
        "image-std": [
            0.26862954,
            0.26130258,
            0.27577711
        ]
    },
    "text-encoder": {
        "path": "text_encoder.onnx"
    },
    "unet": {
        "path": "unet.onnx"
    },
    "vae": {
        "encoder": "vae_encoder.onnx",
        "decoder": "vae_decoder.onnx"
    },
    "hashes": {
        "text-encoder": "edf2f0ea013cd652905d00e50e89db1a",
        "unet": "ffbefc01413f4e2e1fb01ef8767d53d9",
        "vae-encoder": "9ceb9c41e1fee3c67f13e74c6e65570b",
        "vae-decoder": "a0c8bb5e2fe170feb647d38602db3a63",
        "safety-checker": "b88096c404ad8d6f52daba2995c87fe8"
    },
    "safety-checker": {
        "path": "safety_checker.onnx"
    }
}

My code is here:

let env = match OrtEnvironment::builder().with_name("Stable Diffusion").build() {
            Ok(e) => Arc::new(e),
            Err(e) => {
                simple_message_box::create_message_box(&format!("Cannot init ORT environment: {}", e), "Error");
                panic!("Cannot init ORT environment: {}", e);
            }
        };
        let scheduler = match DDIMScheduler::stable_diffusion_v1_optimized_default() {
            Ok(s) => Arc::new(s),
            Err(e) => {
                simple_message_box::create_message_box(&format!("Cannot init scheduler: {}", e), "Error");
                panic!("Cannot init scheduler: {}", e);
            }
        };
        let pipeline = match StableDiffusionPipeline::new(
            &env,
            "./models/",
            &StableDiffusionOptions::default()
        ) {
            Ok(p) => p,
            Err(e) => {
                simple_message_box::create_message_box(&format!("Cannot init pipeline: {}", e), "Error");
                panic!("Cannot init pipeline: {}", e);
            }
            
        };

And it panic with a message:"Cannot init pipeline: invalid type: map, expected u32".

@decahedron1 decahedron1 self-assigned this Dec 23, 2022
@decahedron1 decahedron1 added bug Something isn't working p: high labels Dec 23, 2022
@decahedron1
Copy link
Member

What model are you trying to use? I can't replicate the diffusers.json output from hf2pyke with SD 1.5 and diffusers==0.11.0.

@decahedron1
Copy link
Member

Could you try converting the model again using the updated hf2pyke script in 42ed0a0?

@sakura6264
Copy link
Author

The bug has been fixed. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working p: high
Projects
None yet
Development

No branches or pull requests

2 participants