File size: 1,915 Bytes
47be72b
 
abfcd1b
 
 
2122e78
abfcd1b
3acbd7f
 
abfcd1b
 
3bebb63
eb27d9c
3bebb63
3acbd7f
3bebb63
 
 
 
 
 
eb27d9c
 
466360d
47be72b
eb27d9c
 
 
 
 
08474c3
 
 
 
3ad5fbd
 
 
 
08474c3
 
 
 
a9865a1
08474c3
 
a9865a1
08474c3
 
 
a9865a1
 
3ad5fbd
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
---
license: afl-3.0
tags:
- feature_extraction
- image
- perceptual_metric
datasets:
- Jorgvt/TID2008
- TID2013
metrics:
- pearsonr
model-index:
- name: PerceptNet
  results:
  - task:
      type: feature_extraction
      name: Perceptual Distance
    dataset:
      type: image
      name: tid2013
    metrics:
    - type: pearsonr
      value: 0.93
      name: PearsonR (MOS)
---

# PerceptNet

PercepNet model trained on TID2008 and validated on TID2013, obtaining 0.97 and 0.93 Pearson Correlation respectively.

Link to the run: https://wandb.ai/jorgvt/PerceptNet/runs/28m2cnzj?workspace=user-jorgvt

# Usage

There are two alternatives to use the model: install our development repo and load the pretrained weights manually, and load the model using `from_pretrained_keras`:

## Loading weights manually

As of now to use the model you have to install the [PerceptNet repo](https://github.com/Jorgvt/perceptnet) to get access to the `PerceptNet` class where you will load the weights available here like this:

```python
from perceptnet.networks import PerceptNet
from tensorflow.keras.utils import get_file

weights_path = get_file(fname='perceptnet_rgb.h5',
                        origin='https://huggingface.co/Jorgvt/PerceptNet/resolve/main/tf_model.h5')
model = PerceptNet(kernel_initializer='ones', gdn_kernel_size=1, learnable_undersampling=False)
model.build(input_shape=(None, 384, 512, 3))
model.load_weights(weights_path)                        
```

> PerceptNet requires `wandb` to be installed. It's something we're looking into.

## Directly from the Hub

As every other *Keras* model in the Hub, it can be loaded as follows:

```python
from huggingface_hub import from_pretrained_keras
model = from_pretrained_keras("Jorgvt/PerceptNet", compile=False)
```

> Keep in mind that the model uses grouped convolutions and, at least in Colab, `Unimplemented Errors` may arise when using it in CPU.