Buckets:

mishig's picture
|
download
raw
3.08 kB
# OpenVINO
๐Ÿค— [Optimum](https://github.com/huggingface/optimum-intel)์€ ๋‹ค์–‘ํ•œ Intel ํ”„๋กœ์„ธ์„œ์—์„œ ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” OpenVINO์™€ ํ˜ธํ™˜๋˜๋Š” Stable Diffusion ํŒŒ์ดํ”„๋ผ์ธ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค(์ง€์›๋˜๋Š” ์žฅ์น˜์˜ [์ „์ฒด ๋ชฉ๋ก](https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html)์„ ์ฐธ์กฐํ•˜์„ธ์š”).
`--upgrade-strategy eager` ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๐Ÿค— Optimum Intel์„ ์„ค์น˜ํ•ด์•ผ [`optimum-intel`](https://github.com/huggingface/optimum-intel)์ด ์ตœ์‹  ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
```bash
pip install --upgrade-strategy eager optimum["openvino"]
```
์ด ๊ฐ€์ด๋“œ์—์„œ๋Š” OpenVINO์™€ ํ•จ๊ป˜ Stable Diffusion ๋ฐ Stable Diffusion XL (SDXL) ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.
## Stable Diffusion
๋กœ๋“œ ๋ฐ ์ถ”๋ก  ์‹คํ–‰์„ ์œ„ํ•ด `OVStableDiffusionPipeline`์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. PyTorch ๋ชจ๋ธ์„ ๋กœ๋“œํ•˜์—ฌ OpenVINO ํ˜•์‹์œผ๋กœ ์ฆ‰์‹œ ๋ณ€ํ™˜ํ•˜๋ ค๋ฉด `export=True`๋ฅผ ์„ค์ •ํ•˜์„ธ์š”:
```python
from optimum.intel import OVStableDiffusionPipeline
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipeline = OVStableDiffusionPipeline.from_pretrained(model_id, export=True)
prompt = "sailing ship in storm by Rembrandt"
image = pipeline(prompt).images[0]
# Don't forget to save the exported model
pipeline.save_pretrained("openvino-sd-v1-5")
```
์ถ”๋ก  ์†๋„๋ฅผ ๋” ๋†’์ด๊ธฐ ์œ„ํ•ด ๋ชจ๋ธ์„ ์ •์ ์œผ๋กœ ๋ฆฌ์…ฐ์ดํ”„ํ•ฉ๋‹ˆ๋‹ค. ์ถœ๋ ฅ ๋†’์ด ๋˜๋Š” ๋„ˆ๋น„์™€ ๊ฐ™์€ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ณ€๊ฒฝํ•˜๋ฉด ๋ชจ๋ธ์„ ๋‹ค์‹œ ์ •์ ์œผ๋กœ ๋ฆฌ์…ฐ์ดํ”„ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
```python
# Define the shapes related to the inputs and desired outputs
batch_size, num_images, height, width = 1, 1, 512, 512
# Statically reshape the model
pipeline.reshape(batch_size, height, width, num_images)
# Compile the model before inference
pipeline.compile()
image = pipeline(
prompt,
height=height,
width=width,
num_images_per_prompt=num_images,
).images[0]
```
๐Ÿค— Optimum [๋ฌธ์„œ](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion)์—์„œ ๋” ๋งŽ์€ ์˜ˆ์‹œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ, Stable Diffusion์€ ํ…์ŠคํŠธ-์ด๋ฏธ์ง€ ์ƒ์„ฑ, ์ด๋ฏธ์ง€-์ด๋ฏธ์ง€ ๋ณ€ํ™˜, ์ธํŽ˜์ธํŒ…์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
## Stable Diffusion XL
SDXL๋กœ ๋กœ๋“œํ•˜๊ณ  ์ถ”๋ก ์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด `OVStableDiffusionXLPipeline`์„(๋ฅผ) ์‚ฌ์šฉํ•˜์„ธ์š”:
```python
from optimum.intel import OVStableDiffusionXLPipeline
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id)
prompt = "sailing ship in storm by Rembrandt"
image = pipeline(prompt).images[0]
```
์ถ”๋ก  ์†๋„๋ฅผ ๋” ๋†’์ด๊ธฐ ์œ„ํ•ด, Stable Diffusion ์„น์…˜์— ๋‚˜์™€ ์žˆ๋“ฏ์ด ๋ชจ๋ธ์„ [์ •์ ์œผ๋กœ ๋ฆฌ์‚ฌ์ด์ฆˆ](#stable-diffusion)ํ•ฉ๋‹ˆ๋‹ค.
๐Ÿค— Optimum [๋ฌธ์„œ](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl)์—์„œ ๋” ๋งŽ์€ ์˜ˆ์‹œ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, OpenVINO์—์„œ SDXL์„ ์‹คํ–‰ํ•˜๋Š” ๊ธฐ๋Šฅ์€ ํ…์ŠคํŠธ-์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋ฐ ์ด๋ฏธ์ง€-์ด๋ฏธ์ง€ ๋ณ€ํ™˜์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

Xet Storage Details

Size:
3.08 kB
ยท
Xet hash:
375bfa95a629c2ec20bafdf593dd0bad2767329dcfeee746d2cfcd428dcc3dda

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.