Skip to content

Commit

Permalink
make lpips optional
Browse files Browse the repository at this point in the history
Summary: So that lpips isn't needed in readthedocs

Reviewed By: shapovalov

Differential Revision: D40859351

fbshipit-source-id: 58933bd3b71e78e658fbce56c3663b11ee2331f6
  • Loading branch information
bottler authored and facebook-github-bot committed Oct 31, 2022
1 parent eff0aad commit 322c8f2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pytorch3d/implicitron/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
# LICENSE file in the root directory of this source tree.

import copy

import json
import logging
import os
import warnings
from typing import Any, Dict, List, Optional, Tuple

import lpips
import torch

import tqdm
Expand Down Expand Up @@ -89,8 +88,16 @@ def run(
Returns:
A dictionary of results.
"""
lpips_model = lpips.LPIPS(net="vgg")
lpips_model = lpips_model.to(device)
try:
import lpips

lpips_model = lpips.LPIPS(net="vgg")
lpips_model = lpips_model.to(device)
except ImportError:
warnings.warn(
"lpips library NOT FOUND. lpips losses will not be calculated"
)
lpips_model = None

model.eval()

Expand Down

0 comments on commit 322c8f2

Please sign in to comment.