mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
make lpips optional
Summary: So that lpips isn't needed in readthedocs Reviewed By: shapovalov Differential Revision: D40859351 fbshipit-source-id: 58933bd3b71e78e658fbce56c3663b11ee2331f6
This commit is contained in:
parent
eff0aad15a
commit
322c8f2f50
@ -5,13 +5,12 @@
|
|||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
import lpips
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
import tqdm
|
import tqdm
|
||||||
@ -89,8 +88,16 @@ class ImplicitronEvaluator(EvaluatorBase):
|
|||||||
Returns:
|
Returns:
|
||||||
A dictionary of results.
|
A dictionary of results.
|
||||||
"""
|
"""
|
||||||
lpips_model = lpips.LPIPS(net="vgg")
|
try:
|
||||||
lpips_model = lpips_model.to(device)
|
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()
|
model.eval()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user