Skip to main content

LPIPS Similarity Metric for MegEngine

Project description

LPIPS for MegEngine

MegEngine port for LPIPS metric.

Get Started

Run pip3 install mge-lpips to install this package. The provided mge_lpips.LPIPS is a normal MegEngine M.Module which can be used as a metric or a loss function.

import numpy as np
import megengine as mge
from mge_lpips import LPIPS

metric_lpips = LPIPS(net="alex")

in1 = np.random.uniform(-1, 1, size=(2, 3, 256, 256)).astype(np.float32)
in2 = np.random.uniform(-1, 1, size=(2, 3, 256, 256)).astype(np.float32)

d = metric_lpips(mge.Tensor(in1), mge.Tensor(in2))

Acknowledgements

The code of this project is modified from the original LPIPS project. The backbone model code is modified from torchvision. The weights are from the origian LPIPS project and torchvision.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mge_lpips-0.1.0-py3-none-any.whl (48.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page