Skip to content

Commit

Permalink
236- OV_model and CPU default device (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paula Ramos authored Feb 28, 2024
1 parent 438a552 commit 722bc1a
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"\n",
"device = widgets.Dropdown(\n",
" options=ie.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
Expand All @@ -165,11 +165,12 @@
"source": [
"from optimum.intel.openvino import OVStableDiffusionPipeline\n",
"\n",
"model_id = \"stabilityai/stable-diffusion-2-1-base\"\n",
"ov_pipe = OVStableDiffusionPipeline.from_pretrained(model_id, export=True, compile=False)\n",
"# download the pre-converted SD v2.1 model from Hugging Face Hub\n",
"name = \"helenai/stabilityai-stable-diffusion-2-1-base-ov\"\n",
"ov_pipe = OVStableDiffusionPipeline.from_pretrained(name, compile=False)\n",
"ov_pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)\n",
"ov_pipe.to(device.value)\n",
"ov_pipe.compile()\n"
"ov_pipe.compile()"
]
},
{
Expand Down Expand Up @@ -206,9 +207,12 @@
}
],
"source": [
"prompt = \"red car in snowy forest\"\n",
"output_ov = ov_pipe(prompt, num_inference_steps=17).images[0]\n",
"output_ov.save(\"image_ov_cpu.png\")\n",
"import gc\n",
"\n",
"# Generate an image. \n",
"prompt = \"red car in snowy forest, epic vista, beautiful landscape, 4k, 8k\"\n",
"output_ov = ov_pipe(prompt, num_inference_steps=17, output_type=\"pil\").images[0]\n",
"output_ov.save(\"image.png\")\n",
"output_ov"
]
},
Expand Down

0 comments on commit 722bc1a

Please sign in to comment.