Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Model Card for LINO-UniPS
|
| 2 |
+
|
| 3 |
+
This repository contains the weights of `Light of Normals: Unified Feature Representation for Universal Photometric Stereo`
|
| 4 |
+
|
| 5 |
+
## Usage
|
| 6 |
+
|
| 7 |
+
See the Github repository: https://github.com/houyuanchen111/LINO_UniPS regarding installation instructions.
|
| 8 |
+
|
| 9 |
+
The model can then be used as follows:
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
import torch
|
| 13 |
+
import pytorch_lightning as pl
|
| 14 |
+
from torch.utils.data import DataLoader
|
| 15 |
+
from PIL import Image
|
| 16 |
+
import numpy as np
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
# load input images
|
| 20 |
+
input_images = [
|
| 21 |
+
(np.array(Image.open(f"path/to/your_image_{i}.png").convert("RGB")))
|
| 22 |
+
for i in range(1,8) # Adjust the range based on your images
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
# load mask (optional)
|
| 26 |
+
mask = Image.open("path/to/your_mask.png") if os.path.exists("path/to/your_mask.png") else None
|
| 27 |
+
|
| 28 |
+
# load data_module and model
|
| 29 |
+
datamodule = torch.hub.load(
|
| 30 |
+
"houyuanchen111/LINO_UniPS",
|
| 31 |
+
"load_data",
|
| 32 |
+
input_images,
|
| 33 |
+
mask
|
| 34 |
+
)
|
| 35 |
+
lino = torch.hub.load(
|
| 36 |
+
"houyuanchen111/LINO_UniPS",
|
| 37 |
+
"lino_unips",
|
| 38 |
+
pretrained=True
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# predict
|
| 42 |
+
test_loader = DataLoader(datamodule, batch_size=1)
|
| 43 |
+
trainer = pl.Trainer(accelerator="auto", devices=1,precision="bf16-mixed")
|
| 44 |
+
nml_predict = trainer.predict(model=lino, dataloaders=test_loader)
|
| 45 |
+
```
|