Update README.md
Browse files
README.md
CHANGED
@@ -1 +1,20 @@
|
|
1 |
-
OpenCLIP-VIT-g image encoder extracted from [https://huggingface.co/stabilityai/stable-diffusion-2-1-unclip/tree/main/image_encoder](https://huggingface.co/stabilityai/stable-diffusion-2-1-unclip/tree/main/image_encoder)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
OpenCLIP-VIT-g image encoder extracted from [https://huggingface.co/stabilityai/stable-diffusion-2-1-unclip/tree/main/image_encoder](https://huggingface.co/stabilityai/stable-diffusion-2-1-unclip/tree/main/image_encoder)
|
2 |
+
|
3 |
+
```python
|
4 |
+
from PIL import Image
|
5 |
+
import requests
|
6 |
+
from transformers import AutoProcessor, CLIPVisionModelWithProjection
|
7 |
+
from transformers import CLIPVisionModelWithProjection, CLIPImageProcessor
|
8 |
+
|
9 |
+
model_name = "Jiayi-Pan/SD-v2-1-Image-Encoder"
|
10 |
+
model = CLIPVisionModelWithProjection.from_pretrained(model_name)
|
11 |
+
processor = transformers.CLIPImageProcessor.from_pretrained(model_name)
|
12 |
+
|
13 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
14 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
15 |
+
|
16 |
+
inputs = processor(images=image, return_tensors="pt")
|
17 |
+
|
18 |
+
outputs = model(**inputs)
|
19 |
+
image_embeds = outputs.image_embeds
|
20 |
+
```
|