Skip to content

Commit 322c8f2

Browse files
bottlerfacebook-github-bot
authored andcommitted
make lpips optional
Summary: So that lpips isn't needed in readthedocs Reviewed By: shapovalov Differential Revision: D40859351 fbshipit-source-id: 58933bd3b71e78e658fbce56c3663b11ee2331f6
1 parent eff0aad commit 322c8f2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pytorch3d/implicitron/evaluation/evaluator.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
# LICENSE file in the root directory of this source tree.
66

77
import copy
8-
98
import json
109
import logging
1110
import os
11+
import warnings
1212
from typing import Any, Dict, List, Optional, Tuple
1313

14-
import lpips
1514
import torch
1615

1716
import tqdm
@@ -89,8 +88,16 @@ def run(
8988
Returns:
9089
A dictionary of results.
9190
"""
92-
lpips_model = lpips.LPIPS(net="vgg")
93-
lpips_model = lpips_model.to(device)
91+
try:
92+
import lpips
93+
94+
lpips_model = lpips.LPIPS(net="vgg")
95+
lpips_model = lpips_model.to(device)
96+
except ImportError:
97+
warnings.warn(
98+
"lpips library NOT FOUND. lpips losses will not be calculated"
99+
)
100+
lpips_model = None
94101

95102
model.eval()
96103

0 commit comments

Comments
 (0)