diff --git a/notebooks/stable-diffusion-xl/segmind-vegart.ipynb b/notebooks/stable-diffusion-xl/segmind-vegart.ipynb index 89f1f2d3a48..dcce55d519e 100644 --- a/notebooks/stable-diffusion-xl/segmind-vegart.ipynb +++ b/notebooks/stable-diffusion-xl/segmind-vegart.ipynb @@ -427,6 +427,17 @@ "\n", "int8_pipe = None\n", "\n", + "core = ov.Core()\n", + "\n", + "def create_int8_pipe(model_dir, unet_int8_path, device, core, unet_device='CPU'):\n", + " int8_pipe = OVStableDiffusionXLPipeline.from_pretrained(model_dir, device=device, compile=True)\n", + " del int8_pipe.unet.request\n", + " del int8_pipe.unet.model\n", + " gc.collect()\n", + " int8_pipe.unet.model = core.read_model(unet_int8_path)\n", + " int8_pipe.unet.request = core.compile_model(int8_pipe.unet.model, unet_device or device)\n", + " return int8_pipe\n", + "\n", "if to_quantize.value and \"GPU\" in device.value:\n", " to_quantize.value = False\n", "42\n", @@ -635,15 +646,6 @@ "source": [ "%%skip not $to_quantize.value\n", "\n", - "def create_int8_pipe(model_dir, unet_int8_path, device, core, unet_device='CPU'):\n", - " int8_pipe = OVStableDiffusionXLPipeline.from_pretrained(model_dir, device=device, compile=True)\n", - " del int8_pipe.unet.request\n", - " del int8_pipe.unet.model\n", - " gc.collect()\n", - " int8_pipe.unet.model = core.read_model(unet_int8_path)\n", - " int8_pipe.unet.request = core.compile_model(int8_pipe.unet.model, unet_device or device)\n", - " return int8_pipe\n", - "\n", "int8_text2image_pipe = create_int8_pipe(model_dir, UNET_INT8_OV_PATH, device.value, core)\n", "\n", "\n", @@ -840,6 +842,8 @@ } ], "source": [ + "import ipywidgets as widgets\n", + "\n", "quantized_model_present = UNET_INT8_OV_PATH.exists()\n", "\n", "use_quantized_model = widgets.Checkbox(\n",