Exemplo n.º 1
0
import json
import os
import os.path as osp
from functools import lru_cache, wraps
from typing import *

import h5py
import networkx as nx
import numpy as np
import torch
from rsmlkit.collections.frozendict import frozendict
from rsmlkit.logging import get_logger

logger = get_logger('__file__')


def freezeargs(func):
    """
    Transform mutable dictionnary
    Into immutable Useful to be compatible with cache
    """
    @wraps(func)
    def wrapped(*args, **kwargs):
        args = tuple([
            frozendict(arg) if isinstance(arg, dict) else arg for arg in args
        ])
        kwargs = {
            k: frozendict(v) if isinstance(v, dict) else v
            for k, v in kwargs.items()
        }
        return func(*args, **kwargs)
Exemplo n.º 2
0
# Email: [email protected]
# Created on: 2020-05-18
# 
# This file is part of MGN
# Distributed under terms of the MIT License

import logging
import os
import os.path as osp
import sys
from itertools import zip_longest

# logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(message)s")
from rsmlkit.logging import get_logger, set_default_level

logger = get_logger(__file__)
set_default_level(logging.INFO)

## quick HACK
PROJECT_PATH = '..'
CLEVR_PARSER_PATH = f'{PROJECT_PATH}/vendors/clevr-parser'
print(f"CLEVR_PARSER_PATH={CLEVR_PARSER_PATH}")
if PROJECT_PATH not in sys.path:
    sys.path.insert(0, PROJECT_PATH)
if CLEVR_PARSER_PATH not in sys.path:
    sys.path.insert(0, CLEVR_PARSER_PATH)

import clevr_parser

from .data import PairData, ClevrData