File size: 1,349 Bytes
46bcb58
 
 
 
 
 
 
82649d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
license: mit
tags:
- universal-photometric-stereo
- normal-estimation
---

# Model Card for LINO-UniPS

This repository contains the weights of `Light of Normals: Unified Feature Representation for Universal Photometric Stereo`

## Usage

See the Github repository: https://github.com/houyuanchen111/LINO_UniPS regarding installation instructions.

The model can then be used as follows:

```python
import torch
import pytorch_lightning as pl
from torch.utils.data import DataLoader
from PIL import Image
import numpy as np
import os

# load input images
input_images = [
    (np.array(Image.open(f"path/to/your_image_{i}.png").convert("RGB")))
    for i in range(1,8)  # Adjust the range based on your images
]

# load mask (optional)
mask = Image.open("path/to/your_mask.png") if os.path.exists("path/to/your_mask.png") else None

# load data_module and model
datamodule = torch.hub.load(
            "houyuanchen111/LINO_UniPS",
            "load_data",
            input_images,
            mask
        )
lino = torch.hub.load(
            "houyuanchen111/LINO_UniPS",
            "lino_unips",
            pretrained=True
        )

# predict
test_loader = DataLoader(datamodule, batch_size=1)
trainer = pl.Trainer(accelerator="auto", devices=1,precision="bf16-mixed")
nml_predict = trainer.predict(model=lino, dataloaders=test_loader)
```