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 |
|---|---|---|---|---|---|---|
Transformer-Cycle-GAN | Transformer-Cycle-GAN-main/Dataset.py | import os
import numpy as np
from PIL import Image
from torch.utils.data import Dataset
class ABDataset(Dataset):
def __init__(self, root_a, root_b=None, transform=None):
self.root_a = root_a
self.root_b = root_b
self.transform = transform
self.a_images = os.listdir(root_a)
... | 1,592 | 31.510204 | 73 | py |
Transformer-Cycle-GAN | Transformer-Cycle-GAN-main/Test.py | import time
import gc
import torch
import math
import albumentations as A
import numpy as np
from albumentations.pytorch import ToTensorV2
from torch.utils.data import DataLoader
from torchvision.utils import save_image
from tqdm import tqdm
# from torchsummary import summary
# from torchmetrics import PeakSignalNoise... | 3,139 | 23.341085 | 97 | py |
Transformer-Cycle-GAN | Transformer-Cycle-GAN-main/Utils.py | import torch
import os
import random
import numpy as np
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def save_checkpoint(model, optimizer, filename="my_checkpoint.pth.tar"):
checkpoint = {
"state_dict": model.state_dict(),
"optimizer": optimizer.state_dict(),
}
to... | 1,196 | 28.925 | 84 | py |
Transformer-Cycle-GAN | Transformer-Cycle-GAN-main/Model.py | import torch
from torch import nn
# from torchsummary import summary
class ImgPatches(nn.Module):
def __init__(self, input_channel=3, dim=1024, patch_size=8):
super().__init__()
self.patch_embed = nn.Conv2d(input_channel, dim,
kernel_size=patch_size, stride=pat... | 7,053 | 32.751196 | 116 | py |
Transformer-Cycle-GAN | Transformer-Cycle-GAN-main/Train.py | import torch
from torch import nn
from torch import optim
from torch.utils.data import DataLoader
from torchvision.utils import save_image
import albumentations as A
from albumentations.pytorch import ToTensorV2
from tqdm import tqdm
# from torchsummary import summary
from Utils import save_checkpoint, load_checkpoint... | 5,852 | 30.132979 | 109 | py |
PRIN | PRIN-master/test.py | import torch.utils.data
import torch
import types
import importlib.machinery
import os
import numpy as np
import h5py
import hyper
from dataset import MyDataset
data_path = "./hdf5_data"
N_PARTS = hyper.N_PARTS
N_CATS = hyper.N_CATS
seg_classes = {'Earphone': [16, 17, 18], 'Motorbike': [30, 31, 32, 33, 34, 35], 'Ro... | 5,790 | 34.09697 | 390 | py |
PRIN | PRIN-master/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from s2cnn import s2_equatorial_grid, S2Convolution, so3_equatorial_grid, SO3Convolution, so3_integrate, soft
import hyper
class Model(nn.Module):
def __init__(self, nclasses):
super().__init__()
self.features = [hyper.R_IN, 40, ... | 2,229 | 36.166667 | 120 | py |
PRIN | PRIN-master/dataset.py | import os
import numpy as np
import torch.utils.data
from lie_learn.spaces import S2
import hyper
import sys
sys.path.append('./src/build')
from sampling import compute
def rotmat(a, b, c, hom_coord=False): # apply to mesh using mesh.apply_transform(rotmat(a,b,c, True))
"""
Create a rotation matrix with an o... | 3,304 | 31.087379 | 148 | py |
PRIN | PRIN-master/train.py | import torch
import torch.nn.functional as F
from torch.utils.data import Sampler, BatchSampler
import os
import shutil
import time
import logging
import copy
import types
import importlib.machinery
import numpy as np
import h5py
import hyper
from dataset import MyDataset
from test import load_test_set
data_path = "... | 10,099 | 37.697318 | 390 | py |
MP-SPDZ | MP-SPDZ-master/Compiler/ml.py | """
This module contains machine learning functionality. It is work in
progress, so you must expect things to change. The only tested
functionality for training is using consecutive layers.
This includes logistic regression. It can be run as
follows::
sgd = ml.SGD([ml.Dense(n_examples, n_features, 1),
... | 139,720 | 38.369118 | 172 | py |
MP-SPDZ | MP-SPDZ-master/Scripts/torch_mnist_lenet_import.py | #!/usr/bin/env python3
# test model output by torch_mnist_lenet_predict.mpc
import torchvision
import torch
import torch.nn as nn
import numpy
net = nn.Sequential(
nn.Conv2d(1, 20, 5),
nn.ReLU(),
nn.MaxPool2d(2),
nn.Conv2d(20, 50, 5),
nn.ReLU(),
nn.MaxPool2d(2),
nn.Flatten(),
nn.ReLU(... | 1,327 | 24.538462 | 69 | py |
MP-SPDZ | MP-SPDZ-master/Scripts/torch_cifar_alex_import.py | #!/usr/bin/env python3
# test model output by torch_alex_test.mpc
import torchvision
import torch
import torch.nn as nn
import numpy
net = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=2),
nn.ReLU(),
nn.MaxPool2d(kernel_size=2),
nn.Conv2d(64, 96, kernel_size=3, padding=2),
nn.R... | 1,735 | 27 | 70 | py |
MP-SPDZ | MP-SPDZ-master/Scripts/torch_mnist_dense_import.py | #!/usr/bin/env python3
# test model output by torch_mnist_dense.mpc
import torchvision
import torch
import torch.nn as nn
import numpy
net = nn.Sequential(
nn.Flatten(),
nn.Linear(28 * 28, 128),
nn.ReLU(),
nn.Linear(128, 128),
nn.ReLU(),
nn.Linear(128, 10)
)
f = open('Player-Data/Binary-Outp... | 1,225 | 25.085106 | 69 | py |
MP-SPDZ | MP-SPDZ-master/doc/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 5,829 | 28.004975 | 79 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/val.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Validate a trained YOLOv5 detection model on a detection dataset
Usage:
$ python val.py --weights yolov5s.pt --data coco128.yaml --img 640
Usage - formats:
$ python val.py --weights yolov5s.pt # PyTorch
yolov5s.torch... | 20,224 | 48.692875 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/export.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Export a YOLOv5 PyTorch model to other formats. TensorFlow exports authored by https://github.com/zldrobit
Format | `export.py --include` | Model
--- | --- | ---
PyTorch | ... | 31,532 | 47.289433 | 147 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/detect.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Run YOLOv5 detection inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
Usage - sources:
$ python detect.py --weights yolov5s.pt --source 0 # webcam
img.jp... | 13,982 | 52.988417 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/benchmarks.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Run YOLOv5 benchmarks on all supported export formats
Format | `export.py --include` | Model
--- | --- | ---
PyTorch | - | yolov5s.pt
TorchScrip... | 7,829 | 45.058824 | 119 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/hubconf.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5
Usage:
import torch
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # official model
model = torch.hub.load('ultralytics/yolov5:master', 'yolov5s') # from branch
model = torch.hub.loa... | 7,700 | 44.3 | 117 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/train.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Train a YOLOv5 model on a custom dataset.
Models and datasets download automatically from the latest YOLOv5 release.
Usage - Single-GPU training:
$ python train.py --data coco128.yaml --weights yolov5s.pt --img 640 # from pretrained (recommended)
$ python train.... | 35,611 | 50.988321 | 149 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/classify/val.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Validate a trained YOLOv5 classification model on a classification dataset
Usage:
$ bash data/scripts/get_imagenet.sh --val # download ImageNet val split (6.3G, 50000 images)
$ python classify/val.py --weights yolov5m-cls.pt --data ../datasets/imagenet --img 224... | 8,020 | 46.182353 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/classify/predict.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Run YOLOv5 classification inference on images, videos, directories, globs, YouTube, webcam, streams, etc.
Usage - sources:
$ python classify/predict.py --weights yolov5s-cls.pt --source 0 # webcam
... | 11,379 | 49.803571 | 124 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/classify/train.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Train a YOLOv5 classifier model on a classification dataset
Usage - Single-GPU training:
$ python classify/train.py --model yolov5s-cls.pt --data imagenette160 --epochs 5 --img 224
Usage - Multi-GPU DDP training:
$ python -m torch.distributed.run --nproc_per_nod... | 16,201 | 47.801205 | 167 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/models/yolo.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
YOLO-specific modules
Usage:
$ python models/yolo.py --cfg yolov5s.yaml
"""
import argparse
import contextlib
import os
import platform
import sys
from copy import deepcopy
from pathlib import Path
FILE = Path(__file__).resolve()
ROOT = FILE.parents[1] # YOLOv5 ro... | 17,763 | 44.316327 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/models/tf.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
TensorFlow, Keras and TFLite versions of YOLOv5
Authored by https://github.com/zldrobit in PR https://github.com/ultralytics/yolov5/pull/1127
Usage:
$ python models/tf.py --weights yolov5s.pt
Export:
$ python export.py --weights yolov5s.pt --include saved_model ... | 27,015 | 43.361248 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/models/common.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Common modules
"""
import ast
import contextlib
import json
import math
import platform
import warnings
import zipfile
from collections import OrderedDict, namedtuple
from copy import copy
from pathlib import Path
from urllib.parse import urlparse
import cv2
import nump... | 41,483 | 47.181185 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/models/experimental.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Experimental modules
"""
import math
import numpy as np
import torch
import torch.nn as nn
from utils.downloads import attempt_download
class Sum(nn.Module):
# Weighted sum of 2 or more layers https://arxiv.org/abs/1911.09070
def __init__(self, n, weight=False... | 4,316 | 37.544643 | 116 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/segment/val.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Validate a trained YOLOv5 segment model on a segment dataset
Usage:
$ bash data/scripts/get_coco.sh --val --segments # download COCO-segments val split (1G, 5000 images)
$ python segment/val.py --weights yolov5s-seg.pt --data coco.yaml --img 640 # validate COCO... | 23,817 | 49.569002 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/segment/predict.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Run YOLOv5 segmentation inference on images, videos, directories, streams, etc.
Usage - sources:
$ python segment/predict.py --weights yolov5s-seg.pt --source 0 # webcam
i... | 14,890 | 53.346715 | 123 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/segment/train.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Train a YOLOv5 segment model on a segment dataset
Models and datasets download automatically from the latest YOLOv5 release.
Usage - Single-GPU training:
$ python segment/train.py --data coco128-seg.yaml --weights yolov5s-seg.pt --img 640 # from pretrained (recommen... | 34,890 | 51.625943 | 165 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/augmentations.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Image augmentation functions
"""
import math
import random
import cv2
import numpy as np
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as TF
from utils.general import LOGGER, check_version, colorstr, resample_segments, segment... | 17,130 | 41.8275 | 118 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/loss.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Loss functions
"""
import torch
import torch.nn as nn
from utils.metrics import bbox_iou
from utils.torch_utils import de_parallel
def smooth_BCE(eps=0.1): # https://github.com/ultralytics/yolov3/issues/238#issuecomment-598028441
# return positive, negative label... | 9,916 | 41.2 | 119 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/autobatch.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Auto-batch utils
"""
from copy import deepcopy
import numpy as np
import torch
from utils.general import LOGGER, colorstr
from utils.torch_utils import profile
def check_train_batch_size(model, imgsz=640, amp=True):
# Check YOLOv5 training batch size
with tor... | 2,976 | 39.780822 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/autoanchor.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
AutoAnchor utils
"""
import random
import numpy as np
import torch
import yaml
from tqdm import tqdm
from utils import TryExcept
from utils.general import LOGGER, colorstr
PREFIX = colorstr('AutoAnchor: ')
def check_anchor_order(m):
# Check anchor order against ... | 7,399 | 42.529412 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/plots.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Plotting utils
"""
import contextlib
import math
import os
from copy import copy
from pathlib import Path
from urllib.error import URLError
import cv2
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sn
import to... | 25,273 | 42.878472 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/downloads.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Download utils
"""
import logging
import os
import subprocess
import urllib
from pathlib import Path
import requests
import torch
def is_url(url, check=True):
# Check if string is URL and check if URL exists
try:
url = str(url)
result = urllib.... | 4,648 | 41.651376 | 119 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/dataloaders.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Dataloaders and dataset utils
"""
import contextlib
import glob
import hashlib
import json
import math
import os
import random
import shutil
import time
from itertools import repeat
from multiprocessing.pool import Pool, ThreadPool
from pathlib import Path
from threading... | 55,546 | 44.493038 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/torch_utils.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
PyTorch utils
"""
import math
import os
import platform
import subprocess
import time
import warnings
from contextlib import contextmanager
from copy import deepcopy
from pathlib import Path
import torch
import torch.distributed as dist
import torch.nn as nn
import torc... | 19,563 | 44.287037 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/metrics.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Model validation metrics
"""
import math
import warnings
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
from utils import TryExcept, threaded
def fitness(x):
# Model fitness as a weighted combination of metrics
w = [0... | 14,704 | 38.850949 | 120 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/activations.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Activation functions
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
class SiLU(nn.Module):
# SiLU activation https://arxiv.org/pdf/1606.08415.pdf
@staticmethod
def forward(x):
return x * torch.sigmoid(x)
class Hardswish(nn.... | 3,446 | 32.144231 | 106 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/__init__.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
utils/initialization
"""
import contextlib
import platform
import threading
def emojis(str=''):
# Return platform-dependent emoji-safe version of string
return str.encode().decode('ascii', 'ignore') if platform.system() == 'Windows' else str
class TryExcept(c... | 1,954 | 26.535211 | 113 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/general.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
General utils
"""
import contextlib
import glob
import inspect
import logging
import math
import os
import platform
import random
import re
import shutil
import signal
import sys
import time
import urllib
from copy import deepcopy
from datetime import datetime
from itert... | 47,348 | 40.173043 | 134 | py |
iquaflow-airport-use-case | iquaflow-airport-use-case-main/yolov5/utils/triton.py | # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
""" Utils to interact with the Triton Inference Server
"""
import typing
from urllib.parse import urlparse
import torch
class TritonRemoteModel:
""" A wrapper over a model served by the Triton Inference Server. It can
be configured to communicate over GRPC or HTTP... | 3,631 | 41.232558 | 120 | py |
MAK | MAK-main/train_imagenet.py | from __future__ import print_function
import os
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import transforms
from utils import setup_seed
from models.resnet import resnet18, resnet10, resnet50
import time
from utils import AverageMete... | 15,873 | 36.527187 | 153 | py |
MAK | MAK-main/utils.py | import torch
import torch.nn as nn
import os
import numpy as np
import random
import torch.nn.functional as F
import re
def normalize_fn(tensor, mean, std):
"""Differentiable version of torchvision.functional.normalize"""
# here we assume the color channel is in at dim=1
mean = mean[None, :, None, None]
... | 7,961 | 29.389313 | 107 | py |
MAK | MAK-main/sampling.py | import os
import sys
sys.path.append(".")
import numpy as np
from os.path import join
import torch
from utils import nt_xent_inter_batch_multiple_time, AverageMeter
from sklearn.cluster import KMeans as Kmeans_sklearn
import torch.nn.functional as F
import time
import argparse
from pdb import set_trace
def reOrderDat... | 14,345 | 47.630508 | 169 | py |
MAK | MAK-main/train_simCLR.py | import argparse
import os
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.datasets as datasets
from torch.utils.data.sampler import SubsetRandomSampler
from models.resnet import resnet18, resnet10, resnet50, resnet101, resnet152
from ... | 17,853 | 39.577273 | 171 | py |
MAK | MAK-main/models/resnet.py | import torch
import torch.nn as nn
from torchvision.models.utils import load_state_dict_from_url
from utils import NormalizeByChannelMeanStd
from pdb import set_trace
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide_r... | 15,242 | 37.78626 | 107 | py |
MAK | MAK-main/models/utils.py | import torch
import torch.nn as nn
def normalize_fn(tensor, mean, std):
"""Differentiable version of torchvision.functional.normalize"""
# here we assume the color channel is in at dim=1
mean = mean[None, :, None, None]
std = std[None, :, None, None]
return tensor.sub(mean).div(std)
class Normal... | 1,631 | 26.661017 | 68 | py |
MAK | MAK-main/data/utils.py | import torch
import torch.nn.functional as F
import math
def gaussian_kernel(size, sigma=2., dim=2, channels=3):
# The gaussian kernel is the product of the gaussian function of each dimension.
# kernel_size should be an odd number.
kernel_size = 2 * size + 1
kernel_size = [kernel_size] * dim
sigma = [sig... | 1,202 | 27.642857 | 96 | py |
MAK | MAK-main/data/LT_Dataset.py | import torch
from torch.utils.data import Dataset
import os
from PIL import Image
import cv2
import random
import numpy as np
import pickle
from matplotlib import pyplot as plt
from pdb import set_trace
# from data.utils import _gaussian_blur
import torch.distributed as dist
import torchvision.transforms as transforms
... | 3,959 | 27.285714 | 98 | py |
MAK | MAK-main/inference/inference_save.py | import time
import torch
from torch import nn
from utils import AverageMeter
import numpy as np
from os.path import join
import time
from utils import gather_tensor
from pdb import set_trace
def inference_save(inference_loader, model, log, local_rank, world_size, args, repeat_time,
inference_loader... | 4,758 | 42.66055 | 126 | py |
nexmon | nexmon-master/utilities/libpcap/testprogs/visopts.py | #!/usr/bin/env python
"""
This program parse the output from pcap_compile() to visualize the CFG after
each optimize phase.
Usage guide:
1. Enable optimizier debugging code when configure libpcap,
and build libpcap & the test programs
./configure --enable-optimizer-dbg
make
make testprogs
2. R... | 10,073 | 31.392283 | 139 | py |
NAISR | NAISR-main/naisr_meshing.py | '''From the DeepSDF repository https://github.com/facebookresearch/DeepSDF
'''
# !/usr/bin/env python3
import logging
import numpy
import numpy as np
import plyfile
import skimage.measure as measure
import time
import torch
import os
import pyvista as pv
import dataio
import matplotlib.pyplot as plt
import point_clou... | 52,337 | 35.651261 | 216 | py |
NAISR | NAISR-main/vis_reconstructions_comp.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
import naisr_meshing
from naisr import loss_pointcloud_s... | 3,742 | 30.720339 | 115 | py |
NAISR | NAISR-main/visualization.py | import numpy as np
import pyvista as pv
from pyvista import examples
import argparse
import logging
import json
import numpy as np
import os
import pandas as pd
import trimesh
import csv
import naisr
import naisr.workspace as ws
import glob
import re
import torch.utils.data as data_utils
import torch
import time
imp... | 11,247 | 28.291667 | 150 | py |
NAISR | NAISR-main/evolution.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 11,871 | 41.551971 | 166 | py |
NAISR | NAISR-main/test.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 4,460 | 29.979167 | 204 | py |
NAISR | NAISR-main/dataio.py | import csv
import glob
import math
import os
import matplotlib.colors as colors
import numpy as np
import scipy.io.wavfile as wavfile
import scipy.ndimage
import scipy.special
import skimage
import skimage.filters
import torch
from PIL import Image
from torch.utils.data import Dataset
from torchvision.transforms impo... | 34,551 | 38.578465 | 121 | py |
NAISR | NAISR-main/evaluate.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import logging
import json
import numpy as np
import os
import pandas as pd
import trimesh
import csv
import naisr
import naisr.workspace as ws
import glob
import re
import torch.utils.data as data_utils
import torch
impor... | 15,107 | 32.798658 | 202 | py |
NAISR | NAISR-main/reconstruct_atlas.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
import naisr_meshing
from naisr import loss_pointcloud_s... | 10,398 | 34.858621 | 130 | py |
NAISR | NAISR-main/train_atlas_3dnaigsr.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import torch
import torch.utils.data as data_utils
from torch.nn import functional as F
import signal
import torch
import utils
from torch.utils.tensorboard import SummaryWriter
from tqdm.autonotebook import tqdm
import time
import numpy a... | 19,487 | 34.176895 | 157 | py |
NAISR | NAISR-main/utils.py | import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import torch
import dataio
import os
import pickle as pk
import open3d as o3d
# Monkey-patch torch.utils.tensorboard.SummaryWriter
from open3d.visualization.tensorboard_plugin import summary
# Utility function to convert Open3D g... | 48,355 | 47.501505 | 208 | py |
NAISR | NAISR-main/vis_transport.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
from naisr import loss_pointcloud_sdf
import naisr_meshi... | 8,986 | 40.8 | 131 | py |
NAISR | NAISR-main/print_meshes.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
from naisr import loss_pointcloud_sdf
import naisr_meshi... | 8,568 | 36.419214 | 123 | py |
NAISR | NAISR-main/evolution_shapematrix_specific.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 7,803 | 35.297674 | 128 | py |
NAISR | NAISR-main/visualizer.py |
import logging
import numpy as np
import plyfile
import skimage.measure as measure
import time
import torch
import os
import pyvista as pv
import dataio
import matplotlib.pyplot as plt
from utils import *
#import point_cloud_utils as pcu
#import hausdorff
import trimesh
from naisr import diff_operators
import pickle
... | 35,651 | 38.790179 | 187 | py |
NAISR | NAISR-main/vis_transport_general.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
from naisr import loss_pointcloud_sdf
import naisr_meshi... | 9,179 | 41.697674 | 139 | py |
NAISR | NAISR-main/visualization_landmark.py | import numpy as np
import pyvista as pv
from pyvista import examples
import argparse
import logging
import json
import numpy as np
import os
import pandas as pd
import trimesh
import csv
import naisr
import naisr.workspace as ws
import glob
import re
import torch.utils.data as data_utils
import torch
import time
imp... | 10,154 | 30.439628 | 138 | py |
NAISR | NAISR-main/transport_general.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
import naisr_meshing
from naisr import loss_pointcloud_s... | 14,159 | 39.573066 | 139 | py |
NAISR | NAISR-main/dientanglement.py | import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import torch.utils.data as data_utils
from naisr import loss_funcs
import naisr_meshing
import pandas as pd
def reconstruct(
model,
model_input,
... | 8,290 | 30.524715 | 110 | py |
NAISR | NAISR-main/evolution_shapematrix.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 6,888 | 35.068063 | 138 | py |
NAISR | NAISR-main/evolution_one_case.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 14,149 | 44.79288 | 176 | py |
NAISR | NAISR-main/template_transfer.py | '''Test script for experiments in paper Sec. 4.2, Supplement Sec. 3, reconstruction from laplacian.
'''
# Enable import from parent package
import os
import sys
import pandas as pd
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import naisr.modules
import naisr_meshing
im... | 7,914 | 36.690476 | 114 | py |
NAISR | NAISR-main/transport.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import pandas as pd
import naisr_meshing
from naisr import loss_pointcloud_s... | 16,676 | 37.874126 | 138 | py |
NAISR | NAISR-main/reconstruct.py | import argparse
import json
import logging
import os
import random
import time
import torch
import naisr
import naisr.workspace as ws
from utils import cond_mkdir
import torch.utils.data as data_utils
from naisr import loss_funcs
import naisr_meshing
import pandas as pd
from naisr import *
def reconstruct(
model,
... | 7,852 | 30.665323 | 150 | py |
NAISR | NAISR-main/networks/ASDF_decoder.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import torch.nn as nn
import torch
import torch.nn.functional as F
import numpy as np
class Decoder(nn.Module):
def __init__(
self,
latent_size=253,
dims = [512,512,512,768,512,512,512,512],
dropout=[0,1... | 2,982 | 28.534653 | 82 | py |
NAISR | NAISR-main/networks/deep_implicit_template_decoder.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import torch.nn as nn
import torch
import torch.nn.functional as F
import numpy as np
import math
class SdfDecoder(nn.Module):
def __init__(
self,
dims,
dropout=None,
dropout_prob=0.0,
norm_laye... | 6,875 | 30.686636 | 101 | py |
NAISR | NAISR-main/networks/NAISR_decoder.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import torch.nn as nn
import torch
import torch.nn.functional as F
import numpy as np
class Decoder(nn.Module):
def __init__(
self,
latent_size=253,
dims = [512,512,512,768,512,512,512,512],
dropout=[0,1... | 2,982 | 28.534653 | 82 | py |
NAISR | NAISR-main/naisr/meta_modules.py | '''Modules for hypernetwork experiments, Paper Sec. 4.4
'''
import torch
from torch import nn
from collections import OrderedDict
import modules
class HyperNetwork(nn.Module):
def __init__(self, hyper_in_features, hyper_hidden_layers, hyper_hidden_features, hypo_module):
'''
Args:
hy... | 6,526 | 41.109677 | 121 | py |
NAISR | NAISR-main/naisr/modules.py | import torch
from torch import nn
#from torchmeta.modules import (MetaModule, MetaSequential)
#from torchmeta.modules.utils import get_subdict
import numpy as np
from collections import OrderedDict
import math
import torch.nn.functional as F
import torch
from torch import nn
from collections import OrderedDict
def lap... | 64,754 | 38.726994 | 296 | py |
NAISR | NAISR-main/naisr/loss_funcs.py | import numpy as np
import torch
import torch.nn.functional as F
import naisr.diff_operators as diff_operators
import naisr.modules as modules
def image_mse(mask, model_output, gt):
if mask is None:
return {'img_loss': ((model_output['model_out'] - gt['img']) ** 2).mean()}
else:
return {'img_l... | 76,414 | 43.739461 | 291 | py |
NAISR | NAISR-main/naisr/workspace.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import json
import os
import torch
model_params_subdir = 'checkpoints'
optimizer_params_subdir = "OptimizerParameters"
latent_codes_subdir = "latentcodes"
logs_filename = "Logs.pth"
recon_testset_subdir = "Results_recon_testset"
inter_test... | 16,702 | 24.976672 | 99 | py |
NAISR | NAISR-main/naisr/utils.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import logging
import torch
import torch.nn as nn
import numpy as np
import sys
import os
def add_common_args(arg_parser):
arg_parser.add_argument(
"--debug",
dest="debug",
default=False,
action="store_t... | 8,051 | 26.765517 | 98 | py |
NAISR | NAISR-main/naisr/model.py | import torch
from torch import nn
from collections import OrderedDict
from naisr.modules import SineLayer, Siren, BaseFCBlock, LipMLPBlock, LipBoundedPosEnc, BaseDeepSDF, BaseDeepSDFSiren #,HyperNetwork, NeuralProcessImplicitHypernet
import numpy as np
import naisr.diff_operators as diff_operators
import torch.nn.func... | 130,529 | 43.097973 | 275 | py |
NAISR | NAISR-main/naisr/data.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import glob
import logging
import numpy as np
import os
import random
import torch
import torch.utils.data
import pandas as pd
import pyvista as pv
import progressbar as pb
from multiprocessing import *
import blosc
def get_toy_instance_fi... | 95,097 | 41.81765 | 401 | py |
NAISR | NAISR-main/naisr/mesh.py | #!/usr/bin/env python3
# Copyright 2004-present Facebook. All Rights Reserved.
import logging
import numpy as np
import plyfile
import skimage.measure
import time
import torch
import naisr.utils
def create_mesh(
decoder, lat_vec, filename, N=256, max_batch=32 ** 3, offset=None, scale=None, atc_vec=None, do_sup_... | 4,641 | 29.339869 | 135 | py |
NAISR | NAISR-main/naisr/model_naigsr.py | import torch
from torch import nn
from collections import OrderedDict
from naisr.modules import SineLayer, Siren, BaseFCBlock, LipMLPBlock, LipBoundedPosEnc, BaseDeepSDF, \
BaseDeepSDFSiren # ,HyperNetwork, NeuralProcessImplicitHypernet
import numpy as np
import naisr.diff_operators as diff_operators
class Deep... | 15,742 | 41.779891 | 164 | py |
NAISR | NAISR-main/naisr/diff_operators.py | import torch
from torch.autograd import grad
def hessian(y, x):
''' hessian of y wrt x
y: shape (meta_batch_size, num_observations, channels)
x: shape (meta_batch_size, num_observations, 2)
'''
meta_batch_size, num_observations = y.shape[:2]
grad_y = torch.ones_like(y[..., 0]).to(y.device)
... | 1,915 | 28.9375 | 132 | py |
NAISR | NAISR-main/dataset/demo_create_sdf_of_airway.py | import torch
import numpy as np
import SimpleITK as sitk
import trimesh
'''
def calculate_sdf_from_mesh(surf_mesh, savepath):
points, sdf = sample_sdf_near_surface(surf_mesh, number_of_points=40000)
npz_sdf = np.concatenate((points, sdf[:, None]), axis=-1)
return npz_sdf
'''
import os
import pyvista as... | 15,378 | 36.97284 | 502 | py |
NAISR | NAISR-main/dataset/create_sdf_from_mesh.py | import argparse
from mesh_to_sdf import sample_sdf_near_surface
import trimesh
import pyrender
import numpy as np
import SimpleITK as sitk
import trimesh
import mesh_to_sdf
def calculate_sdf_from_mesh(surf_mesh):
# get centered mesh: mesh
mesh = surf_mesh
centroid = surf_mesh.bounding_box.centroid
ve... | 19,004 | 36.264706 | 235 | py |
NAISR | NAISR-main/examples/pediatric_airway/demo_atlas_dataset_generation.py | import os
import pyvista as pv
import numpy as np
import pandas as pd
import skimage.measure as measure
import pickle
import torch
def unitcross(a, b):
c = np.cross(a, b) / np.linalg.norm(np.cross(a, b))
return c
def rotation_of_a_plane(M, N):
costheta = np.matmul(M, N) / (np.linalg.norm(M) * np.linalg.... | 19,070 | 36.764356 | 208 | py |
Graph_Pooling_Networks | Graph_Pooling_Networks-main/layer.py | import tensorflow as tf
import numpy as np
from algorithm import maxPartitionPooling,\
sumPartitionPooling,\
averagePartitionPooling
class PartitionPooling(tf.keras.layers.Layer):
"""
Partition Pooling layer base class
This is the base class for partition pooli... | 5,770 | 34.84472 | 108 | py |
mmaction | mmaction-master/tools/train_localizer.py | from __future__ import division
import argparse
from mmcv import Config
from mmaction import __version__
from mmaction.datasets import get_trimmed_dataset
from mmaction.apis import (train_network, init_dist, get_root_logger,
set_random_seed)
from mmaction.models import build_localizer
impor... | 2,805 | 29.835165 | 77 | py |
mmaction | mmaction-master/tools/train_detector.py | from __future__ import division
import argparse
from mmcv import Config
from mmaction import __version__
from mmaction.datasets import get_trimmed_dataset
from mmaction.apis import (train_network, init_dist, get_root_logger,
set_random_seed)
from mmaction.models import build_detector
import... | 2,804 | 29.824176 | 78 | py |
mmaction | mmaction-master/tools/test_localizer.py | import argparse
from terminaltables import AsciiTable
import numpy as np
import pandas as pd
import torch
import mmcv
from mmcv.runner import load_checkpoint, parallel_test, obj_from_dict
from mmcv.parallel import scatter, collate, MMDataParallel
from mmaction import datasets
from mmaction.datasets import build_datal... | 6,472 | 35.162011 | 79 | py |
mmaction | mmaction-master/tools/test_recognizer_heavy.py | import argparse
import time
import torch
import torch.distributed as dist
import mmcv
import os
import os.path as osp
from mmcv.runner import load_checkpoint, obj_from_dict
from mmcv.runner import get_dist_info
from mmcv.parallel.distributed import MMDistributedDataParallel
import tempfile
from mmaction import datasets... | 7,406 | 32.977064 | 104 | py |
mmaction | mmaction-master/tools/test_recognizer.py | import argparse
import torch
import time
import torch.distributed as dist
import mmcv
import os.path as osp
import tempfile
from mmcv.runner import load_checkpoint, obj_from_dict
from mmcv.runner import get_dist_info
from mmcv.parallel.distributed import MMDistributedDataParallel
from mmaction import datasets
from mm... | 6,440 | 33.260638 | 111 | py |
mmaction | mmaction-master/tools/test_detector.py | import argparse
import time
import os.path as osp
import tempfile
import torch
import torch.distributed as dist
import mmcv
from mmcv.runner import load_checkpoint, obj_from_dict
from mmcv.runner import get_dist_info
from mmcv.parallel.distributed import MMDistributedDataParallel
from mmaction import datasets
from mm... | 6,517 | 31.753769 | 113 | py |
mmaction | mmaction-master/tools/train_recognizer.py | from __future__ import division
import argparse
from mmcv import Config
from mmaction import __version__
from mmaction.datasets import get_trimmed_dataset
from mmaction.apis import (train_network, init_dist, get_root_logger,
set_random_seed)
from mmaction.models import build_recognizer
impo... | 2,808 | 29.868132 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.