File size: 5,441 Bytes
ffead1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!--Copyright 2023 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# ์„ค์น˜

์‚ฌ์šฉํ•˜์‹œ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋งž๋Š” ๐Ÿค— Diffusers๋ฅผ ์„ค์น˜ํ•˜์„ธ์š”.

๐Ÿค— Diffusers๋Š” Python 3.7+, PyTorch 1.7.0+ ๋ฐ flax์—์„œ ํ…Œ์ŠคํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ค‘์ธ ๋”ฅ๋Ÿฌ๋‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋Œ€ํ•œ ์•„๋ž˜์˜ ์„ค์น˜ ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”.

- [PyTorch ์„ค์น˜ ์•ˆ๋‚ด](https://pytorch.org/get-started/locally/)
- [Flax ์„ค์น˜ ์•ˆ๋‚ด](https://flax.readthedocs.io/en/latest/)

## pip๋ฅผ ์ด์šฉํ•œ ์„ค์น˜

[๊ฐ€์ƒ ํ™˜๊ฒฝ](https://docs.python.org/3/library/venv.html)์— ๐Ÿค— Diffusers๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
Python ๊ฐ€์ƒ ํ™˜๊ฒฝ์— ์ต์ˆ™ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ [๊ฐ€์ƒํ™˜๊ฒฝ pip ์„ค์น˜ ๊ฐ€์ด๋“œ](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)๋ฅผ ์‚ดํŽด๋ณด์„ธ์š”.
๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ์‚ฌ์šฉํ•˜๋ฉด ์„œ๋กœ ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ๋ฅผ ๋” ์‰ฝ๊ฒŒ ๊ด€๋ฆฌํ•˜๊ณ , ์ข…์†์„ฑ๊ฐ„์˜ ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ๋ฅผ ํ”ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ์— ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์‹œ์ž‘ํ•˜์„ธ์š”:

```bash
python -m venv .env
```

๊ทธ๋ฆฌ๊ณ  ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค:

```bash
source .env/bin/activate
```

์ด์ œ ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋กœ ๐Ÿค— Diffusers๋ฅผ ์„ค์น˜ํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:

**PyTorch์˜ ๊ฒฝ์šฐ**

```bash
pip install diffusers["torch"]
```

**Flax์˜ ๊ฒฝ์šฐ**

```bash
pip install diffusers["flax"]
```

## ์†Œ์Šค๋กœ๋ถ€ํ„ฐ ์„ค์น˜

์†Œ์Šค์—์„œ `diffusers`๋ฅผ ์„ค์น˜ํ•˜๊ธฐ ์ „์—, `torch` ๋ฐ `accelerate`์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

`torch` ์„ค์น˜์— ๋Œ€ํ•ด์„œ๋Š” [torch docs](https://pytorch.org/get-started/locally/#start-locally)๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

๋‹ค์Œ๊ณผ ๊ฐ™์ด `accelerate`์„ ์„ค์น˜ํ•˜์„ธ์š”.

```bash
pip install accelerate
```

๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์†Œ์Šค์—์„œ ๐Ÿค— Diffusers๋ฅผ ์„ค์น˜ํ•˜์„ธ์š”:

```bash
pip install git+https://github.com/huggingface/diffusers
```

์ด ๋ช…๋ น์–ด๋Š” ์ตœ์‹  `stable` ๋ฒ„์ „์ด ์•„๋‹Œ ์ตœ์ฒจ๋‹จ `main` ๋ฒ„์ „์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
`main` ๋ฒ„์ „์€ ์ตœ์‹  ๊ฐœ๋ฐœ ์ •๋ณด๋ฅผ ์ตœ์‹  ์ƒํƒœ๋กœ ์œ ์ง€ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด ๋งˆ์ง€๋ง‰ ๊ณต์‹ ๋ฆด๋ฆฌ์ฆˆ ์ดํ›„ ๋ฒ„๊ทธ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์ง€๋งŒ, ์ƒˆ ๋ฆด๋ฆฌ์ฆˆ๊ฐ€ ์•„์ง ์ถœ์‹œ๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ ์ด๋Š” `main` ๋ฒ„์ „์ด ํ•ญ์ƒ ์•ˆ์ •์ ์ด์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.
์šฐ๋ฆฌ๋Š” `main` ๋ฒ„์ „์ด ์ง€์†์ ์œผ๋กœ ์ž‘๋™ํ•˜๋„๋ก ๋…ธ๋ ฅํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ๋Œ€๋ถ€๋ถ„์˜ ๋ฌธ์ œ๋Š” ๋ณดํ†ต ๋ช‡ ์‹œ๊ฐ„ ๋˜๋Š” ํ•˜๋ฃจ ์•ˆ์— ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค.
๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ๋” ๋นจ๋ฆฌ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋„๋ก [Issue](https://github.com/huggingface/transformers/issues)๋ฅผ ์—ด์–ด์ฃผ์„ธ์š”!


## ํŽธ์ง‘๊ฐ€๋Šฅํ•œ ์„ค์น˜

๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด ํŽธ์ง‘๊ฐ€๋Šฅํ•œ ์„ค์น˜๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

* ์†Œ์Šค ์ฝ”๋“œ์˜ `main` ๋ฒ„์ „์„ ์‚ฌ์šฉ
* ๐Ÿค— Diffusers์— ๊ธฐ์—ฌ (์ฝ”๋“œ์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”)

์ €์žฅ์†Œ๋ฅผ ๋ณต์ œํ•˜๊ณ  ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๐Ÿค— Diffusers๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:

```bash
git clone https://github.com/huggingface/diffusers.git
cd diffusers
```

**PyTorch์˜ ๊ฒฝ์šฐ**

```
pip install -e ".[torch]"
```

**Flax์˜ ๊ฒฝ์šฐ**

```
pip install -e ".[flax]"
```

์ด๋Ÿฌํ•œ ๋ช…๋ น์–ด๋“ค์€ ์ €์žฅ์†Œ๋ฅผ ๋ณต์ œํ•œ ํด๋”์™€ Python ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ฒฝ๋กœ๋ฅผ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค.
Python์€ ์ด์ œ ์ผ๋ฐ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ฒฝ๋กœ์— ๋”ํ•˜์—ฌ ๋ณต์ œํ•œ ํด๋” ๋‚ด๋ถ€๋ฅผ ์‚ดํŽด๋ด…๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ๋“ค์–ด Python ํŒจํ‚ค์ง€๊ฐ€ `~/anaconda3/envs/main/lib/python3.7/site-packages/`์— ์„ค์น˜๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ Python์€ ๋ณต์ œํ•œ ํด๋”์ธ `~/diffusers/`๋„ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.

<Tip warning={true}>

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ณ„์† ์‚ฌ์šฉํ•˜๋ ค๋ฉด `diffusers` ํด๋”๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

</Tip>

์ด์ œ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ตœ์‹  ๋ฒ„์ „์˜ ๐Ÿค— Diffusers๋กœ ์‰ฝ๊ฒŒ ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

```bash
cd ~/diffusers/
git pull
```

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด, ๋‹ค์Œ์— ์‹คํ–‰ํ•  ๋•Œ Python ํ™˜๊ฒฝ์ด ๐Ÿค— Diffusers์˜ `main` ๋ฒ„์ „์„ ์ฐพ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

## ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ ๋กœ๊น…์— ๋Œ€ํ•œ ์•Œ๋ฆผ

์šฐ๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” `from_pretrained()` ์š”์ฒญ ์ค‘์— ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ ์ •๋ณด๋ฅผ ์›๊ฒฉ์œผ๋กœ ์ˆ˜์ง‘ํ•ฉ๋‹ˆ๋‹ค.
์ด ๋ฐ์ดํ„ฐ์—๋Š” Diffusers ๋ฐ PyTorch/Flax์˜ ๋ฒ„์ „, ์š”์ฒญ๋œ ๋ชจ๋ธ ๋˜๋Š” ํŒŒ์ดํ”„๋ผ์ธ ํด๋ž˜์Šค, ๊ทธ๋ฆฌ๊ณ  ํ—ˆ๋ธŒ์—์„œ ํ˜ธ์ŠคํŒ…๋˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์ „ํ•™์Šต๋œ ์ฒดํฌํฌ์ธํŠธ์— ๋Œ€ํ•œ ๊ฒฝ๋กœ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
์ด ์‚ฌ์šฉ ๋ฐ์ดํ„ฐ๋Š” ๋ฌธ์ œ๋ฅผ ๋””๋ฒ„๊น…ํ•˜๊ณ  ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์˜ ์šฐ์„ ์ˆœ์œ„๋ฅผ ์ง€์ •ํ•˜๋Š”๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ๋Š” HuggingFace ํ—ˆ๋ธŒ์—์„œ ๋ชจ๋ธ๊ณผ ํŒŒ์ดํ”„๋ผ์ธ์„ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ๋งŒ ์ „์†ก๋˜๋ฉฐ, ๋กœ์ปฌ ์‚ฌ์šฉ ์ค‘์—๋Š” ์ˆ˜์ง‘๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ๊ณต์œ ํ•˜์ง€ ์•Š๊ธฐ๋ฅผ ์›ํ•˜๋Š” ์‚ฌ๋žŒ์ด ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์ดํ•ดํ•˜๊ณ  ๊ฐœ์ธ ์ •๋ณด๋ฅผ ์กด์ค‘ํ•˜๋ฏ€๋กœ, ํ„ฐ๋ฏธ๋„์—์„œ `DISABLE_TELEMETRY` ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜์—ฌ ํ…”๋ ˆ๋ฉ”ํŠธ๋ฆฌ ์ˆ˜์ง‘์„ ๋น„ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Linux/MacOS์—์„œ:
```bash
export DISABLE_TELEMETRY=YES
```

Windows์—์„œ:
```bash
set DISABLE_TELEMETRY=YES
```