-
Notifications
You must be signed in to change notification settings - Fork 0
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
Clean up VLMPipeline #68
Conversation
…olkit#916) To avoid confusions like openvinotoolkit#909 --------- Co-authored-by: Ravi Panchumarthy <[email protected]> Co-authored-by: Ekaterina Aidova <[email protected]>
Co-authored-by: Ilya Lavrenov <[email protected]>
Address comments in openvinotoolkit#912
); | ||
|
||
/// @brief Default destructor. | ||
~VLMPipeline(); | ||
|
||
/// @brief Generate a response given a prompt and any number of | ||
/// uint8 RGB images. | ||
/// uint8 RGB images with [HWC] layout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I pass NHWC, what will happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1HWC is actually expected. Should I enable both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose yes, maybe in PR with multiple images you can add support of NHWC ? where ov::Tensor represents multiple images and N > 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the latest Optimum from GitHub: https://github.com/huggingface/optimum.git Some example to try: ```sh # Export FP16 model optimum-cli export openvino -m SimianLuo/LCM_Dreamshaper_v7 --weight-format fp16 sd-lcm-fp16 # Export INT8 WOQ model optimum-cli export openvino -m SimianLuo/LCM_Dreamshaper_v7 --weight-format int8 sd-lcm-int8 # Collect the references wwb --base-model sd-lcm-fp16 --gt-data lcm_test/sd_xl.json --model-type sd-lcm # Compute the metric wwb --target-model sd-lcm-int8 --gt-data lcm_test/sd_xl.json --model-type sd-lcm ``` In addition you can compare vs. SD LCM quantized in a Hybrid quantization mode as follows: ```python import time import datasets import matplotlib.pyplot as plt import numpy as np import transformers from pathlib import Path from openvino.runtime import Core from optimum.intel import OVConfig, OVQuantizer, OVStableDiffusionPipeline, OVWeightQuantizationConfig, OVLatentConsistencyModelPipeline from optimum.intel.openvino.configuration import OVQuantizationMethod transformers.logging.set_verbosity_error() datasets.logging.set_verbosity_error() MODEL_ID = "SimianLuo/LCM_Dreamshaper_v7" DATASET_NAME = "jxie/coco_captions" base_model_path = Path(f"models/{MODEL_ID}") fp32_model_path = base_model_path.with_name(base_model_path.name + "_FP32") int8_model_path = base_model_path.with_name("sd-lcm-int8") dataset = datasets.load_dataset(DATASET_NAME, split="train", streaming=True).shuffle(seed=42) print(next(iter(dataset))) def preprocess_fn(example): return {"prompt": example["caption"]} NUM_SAMPLES = 200 dataset = dataset.take(NUM_SAMPLES) calibration_dataset = dataset.map(lambda x: preprocess_fn(x), remove_columns=dataset.column_names) int8_pipe = OVLatentConsistencyModelPipeline.from_pretrained(model_id=MODEL_ID, export=True) quantization_config = OVWeightQuantizationConfig(bits=8, num_samples=NUM_SAMPLES, quant_method=OVQuantizationMethod.HYBRID) quantizer = OVQuantizer(int8_pipe) quantizer.quantize( ov_config=OVConfig(quantization_config=quantization_config), calibration_dataset=calibration_dataset, save_directory=int8_model_path ) ``` And use compute the metric the same way: ```sh wwb --target-model sd-lcm-int8 --gt-data lcm_test/sd_xl.json --model-type sd-lcm ```
Ticket 144955, CVS-153301 --------- Co-authored-by: wenyi5608 <[email protected]> Co-authored-by: Yang,Su <[email protected]> Co-authored-by: Yaroslav Tarkan <[email protected]> Co-authored-by: Alina Kladieva <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Artur Paniukov <[email protected]> Co-authored-by: Ekaterina Aidova <[email protected]> Co-authored-by: Ilya Lavrenov <[email protected]> Co-authored-by: Mikhail Ryzhov <[email protected]>
… for text_encoder
Fixed compilation
- Added VLM bindings. - Added Python VLM chat sample. - Added initialization of performance metrics with zeros. Tickets: CVS-153174, CVS-153173, CVS-153626 PR to miniCPM-V-2_6 branch: #62 --------- Co-authored-by: wenyi5608 <[email protected]> Co-authored-by: Yang,Su <[email protected]> Co-authored-by: Wovchena <[email protected]> Co-authored-by: Yaroslav Tarkan <[email protected]> Co-authored-by: Alina Kladieva <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Artur Paniukov <[email protected]> Co-authored-by: Ekaterina Aidova <[email protected]> Co-authored-by: Ilya Lavrenov <[email protected]> Co-authored-by: Mikhail Ryzhov <[email protected]>
TODO: - [ ] Remove `ov::Core` from constructors. - [ ] Hide files and API. --------- Co-authored-by: wenyi5608 <[email protected]> Co-authored-by: Yang,Su <[email protected]> Co-authored-by: Yaroslav Tarkan <[email protected]> Co-authored-by: Alina Kladieva <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Pavel Esir <[email protected]> Co-authored-by: Artur Paniukov <[email protected]> Co-authored-by: Ekaterina Aidova <[email protected]> Co-authored-by: Ilya Lavrenov <[email protected]> Co-authored-by: Mikhail Ryzhov <[email protected]>
Can be closed |
Address comments in openvinotoolkit#912