python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Meta Platforms, Inc. and affiliates.
import warnings
from mmseg.models.builder import MODELS
ESTIMATORS = MODELS
def build_estimator(cfg, train_cfg=None, test_cfg=None):
"""Build estimator."""
if train_cfg is not None or test_cfg is not None:
warnings.warn(
'train_cfg an... | CODD-main | model/builder.py |
from mmcv.runner import HOOKS, LrUpdaterHook
import mmcv
@HOOKS.register_module()
class MultiGammaLrUpdaterHook(LrUpdaterHook):
"""Step LR scheduler.
Args:
step (list[int]): Step to decay the LR. If an int value is given,
regard it as the decay interval. If a list is given, decay LR at
... | CODD-main | model/lr_updater.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .fusion import Fusion
from .others import NullFusion, GTFusion, KalmanFusion
__all__ = ["NullFusion", "GTFusion", "KalmanFusion", "Fusion"]
| CODD-main | model/fusion/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init, kaiming_init, normal_init, trunc_normal_init
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmseg.models import builder as builder_oss
from mm... | CODD-main | model/fusion/fusion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from mmseg.models.builder import MODELS
@MODELS.register_module()
class NullFusion(nn.Module):
"""Implements a NULL memory module that does not do anything"""
def __init__(
self,
**kwargs,
):
... | CODD-main | model/fusion/others.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import LOSSES
@LOSSES.register_module()
class FusionLoss(nn.Module):
def __init__(
self, min_disp=1, max_disp=192, loss_weight=(1.0), wr_weight=1.0, wf_weight=1.0
... | CODD-main | model/losses/temporal.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import LOSSES
def subpix_cost(cost: torch.Tensor, disp: torch.Tensor, maxdisp: int):
"""
phi, e.g. eqt(9) in HITNet paper
:param cost:
:param disp:
:return:
... | CODD-main | model/losses/hitnet.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .hitnet import *
from .temporal import *
| CODD-main | model/losses/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .hitnet import HITNetMF
| CODD-main | model/stereo/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from mmseg.models.builder import BACKBONES
def conv_down(inp, oup):
return nn.Sequential(
nn.Conv2d(inp, oup, 4, stride=2, padding=1),
nn.LeakyReLU(negative_slope=0.2, inplace=True),
nn.Conv2d(oup, oup... | CODD-main | model/stereo/hitnet/backbone.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import builder as builder_oss
from mmseg.models.builder import MODELS
from utils import thres_metric
from ...builder import ESTIMATORS
@ESTIMATORS.register_module()
class HITNetM... | CODD-main | model/stereo/hitnet/hitnet.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .backbone import HITUNet
from .initialization import TileInitialization
from .propagation import TilePropagation
from .hitnet import HITNetMF
| CODD-main | model/stereo/hitnet/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models.builder import MODELS
def make_grid(h, w, device):
gridh = torch.arange(h, device=device).float()
gridw = torch.arange(w, device=device).float()
gridh, gridw = torch.... | CODD-main | model/stereo/hitnet/initialization.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models.builder import MODELS
def to_plane(d, dx, dy, size=4):
c = torch.linspace(-(size - 1) / 2, (size - 1) / 2, size, device=d.device)
a = c.view([1, 1, size])
a = torch.... | CODD-main | model/stereo/hitnet/propagation.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .motion import Motion
from .others import GTMotion
__all__ = ["Motion", "GTMotion"]
| CODD-main | model/motion/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models import builder as builder_oss
from mmseg.models.builder import MODELS
from pytorch3d.renderer import (
PerspectiveCameras,
PointsRasterizationSettings,
PointsRenderer,
... | CODD-main | model/motion/motion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
import torch.nn as nn
from lietorch import SE3
from mmseg.models.builder import MODELS
from utils import flow_warp
@MODELS.register_module()
class GTMotion(nn.Module):
def __init__(self):
super(GTMotion, self).__init__()
self.loss... | CODD-main | model/motion/others.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import lietorch_extras
import torch
import torch.nn.functional as F
from lietorch import SE3
from . import projective_ops as pops
class SE3BuilderInplace(torch.autograd.Function):
@sta... | CODD-main | model/motion/raft3d/se3_field.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
import torch.nn.functional as F
# lietorch for tangent space backpropogation
from lietorch import SE3
from mmseg.models import builder as builder_oss
from m... | CODD-main | model/motion/raft3d/raft3d.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
from .raft3d import RAFT3D
| CODD-main | model/motion/raft3d/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn.functional as F
def bilinear_sampler(img, coords, mode='bilinear', mask=False):
""" Wrapper for grid_sample, uses pixel coordinates """
H, W = img.shape... | CODD-main | model/motion/raft3d/sampler_ops.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
from .sampler_ops import *
MIN_DEPTH = 0.05
EPS = 1e-5
def project(Xs, intrinsics):
""" Pinhole camera projection """
X, Y, Z = Xs.unbind(dim=-1)
Z = Z + EPS
fx, fy, cx, cy... | CODD-main | model/motion/raft3d/projective_ops.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import lietorch_extras
import torch
import torch.nn.functional as F
class CorrSampler(torch.autograd.Function):
""" Index from correlation pyramid """
@staticmethod
def forward... | CODD-main | model/motion/raft3d/blocks/corr.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import time
import numpy as np
import scipy.sparse
import torch
import torch.nn.functional as F
from sksparse import cholmod
class GridCholeskySolver(torch.autograd.Function):
@static... | CODD-main | model/motion/raft3d/blocks/grid.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
| CODD-main | model/motion/raft3d/blocks/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
... | CODD-main | model/motion/raft3d/blocks/extractor.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Adapted from RAFT3D repository: https://github.com/princeton-vl/RAFT-3D
import torch
import torch.nn as nn
class ConvGRU(nn.Module):
def __init__(self, hidden_dim=128, input_dim=192 + 128, dilation=4):
super(ConvGRU, self).__init__()
self.hi... | CODD-main | model/motion/raft3d/blocks/gru.py |
"""For pip."""
from setuptools import find_packages, setup
exec(open("pdftotree/_version.py").read())
setup(
name="pdftotree",
version=__version__,
description="Convert PDF into hOCR with text, tables, and figures being recognized and preserved.",
long_description=open("README.rst").read(),
package... | pdftotree-master | setup.py |
from typing import Tuple
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfparser import PDFParser
try:
from IPython import get_ipython
if "IPKernelApp" not in get_ipython().config:
raise ImportError("console")
except (AttributeError, ImportError):
... | pdftotree-master | pdftotree/TreeVisualizer.py |
__version__ = "0.5.1+dev"
| pdftotree-master | pdftotree/_version.py |
#!/usr/bin/env python
# At the top level, prevent logging output in absense of logging config.
import logging
from pdftotree._version import __version__
from pdftotree.core import parse
logging.getLogger(__name__).addHandler(logging.NullHandler())
__all__ = ["__version__", "parse"]
| pdftotree-master | pdftotree/__init__.py |
"""
This script takes a PDF document and extracts it's tree structure and then
writes the HTML based on that tree structure. The components of the tree
structure are:
- Tables
- Table Captions
- Figures
- Figure Captions
- Section Headers
- Paragraphs
- List (References in research papers)
- Page Headers
Tables are de... | pdftotree-master | pdftotree/core.py |
import logging
import os
import tempfile
from base64 import b64encode
from functools import cmp_to_key
from typing import Any, Dict, List, Optional, Tuple
from xml.dom.minidom import Document, Element
import numpy as np
import tabula
from pdfminer.image import ImageWriter
from pdfminer.layout import LAParams, LTChar, ... | pdftotree-master | pdftotree/TreeExtract.py |
TOLERANCE = 5
def reorder_lines(lines, tol=TOLERANCE):
"""
Changes the line coordinates to be given as (top, left, bottom, right)
:param lines: list of lines coordinates
:return: reordered list of lines coordinates
"""
reordered_lines = []
for line in lines:
# we divide by tol and ... | pdftotree-master | pdftotree/utils/lines_utils.py |
import numpy as np
from wand.color import Color
from wand.display import display
from wand.drawing import Drawing
from wand.image import Image
def display_bounding_boxes(img, blocks, alternatecolors=False, color=Color("blue")):
"""
Displays each of the bounding boxes passed in 'boxes' on an image of the pdf
... | pdftotree-master | pdftotree/utils/display_utils.py |
pdftotree-master | pdftotree/utils/__init__.py | |
from typing import Tuple
TOLERANCE = 5
def doOverlap(bbox1, bbox2):
"""
:param bbox1: bounding box of the first rectangle
:param bbox2: bounding box of the second rectangle
:return: 1 if the two rectangles overlap
"""
if bbox1[2] < bbox2[0] or bbox2[2] < bbox1[0]:
return False
if ... | pdftotree-master | pdftotree/utils/bbox_utils.py |
"""
Created on Oct 11, 2015
@author: xiao
"""
import os
from sys import platform as _platform
import numpy as np
from pdfminer.layout import LTAnno
from PIL import Image, ImageDraw, ImageFont
from pdftotree.utils.pdf.vector_utils import center
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, ... | pdftotree-master | pdftotree/utils/img_utils.py |
"""
Created on Jan 25, 2016
@author: xiao
"""
import collections
import logging
from builtins import range
from itertools import chain
import numpy as np
from pdfminer.layout import LTAnno
from pdftotree.utils.pdf.vector_utils import inside, intersect
def get_near_items(tree, tree_key):
"""
Check both poss... | pdftotree-master | pdftotree/utils/pdf/layout_utils.py |
"""
Created on Dec 2, 2015
@author: xiao
"""
import bisect
import logging
from builtins import object, range, zip
from collections import defaultdict
from functools import cmp_to_key
from pprint import pformat
import numpy as np
import pandas as pd
from pdfminer.utils import Plane
from pdftotree.utils.pdf.vector_uti... | pdftotree-master | pdftotree/utils/pdf/grid.py |
"""
Handles abstract rendering of the layout
in order to extract local visual features
Created on Jan 28, 2016
@author: xiao
"""
import logging
import numpy as np
from pdf.vector_utils import x0, x1, y0, y1
logger = logging.getLogger(__name__)
class Renderer(object):
"""
enumeration objects to be placed i... | pdftotree-master | pdftotree/utils/pdf/render.py |
"""
Created on Oct 12, 2015
Various routines to work with pdf objects
extracted with PDFminer
@author: xiao
"""
import collections
import re
import string
from collections import Counter
from typing import List, NamedTuple, Optional, Tuple, Union
from pdfminer.converter import PDFPageAggregator
from pdfminer.layout i... | pdftotree-master | pdftotree/utils/pdf/pdf_utils.py |
"""
Created on Oct 26, 2015
Parsing raw PDF data into python data structures
@author: xiao
"""
import logging
import math
import operator
import sys
from builtins import filter, range, str, zip
from collections import Counter, defaultdict
from functools import cmp_to_key
from typing import Any, Dict, List, Tuple
impo... | pdftotree-master | pdftotree/utils/pdf/pdf_parsers.py |
pdftotree-master | pdftotree/utils/pdf/__init__.py | |
"""
Created on Oct 21, 2015
@author: xiao
"""
from collections import namedtuple
import numpy as np
# bbox indices
x0 = 0
y0 = 1
x1 = 2
y1 = 3
class Segment(namedtuple("Segment", ["e", "vector"])):
__slots__ = ()
@property
def length(self):
return self.vector[x0] if self.vector[x0] else self... | pdftotree-master | pdftotree/utils/pdf/vector_utils.py |
"""
Created on Jun 10, 2016
@author: xiao
"""
import numbers
from collections import Counter
from typing import List, Union
from pdfminer.layout import LTComponent, LTCurve, LTFigure, LTLine, LTTextLine
from pdftotree.utils.pdf.grid import Grid
from pdftotree.utils.pdf.layout_utils import is_same_row, is_vline
from ... | pdftotree-master | pdftotree/utils/pdf/node.py |
pdftotree-master | pdftotree/ml/__init__.py | |
import string
from builtins import str
from collections import defaultdict
from typing import Any, List
from pdfminer.layout import LTComponent, LTTextLine
from pdftotree.utils.bbox_utils import isContained
from pdftotree.utils.pdf.pdf_parsers import (
cluster_vertically_aligned_boxes,
get_char_width,
get... | pdftotree-master | pdftotree/ml/features.py |
import logging
import numpy as np
from wand.color import Color
from wand.drawing import Drawing
from pdftotree.ml.features import get_alignment_features, get_lines_features
from pdftotree.TreeExtract import TreeExtractor
from pdftotree.utils.bbox_utils import compute_iou
from pdftotree.utils.display_utils import pdf_... | pdftotree-master | pdftotree/ml/TableExtractML.py |
pdftotree-master | pdftotree/visual/__init__.py | |
import os
from typing import Tuple
import keras.backend as K
import numpy as np
import selectivesearch
from keras.preprocessing.image import img_to_array, load_img
from numpy import ndarray
from wand.color import Color
from wand.image import Image
def predict_heatmap(
pdf_path, page_num, model, img_dim=448, img_... | pdftotree-master | pdftotree/visual/visual_utils.py |
import logging
import os
from subprocess import PIPE, Popen
from typing import Optional
from bs4 import BeautifulSoup
from bs4.element import Tag
from shapely.geometry import box
import pdftotree
# Adapted from https://github.com/ocropus/hocr-tools/blob/v1.3.0/hocr-check
def get_prop(node: Tag, name: str) -> Option... | pdftotree-master | tests/test_basic.py |
"""Test table area detection."""
from bs4 import BeautifulSoup
import pdftotree
from pdftotree.core import load_model
from pdftotree.visual.visual_utils import predict_heatmap
def test_vision_model():
"""Check if the vision model runs and returns results in expected format."""
pdf_file = "tests/input/paleo.p... | pdftotree-master | tests/test_table_detection.py |
pdftotree-master | tests/__init__.py | |
"""Test figures."""
from bs4 import BeautifulSoup
import pdftotree
def test_figures():
output = pdftotree.parse("tests/input/md.pdf")
soup = BeautifulSoup(output, "lxml")
imgs = soup.find_all("img")
assert len(imgs) == 1
output = pdftotree.parse("tests/input/CaseStudy_ACS.pdf")
soup = Beauti... | pdftotree-master | tests/test_figures.py |
"""Test extracted text."""
import re
from bs4 import BeautifulSoup
import pdftotree
def test_text_is_escaped():
"""Test if text is properly escaped."""
output = pdftotree.parse("tests/input/md.pdf")
soup = BeautifulSoup(output, "lxml")
words = soup.find_all(class_="ocrx_word")
# Use str() instea... | pdftotree-master | tests/test_text.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import pylab
import torch
import pickle
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import... | classifier-balancing-main | tau_norm.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import yaml
import csv
import h5py
class Logger(object):
def __init__(self, logdir):
self.logdir = lo... | classifier-balancing-main | logger.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | utils.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | run_networks.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | main.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | layers/ModulatedAttLayer.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | loss/SoftmaxLoss.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | loss/DiscCentroidsLoss.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/MetaEmbeddingClassifier.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNet101Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNet152FeatureCaffe.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import math
import torch.nn as nn
import torch.nn.functional as F
from layers.ModulatedAttLayer import ModulatedAttLayer
de... | classifier-balancing-main | models/ResNextFeature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNet50Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNetFeature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/DotProductClassifier.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use... | classifier-balancing-main | models/ResNext101Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from utils import *
from os import path
class ... | classifier-balancing-main | models/TauNormClassifier.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/CosNormClassifier.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | models/ResNet10Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use... | classifier-balancing-main | models/ResNext152Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import torch.nn as nn
import numpy as np
import pickle
from os import path
class KNNClassifier(nn.Module):
... | classifier-balancing-main | models/KNNClassifier.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNextFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_... | classifier-balancing-main | models/ResNext50Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
from models.ResNetFeature import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_f... | classifier-balancing-main | models/ResNet152Feature.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | data/ClassAwareSampler.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import random
import numpy as np
from torch.utils.data.sampler import Sampler
class PriorityTree(object):
def __init__... | classifier-balancing-main | data/MixedPrioritizedSampler.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import random
import numpy as np
from torch.utils.data.sampler import Sampler
class RandomCycleIter:
def __init__... | classifier-balancing-main | data/ClassPrioritySampler.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Portions of the source code are from the OLTR project which
notice below and in LICENSE in the root directory of
this source tree... | classifier-balancing-main | data/dataloader.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
Usage:
1. Change "root" to your data path
2. python gen_lists.py
"""
import os
import json
from tqdm import tqdm
root = '/check... | classifier-balancing-main | data/iNaturalist18/gen_lists.py |
"""Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import json
from tqdm import tqdm
root = '/datasets01_101/imagenet_full_size/061417'
split2txt = {
'train': 'I... | classifier-balancing-main | data/ImageNet/gen_txt.py |
import re
import sys
import os
import os.path
import random
import json
import time
import nltk.data
import spacy
import pandas as pd
import random
from multiprocessing import Pipe, Pool
from functools import partial
from collections import defaultdict, Counter
from tqdm import tqdm
sys.path.append("/checkpoint/sima... | concurrentqa-main | dataset_construction/cleanEnron.py |
import os
import sys
import argparse
import json as json
import pandas as pd
from collections import Counter, defaultdict
from importlib import reload
from email.parser import Parser
# recursively get the document body
def get_body(body):
if type(body) == str:
return [body]
else:
body_results ... | concurrentqa-main | dataset_construction/EnronParser.py |
import os
import csv
import ujson
import json
from tqdm import tqdm
import requests
import pandas as pd
import numpy as np
import time
import ast
import random
from collections import Counter, defaultdict, OrderedDict
INBOX = "skilling-j"
def add_entry(q="", idx="", answer=[], sp1={}, sp2={}, typ="", domain=[]):
e... | concurrentqa-main | dataset_construction/Enron_skilling-j/make_queries.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import uuid
from pathlib import Path
import main as classification
import submitit
def parse... | ConvNeXt-main | run_with_submitit.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
from torchvision import datasets, transforms
from timm.data.constants import \
IMAGENET_DEFAULT_MEAN, IMA... | ConvNeXt-main | datasets.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import Iterable, Optional
import torch
from timm.data import Mixup
from timm.utils import accura... | ConvNeXt-main | engine.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
import math
import time
from collections import defaultdict, deque
import datetime
import numpy as np
from tim... | ConvNeXt-main | utils.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import datetime
import numpy as np
import time
import torch
import torch.nn as nn
import torch.backends.... | ConvNeXt-main | main.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import optim as optim
from timm.optim.adafactor import Adafactor
from timm.optim.adahessian imp... | ConvNeXt-main | optim_factory.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers... | ConvNeXt-main | models/convnext_isotropic.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import trunc_normal_, DropPat... | ConvNeXt-main | models/convnext.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import json
from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor
from mmcv.runner import get_dist_inf... | ConvNeXt-main | object_detection/mmcv_custom/layer_decay_optimizer_constructor.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# -*- coding: utf-8 -*-
from .checkpoint import load_checkpoint
from .layer_decay_optimizer_constructor import Learning... | ConvNeXt-main | object_detection/mmcv_custom/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import datetime
from collections import OrderedDict
import torch
import mmcv
from mmcv.runner import HOOKS
from mmcv.r... | ConvNeXt-main | object_detection/mmcv_custom/customized_text.py |
# Copyright (c) Open-MMLab. All rights reserved.
import os.path as osp
import time
from tempfile import TemporaryDirectory
import torch
from torch.optim import Optimizer
import mmcv
from mmcv.parallel import is_module_wrapper
from mmcv.runner.checkpoint import weights_to_cpu, get_state_dict
try:
import apex
exce... | ConvNeXt-main | object_detection/mmcv_custom/runner/checkpoint.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.