repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
MatNet
MatNet-main/ATSP/ATSP_MatNet/ATSPTester.py
""" The MIT License Copyright (c) 2021 MatNet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, d...
6,815
37.292135
115
py
MatNet
MatNet-main/ATSP/ATSP_MatNet/ATSPTrainer.py
""" The MIT License Copyright (c) 2021 MatNet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, d...
9,434
41.309417
120
py
MatNet
MatNet-main/ATSP/ATSP_MatNet/ATSPEnv.py
""" The MIT License Copyright (c) 2021 MatNet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, d...
5,553
33.07362
108
py
mezze
mezze-master/mezze/tfq/inference.py
# Copyright: 2015-2020 The Johns Hopkins University Applied Physics Laboratory LLC (JHU/APL). # All Rights Reserved. # # This material may be only be used, modified, or reproduced by or for the U.S. # Government pursuant to the license rights granted under the clauses at DFARS # 252.227-7013/7014 or FAR 52.227-14. For ...
10,349
39.272374
197
py
mezze
mezze-master/mezze/tfq/filter_fcn.py
# Copyright: 2015-2020 The Johns Hopkins University Applied Physics Laboratory LLC (JHU/APL). # All Rights Reserved. # # This material may be only be used, modified, or reproduced by or for the U.S. # Government pursuant to the license rights granted under the clauses at DFARS # 252.227-7013/7014 or FAR 52.227-14. For ...
16,269
35.809955
146
py
HateALERT-HASOC
HateALERT-HASOC-master/Data/bert_trial/simple_lm_finetuning.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
27,716
42.24025
134
py
HateALERT-HASOC
HateALERT-HASOC-master/Data/bert_trial/finetune_on_pregenerated.py
from argparse import ArgumentParser from pathlib import Path import os import torch import logging import json import random import numpy as np from collections import namedtuple from tempfile import TemporaryDirectory from torch.utils.data import DataLoader, Dataset, RandomSampler from torch.utils.data.distributed im...
15,759
46.613293
136
py
HateALERT-HASOC
HateALERT-HASOC-master/Data/bert_trial/pregenerate_training_data.py
from argparse import ArgumentParser from pathlib import Path from tqdm import tqdm, trange from tempfile import TemporaryDirectory import shelve from multiprocessing import Pool from random import random, randrange, randint, shuffle, choice from pytorch_transformers.tokenization_bert import BertTokenizer import numpy ...
16,272
44.839437
120
py
mapfe4mp
mapfe4mp-master/evaluate/test_model_utils.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Test model utils """ Created on Wed May 18 17:59:06 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import sys import time import git # DL & Math import torch import torchstat from thop import profile, clever_for...
969
20.555556
119
py
mapfe4mp
mapfe4mp-master/evaluate/test_flops_parameters.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Test performance of the models in terms of FLOPs (MACs) and parameters """ Created on Wed May 18 17:59:06 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import sys import time import pdb import yaml import os import git from prodict import Prodic...
7,668
33.545045
115
py
mapfe4mp
mapfe4mp-master/evaluate/argoverse/generate_goal_points_error.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Compute the error between the goals and ground-truth end-points """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo """ import cv2 import numpy as np import os import copy import pdb import sys import math import git import csv import torch import...
10,292
32.096463
128
py
mapfe4mp
mapfe4mp-master/evaluate/argoverse/generate_results_rel-rel.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Generate results: ## If 'train' or 'val': Check the results with the best ckpt (in order to obtain qualitative results, check metrics, etc.) ## If 'test': Generate the .h5 file to submit to the Argoverse 1.1 Motion Forecasting Leaderboard (qualitative results are ori...
32,744
46.456522
181
py
mapfe4mp
mapfe4mp-master/model/modules/losses.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## losses """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import pdb import os # DL & Math imports import math import torch import torch.nn as nn import torch.cuda import random import numpy as np import cv2 impor...
33,749
36.964004
156
py
mapfe4mp
mapfe4mp-master/model/modules/evaluation_metrics.py
import torch import random import pdb def displacement_error(pred_traj, pred_traj_gt, consider_ped=None, mode='sum'): """ If mode == "sum", we return the sum of all differences between GT and pred along the prediction """ loss = pred_traj_gt.permute(1, 0, 2) - pred_traj.permute(1, 0, 2) loss =...
974
26.857143
83
py
mapfe4mp
mapfe4mp-master/model/modules/layers.py
import sys import torch import math from torch import nn if str(sys.version_info[0])+"."+str(sys.version_info[1]) >= "3.9": # Python >= 3.9 from math import gcd else: from fractions import gcd import pdb class MLP(nn.Module): """ """ def __init__(self, dim_list, activation='relu', batch_norm=T...
3,709
30.176471
82
py
mapfe4mp
mapfe4mp-master/model/modules/classifiers.py
import torch from torch import nn import pdb from model.modules.layers import MLP class Classifier(nn.Module): def __init__(self, mlp_config): super(Classifier, self).__init__() self.spatial_embedding = MLP(**mlp_config) # self.softmax = nn.Softmax(dim=1) # Perform softmax operation acc...
1,273
32.526316
122
py
mapfe4mp
mapfe4mp-master/model/modules/backbones.py
import torch from torch import nn from model.utils.load_models import load_VGG_model from model.modules.encoders import EncoderLSTM as Encoder class VisualExtractor(nn.Module): """ In this class add all the visual extractors that will be used in the architecture. Currently supporting: - VGG{11, 13...
8,260
35.553097
106
py
mapfe4mp
mapfe4mp-master/model/modules/attention.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Attention functions """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo, Miguel Eduardo Ortiz Huamaní and Marcos V. Conde """ # General purpose imports import pdb from typing import Optional, Tuple # DL & Math imports import numpy as np import ...
21,284
38.271218
136
py
mapfe4mp
mapfe4mp-master/model/modules/set_transformer.py
import math import pdb import torch import torch.nn as nn import torch.nn.functional as F # Multi-Head Attention Block # ln = layer normalization class MAB(nn.Module): def __init__(self, dim_Q, dim_K, dim_V, num_heads, do=0.1, ln=False): super(MAB, self).__init__() self.dim_V = dim_V self....
2,519
33.054054
77
py
mapfe4mp
mapfe4mp-master/model/modules/decoders.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Decoder functions """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo, Miguel Eduardo Ortiz Huamaní and Marcos V. Conde """ # General purpose imports import pdb # DL & Math imports import torch from torch import nn import torch.nn.functional as...
11,456
39.059441
126
py
mapfe4mp
mapfe4mp-master/model/modules/encoders.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Encoder functions """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo, Miguel Eduardo Ortiz Huamaní and Marcos V. Conde """ # General purpose imports import pdb # DL & Math imports import torch from torch import nn import torch.nn.functional as...
6,147
40.261745
135
py
mapfe4mp
mapfe4mp-master/model/models/cghformer.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## CGHFormer """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import math import numpy as np import pdb import time import sys # DL & Math imports import torch import torch.nn as nn import torch.nn.functional as F...
28,710
35.808974
148
py
mapfe4mp
mapfe4mp-master/model/models/mapfe4mp.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## MAPFE4MP: Map Features For Efficient Motion Prediction """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import math import numpy as np import pdb import time # DL & Math imports import torch import torch.nn as...
36,019
39.111359
152
py
mapfe4mp
mapfe4mp-master/model/models/other/pv_lstm.py
## STABLE # import torch # import torch.nn as nn # import torch.nn.functional as F # import torch.optim as optim # import torchvision # import torchvision.transforms as transforms # import pdb # # Variation of the PV_LSTM network with position decoder # class TrajectoryGenerator(nn.Module): # def __init__(self,...
7,060
37.167568
123
py
mapfe4mp
mapfe4mp-master/model/models/other/sophie_mm.py
import os import math import random import copy import time import numpy as np import pdb from model.datasets.argoverse.dataset import PHYSICAL_CONTEXT from model.modules.attention import MultiHeadAttention from model.modules.layers import Linear import torch import torch.nn as nn import torch.nn.functional as F fro...
28,892
39.523142
128
py
mapfe4mp
mapfe4mp-master/model/models/other/social_lstm_mhsa.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## LSTM based Encoder-Decoder with Multi-Head Self Attention """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo, Miguel Eduardo Ortiz Huamaní and Marcos V. Conde """ # General purpose imports from os import path import pdb import math # DL & Math...
10,282
40.800813
132
py
mapfe4mp
mapfe4mp-master/model/models/other/social_set_transformer_mm.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Argoverse dataset """ Created on Mon May 23 17:54:37 2022 @author: Miguel Eduardo Ortiz Huamaní, Marcos V. Conde and Carlos Gómez-Huélamo """ # General purpose imports import random import os import time from operator import itemgetter import pdb # DL & Math impo...
4,013
36.166667
120
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/data_augmentation_functions.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Data augmentation functions """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import random import math import pdb import copy # DL & Math imports import numpy as np import torch import cv2 from sklearn import li...
4,810
29.257862
104
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/dataset_utils.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Dataloader utils """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import copy import os import csv import glob, glob2 import pdb import time # DL & Math imports import numpy as np import torch import cv2 import ...
15,230
35.437799
133
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/geometric_functions.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Geometric functions """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import random import math import pdb import copy # DL & Math imports import numpy as np import torch import c...
6,612
25.991837
141
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/map_functions.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- """ Created on Mon Feb 7 12:33:19 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import time import pdb import os import git import copy from typing import Any, Dict, List, Tuple, Union from shapely.geometry import L...
52,957
36.399718
153
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/dataset.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Argoverse dataset """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import random import math import os import time import operator import copy import pdb import sys # DL & Math im...
54,280
52.743564
173
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/plot_functions.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Visualization functions """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import pdb import os import time from collections import defaultdict, OrderedDict from typing import Dict # DL & Math imports import numpy...
13,503
32.508685
120
py
mapfe4mp
mapfe4mp-master/model/datasets/argoverse/goal_points_functions.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Goal points functions """ Created on Sun Mar 06 23:47:19 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import random import math import pdb import copy import os import time # DL & Math imports import numpy as np import torch import torchvisio...
19,476
35.135436
136
py
mapfe4mp
mapfe4mp-master/model/utils/utils.py
import torch import copy import pdb import numpy as np import torch.nn as nn # Model parameters functions def create_weights(batch, vmin, vmax, w_len=30, w_type="linear"): """ """ w = torch.ones(w_len) if w_type == "linear": w = torch.linspace(vmin, vmax, w_len) elif w_type == "exponential...
1,742
25.409091
65
py
mapfe4mp
mapfe4mp-master/model/utils/load_models.py
import torch from torch import nn import torchvision import torchvision.models as models def load_VGG_model(vgg_type=19, batch_norm=False, pretrained=True, features= True): """ vgg_type : {A, B, D, E} Paper: Very Deep Convolutional Networks For Large-Scale Image Recognition Trained on Imagenet """ ...
1,274
31.692308
86
py
mapfe4mp
mapfe4mp-master/model/utils/checkpoint_data.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Load checkpoint and generator """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import pdb import os import importlib from collections import defaultdict # DL & Math imports import torch #######################...
4,298
31.568182
93
py
mapfe4mp
mapfe4mp-master/model/trainers/trainer_cghformer.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import gc import os import numpy as np import pdb import time import copy import importlib # DL & Math imports import torch import torch.nn as nn import t...
65,880
42.979306
172
py
mapfe4mp
mapfe4mp-master/model/trainers/trainer_mapfe4mp.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import gc import os import numpy as np import pdb import time import copy # DL & Math imports import torch import torch.nn as nn import torch.optim as opt...
60,644
43.105455
172
py
mapfe4mp
mapfe4mp-master/model/trainers/other/trainer_pv_lstm.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer LSTM based Encoder-Decoder Position-Velocity """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import gc import os import numpy as np import pdb import time import copy # D...
35,721
42.19468
151
py
mapfe4mp
mapfe4mp-master/model/trainers/other/trainer_social_set_transformer_mm.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer Set Transformer Multimodal """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import gc import os import numpy as np import pdb import time import copy # DL & Math imports ...
25,929
39.326594
151
py
mapfe4mp
mapfe4mp-master/model/trainers/other/trainer_sophie_mm.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer LSTM based Encoder-Decoder with Multi-Head Self Attention """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo """ # General purpose imports import gc import os import numpy as np import pdb import time import sys import copy # DL & Math ...
51,779
43.637931
170
py
mapfe4mp
mapfe4mp-master/model/trainers/other/trainer_social_lstm_mhsa.py
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- ## Trainer LSTM based Encoder-Decoder with Multi-Head Self Attention """ Created on Fri Feb 25 12:19:38 2022 @author: Carlos Gómez-Huélamo and Miguel Eduardo Ortiz Huamaní """ # General purpose imports import gc import os import numpy as np import pdb import time imp...
36,686
42.468009
151
py
mapfe4mp
mapfe4mp-master/model/trainers/other/trainer_gan_social_lstm_mhsa.py
# Doc GANs: https://developers.google.com/machine-learning/gan import argparse import gc import logging import os import sys import time import pdb import numpy as np import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader import torch.optim.lr_scheduler as lrs from torc...
30,927
40.347594
151
py
sam-hq
sam-hq-main/segment_anything/automatic_mask_generator.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 numpy as np import torch from torchvision.ops.boxes import batched_nms, box_area # type: ignore from typing impor...
15,354
39.946667
108
py
sam-hq
sam-hq-main/segment_anything/build_sam_baseline.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 functools import partial from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa...
4,702
29.147436
98
py
sam-hq
sam-hq-main/segment_anything/predictor.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 numpy as np import torch from .modeling import Sam from typing import Optional, Tuple from .utils.transforms imp...
11,935
42.090253
100
py
sam-hq
sam-hq-main/segment_anything/build_sam.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 functools import partial from .modeling import ImageEncoderViT, MaskDecoderHQ, PromptEncoder, Sam, Two...
5,324
30.696429
156
py
sam-hq
sam-hq-main/segment_anything/utils/onnx.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 from torch.nn import functional as F from typing import Tuple from ..modeling import ...
6,233
38.961538
139
py
sam-hq
sam-hq-main/segment_anything/utils/amg.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 numpy as np import torch import math from copy import deepcopy from itertools import product from typing import An...
12,712
35.636888
88
py
sam-hq
sam-hq-main/segment_anything/utils/transforms.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 numpy as np import torch from torch.nn import functional as F from torchvision.transforms.functional import resize,...
3,972
37.572816
99
py
sam-hq
sam-hq-main/segment_anything/modeling/mask_decoder.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 nn from torch.nn import functional as F from typing import List, Tuple, Type from .common...
6,685
36.351955
123
py
sam-hq
sam-hq-main/segment_anything/modeling/mask_decoder_hq.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # Modified by HQ-SAM team # 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 nn from torch.nn import functional as F from typing import List,...
9,784
40.995708
135
py
sam-hq
sam-hq-main/segment_anything/modeling/image_encoder.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 typing import Optional, Tuple, Type from .common...
14,549
35.466165
202
py
sam-hq
sam-hq-main/segment_anything/modeling/prompt_encoder.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 numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Type from .common import L...
8,594
38.976744
97
py
sam-hq
sam-hq-main/segment_anything/modeling/tiny_vit_sam.py
# -------------------------------------------------------- # TinyViT Model Architecture # Copyright (c) 2022 Microsoft # Adapted from LeViT and Swin Transformer # LeViT: (https://github.com/facebookresearch/levit) # Swin: (https://github.com/microsoft/swin-transformer) # Build the TinyViT Model # ------------------...
25,091
33.609655
122
py
sam-hq
sam-hq-main/segment_anything/modeling/transformer.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 Tensor, nn import math from typing import Tuple, Type from .common import MLPBlock clas...
8,397
33.846473
89
py
sam-hq
sam-hq-main/segment_anything/modeling/common.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 from typing import Type class MLPBlock(nn.Module): def __init__( self, ...
1,479
32.636364
136
py
sam-hq
sam-hq-main/segment_anything/modeling/sam.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 nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
7,473
40.988764
113
py
sam-hq
sam-hq-main/scripts/export_onnx_model.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 segment_anything import sam_model_registry from segment_anything.utils.onnx import SamOnnxModel import...
7,022
31.068493
121
py
sam-hq
sam-hq-main/train/train.py
# Copyright by HQ-SAM team # 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 argparse import numpy as np import torch import torch.optim as optim import torch.nn as nn import torch.nn.functional as F from tor...
30,634
43.079137
169
py
sam-hq
sam-hq-main/train/segment_anything_training/build_sam.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 functools import partial from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa...
2,929
26.12963
89
py
sam-hq
sam-hq-main/train/segment_anything_training/utils/transforms.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 numpy as np import torch from torch.nn import functional as F from torchvision.transforms.functional import resize,...
3,968
37.533981
99
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/mask_decoder.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 nn from torch.nn import functional as F from typing import List, Tuple, Type from .common...
6,615
36.378531
123
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/image_encoder.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 typing import Optional, Tuple, Type from .common...
14,576
35.533835
202
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/prompt_encoder.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 numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Type from .common import L...
8,594
38.976744
97
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/transformer.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 Tensor, nn import math from typing import Tuple, Type from .common import MLPBlock clas...
8,396
33.842324
89
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/common.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 from typing import Type class MLPBlock(nn.Module): def __init__( self, ...
1,479
32.636364
136
py
sam-hq
sam-hq-main/train/segment_anything_training/modeling/sam.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 nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
7,540
40.20765
95
py
sam-hq
sam-hq-main/train/utils/dataloader.py
# Copyright by HQ-SAM team # All rights reserved. ## data loader from __future__ import print_function, division import numpy as np import random from copy import deepcopy from skimage import io import os from glob import glob import torch from torch.utils.data import Dataset, DataLoader, ConcatDataset from torchvis...
10,833
38.830882
151
py
sam-hq
sam-hq-main/train/utils/misc.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Misc functions, including distributed helpers. Mostly copy-paste from torchvision references. """ import os import random import subprocess import time from collections import OrderedDict, defaultdict, deque import datetime import pickle from ...
17,694
31.951583
160
py
sam-hq
sam-hq-main/train/utils/loss_mask.py
import torch from torch.nn import functional as F from typing import List, Optional import utils.misc as misc def point_sample(input, point_coords, **kwargs): """ A wrapper around :function:`torch.nn.functional.grid_sample` to support 3D point_coords tensors. Unlike :function:`torch.nn.functional.grid_samp...
7,836
38.781726
100
py
sam-hq
sam-hq-main/demo/demo_sam.py
import numpy as np import torch import matplotlib.pyplot as plt import cv2 from segment_anything import sam_model_registry_baseline, SamPredictor import os def show_mask(mask, ax, random_color=False): if random_color: color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0) else: ...
5,002
38.085938
128
py
sam-hq
sam-hq-main/demo/demo_hqsam_light.py
import numpy as np import torch import matplotlib.pyplot as plt import cv2 from segment_anything import sam_model_registry, SamPredictor import os def show_mask(mask, ax, random_color=False): if random_color: color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0) else: color = n...
5,089
35.099291
145
py
sam-hq
sam-hq-main/demo/demo_hqsam.py
import numpy as np import torch import matplotlib.pyplot as plt import cv2 from segment_anything import sam_model_registry, SamPredictor import os def show_mask(mask, ax, random_color=False): if random_color: color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0) else: color = n...
5,729
37.716216
149
py
sam-hq
sam-hq-main/seginw/test_ap_on_seginw.py
# modified from https://github.com/IDEA-Research/GroundingDINO/blob/main/demo/test_ap_on_coco.py import argparse import os import sys import time import numpy as np import torch import torch.nn as nn from torch.utils.data import DataLoader, DistributedSampler from groundingdino.models import build_model import grou...
11,126
35.722772
128
py
sam-hq
sam-hq-main/seginw/segment_anything/automatic_mask_generator.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 numpy as np import torch from torchvision.ops.boxes import batched_nms, box_area # type: ignore from typing impor...
15,132
39.571046
92
py
sam-hq
sam-hq-main/seginw/segment_anything/predictor.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 numpy as np import torch from .modeling import Sam from typing import Optional, Tuple from .utils.transforms imp...
11,934
42.242754
100
py
sam-hq
sam-hq-main/seginw/segment_anything/build_sam.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 functools import partial from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa...
2,929
26.12963
89
py
sam-hq
sam-hq-main/seginw/segment_anything/build_sam_hq.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 functools import partial from .modeling import ImageEncoderViT, MaskDecoderHQ, PromptEncoder, Sam, Two...
3,290
28.123894
156
py
sam-hq
sam-hq-main/seginw/segment_anything/utils/onnx.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 from torch.nn import functional as F from typing import Tuple from ..modeling import ...
5,790
38.937931
100
py
sam-hq
sam-hq-main/seginw/segment_anything/utils/amg.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 numpy as np import torch import math from copy import deepcopy from itertools import product from typing import An...
12,711
35.634006
88
py
sam-hq
sam-hq-main/seginw/segment_anything/utils/transforms.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 numpy as np import torch from torch.nn import functional as F from torchvision.transforms.functional import resize,...
3,968
37.533981
99
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/mask_decoder.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 nn from torch.nn import functional as F from typing import List, Tuple, Type from .common...
6,684
36.55618
123
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/mask_decoder_hq.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # Modified by HQ-SAM team # 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 nn from torch.nn import functional as F from typing import List,...
9,783
41.172414
135
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/image_encoder.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 typing import Optional, Tuple, Type from .common...
14,548
35.555276
202
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/prompt_encoder.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 numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Type from .common import L...
8,594
38.976744
97
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/transformer.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 Tensor, nn import math from typing import Tuple, Type from .common import MLPBlock clas...
8,396
33.842324
89
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/common.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 from typing import Type class MLPBlock(nn.Module): def __init__( self, ...
1,479
32.636364
136
py
sam-hq
sam-hq-main/seginw/segment_anything/modeling/sam.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 nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
7,225
40.291429
95
py
sam-hq
sam-hq-main/seginw/GroundingDINO/setup.py
# coding=utf-8 # Copyright 2022 The IDEA Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
7,646
34.239631
125
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/fuse_modules.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
11,825
38.684564
131
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/transformer_vanilla.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
4,020
31.427419
110
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/utils.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
10,087
36.501859
117
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
16,691
41.151515
117
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/transformer.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
36,805
37.339583
109
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/bertwarper.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
12,242
43.682482
213
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/ms_deform_attn.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
15,482
36.398551
108
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/backbone/swin_transformer.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
29,339
35.537983
139
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/backbone/position_encoding.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
6,866
35.721925
110
py