Update README.md
Browse files
README.md
CHANGED
|
@@ -11,13 +11,21 @@ Inspired by [vvmatorin/CSD](https://huggingface.co/vvmatorin/CSD), the differenc
|
|
| 11 |
Inference:
|
| 12 |
|
| 13 |
```python
|
|
|
|
|
|
|
| 14 |
from PIL import Image
|
| 15 |
-
from transformers import
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
```
|
|
|
|
| 11 |
Inference:
|
| 12 |
|
| 13 |
```python
|
| 14 |
+
import torch
|
| 15 |
+
import requests
|
| 16 |
from PIL import Image
|
| 17 |
+
from transformers import AutoModel, AutoConfig, AutoProcessor
|
| 18 |
|
| 19 |
+
image_url = "https://midjourneysref.com/cdn-cgi/image/format=webp,quality=80,fit=cover/https://explore.midjourneysref.com/1541138391-4-219d8b0b"
|
| 20 |
+
def load_image(url):
|
| 21 |
+
im = Image.open(requests.get(url, stream=True).raw)
|
| 22 |
+
return im
|
| 23 |
|
| 24 |
+
processor = AutoProcessor.from_pretrained('NagaSaiAbhinay/CSD')
|
| 25 |
+
model = AutoModel.from_pretrained('NagaSaiAbhinay/CSD', trust_remote_code=True).to("cuda")
|
| 26 |
|
| 27 |
+
im = load_image(image_url)
|
| 28 |
+
processed_image = processor(images=im, return_tensors='pt').to('cuda')
|
| 29 |
+
processed_image = processed_image['pixel_values']
|
| 30 |
+
_, style_vector, _ = model(processed_image)
|
| 31 |
```
|