Spaces:
Running
Running
File size: 1,562 Bytes
9223079 2f1d0e2 8320ccc b075789 9223079 4c88343 9223079 2f1d0e2 9223079 e15a186 9223079 2f1d0e2 9223079 2f1d0e2 9223079 4c88343 b075789 |
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 64 |
import logging
import sys
import torch
from packaging import version
__version__ = "1.5"
LOG_PATH = "log.txt"
def read_logs():
sys.stdout.flush()
with open(LOG_PATH, "r") as f:
return f.read()
def flush_logs():
sys.stdout.flush()
logs = open(LOG_PATH, "w")
logs.close()
formatter = logging.Formatter(
fmt="[%(asctime)s %(name)s %(levelname)s] %(message)s",
datefmt="%Y/%m/%d %H:%M:%S",
)
logs_file = open(LOG_PATH, "w")
logs_file.close()
file_handler = logging.FileHandler(filename=LOG_PATH)
file_handler.setFormatter(formatter)
file_handler.setLevel(logging.INFO)
stdout_handler = logging.StreamHandler()
stdout_handler.setFormatter(formatter)
stdout_handler.setLevel(logging.INFO)
logger = logging.getLogger("hloc")
logger.setLevel(logging.INFO)
logger.addHandler(file_handler)
logger.addHandler(stdout_handler)
logger.propagate = False
try:
import pycolmap
except ImportError:
logger.warning("pycolmap is not installed, some features may not work.")
else:
min_version = version.parse("0.6.0")
found_version = pycolmap.__version__
if found_version != "dev":
version = version.parse(found_version)
if version < min_version:
s = f"pycolmap>={min_version}"
logger.warning(
"hloc requires %s but found pycolmap==%s, "
'please upgrade with `pip install --upgrade "%s"`',
s,
found_version,
s,
)
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|