Update README.md
Browse files
README.md
CHANGED
|
@@ -32,16 +32,27 @@ This model is intended for:
|
|
| 32 |
## 🧪 Example
|
| 33 |
|
| 34 |
```python
|
| 35 |
-
import
|
| 36 |
-
from custom_rcan import RcanModelM # Replace with your actual module
|
| 37 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
model.load_state_dict(state_dict, strict=False)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
print(y.shape) # (1, 2, 256, 256) for scale=4
|
|
|
|
| 32 |
## 🧪 Example
|
| 33 |
|
| 34 |
```python
|
| 35 |
+
from super_image import RcanModel, RcanConfig
|
|
|
|
| 36 |
from huggingface_hub import hf_hub_download
|
| 37 |
+
import torch
|
| 38 |
+
|
| 39 |
+
path = hf_hub_download(repo_id="lschmidt/rcan-dsc", filename="rcan_model.py")
|
| 40 |
+
|
| 41 |
+
# Dynamically load it
|
| 42 |
+
exec(open(path).read())
|
| 43 |
|
| 44 |
+
|
| 45 |
+
# Now you can call the function directly
|
| 46 |
+
model = load_rcan()
|
| 47 |
+
|
| 48 |
+
# load config
|
| 49 |
+
config, _ = RcanConfig.from_pretrained("lschmidt/rcan-dsc")
|
| 50 |
+
|
| 51 |
+
# load pretrained weights
|
| 52 |
+
state_dict_path = hf_hub_download(repo_id="lschmidt/rcan-dsc", filename="pytorch_model_4x.pt")
|
| 53 |
+
state_dict = torch.load(state_dict_path, map_location="cpu")
|
| 54 |
model.load_state_dict(state_dict, strict=False)
|
| 55 |
|
| 56 |
+
inputs = torch.randn(1, 2, 10, 10)
|
| 57 |
+
output = model(inputs)
|
| 58 |
+
|
|
|