Update README.md
Browse files
README.md
CHANGED
|
@@ -95,31 +95,21 @@ pip install stylizing-vit
|
|
| 95 |
|
| 96 |
```python
|
| 97 |
import torch
|
| 98 |
-
from huggingface_hub import hf_hub_download
|
| 99 |
from stylizing_vit import create_model
|
| 100 |
|
| 101 |
-
# Option 1: Load using .pth weights
|
| 102 |
-
# weights_path = hf_hub_download(
|
| 103 |
-
# repo_id="sdoerrich97/stylizing_vit_base_[DATASET_SLUG]",
|
| 104 |
-
# filename="model.pth"
|
| 105 |
-
# )
|
| 106 |
-
|
| 107 |
-
# Option 2: Load using .safetensors weights (Recommended)
|
| 108 |
-
weights_path = hf_hub_download(
|
| 109 |
-
repo_id="sdoerrich97/stylizing_vit_base_[DATASET_SLUG]",
|
| 110 |
-
filename="model.safetensors"
|
| 111 |
-
)
|
| 112 |
-
|
| 113 |
# Initialize the model
|
| 114 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 115 |
-
|
| 116 |
-
model
|
|
|
|
|
|
|
| 117 |
model.eval()
|
| 118 |
|
| 119 |
# Apply Style Transfer
|
| 120 |
# content_img and style_img should be normalized torch tensors of shape (1, 3, 224, 224)
|
| 121 |
# with torch.no_grad():
|
| 122 |
# stylized_img = model(content_img, style_img)
|
|
|
|
| 123 |
```
|
| 124 |
|
| 125 |
## Training Details
|
|
|
|
| 95 |
|
| 96 |
```python
|
| 97 |
import torch
|
|
|
|
| 98 |
from stylizing_vit import create_model
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# Initialize the model
|
| 101 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 102 |
+
|
| 103 |
+
# Load the model with pretrained weights
|
| 104 |
+
# This automatically downloads the weights from the Hugging Face Hub
|
| 105 |
+
model = create_model(backbone="base", weights="camelyon17wilds", train=False).to(device)
|
| 106 |
model.eval()
|
| 107 |
|
| 108 |
# Apply Style Transfer
|
| 109 |
# content_img and style_img should be normalized torch tensors of shape (1, 3, 224, 224)
|
| 110 |
# with torch.no_grad():
|
| 111 |
# stylized_img = model(content_img, style_img)
|
| 112 |
+
``` stylized_img = model(content_img, style_img)
|
| 113 |
```
|
| 114 |
|
| 115 |
## Training Details
|