repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
gate-teamware | gate-teamware-master/backend/management/commands/build_api_docs.py | import json
from django.core.management.base import BaseCommand, CommandError
from django.template.loader import render_to_string
from backend.rpcserver import JSONRPCEndpoint
class Command(BaseCommand):
help = "Generate a JSON file listing API endpoints"
def add_arguments(self, parser):
parser.add_a... | 788 | 24.451613 | 70 | py |
gate-teamware | gate-teamware-master/backend/management/commands/load_test_fixture.py | from multiprocessing.connection import wait
import sys, os
from django.utils import timezone
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand, CommandError
from backend.models import AnnotatorProject, Project, Document, Annotation, DocumentType
from django.core.manage... | 10,652 | 39.048872 | 121 | py |
gate-teamware | gate-teamware-master/backend/tests/test_views.py | import math
import csv
import io
import json
from io import TextIOWrapper
from zipfile import ZipFile
from django.contrib.auth import get_user_model
from django.test import TestCase
from backend.models import Project, Document, Annotation, DocumentType
from backend.tests.test_rpc_server import TestEndpoint
from backen... | 8,609 | 49.946746 | 130 | py |
gate-teamware | gate-teamware-master/backend/tests/test_rpc_endpoints.py | from django.core import mail
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.hashers import check_password
from django.http import HttpRequest
from django.test import TestCase, Client
from django.utils import timezone
import json
from backend.models import Ann... | 74,587 | 41.116318 | 183 | py |
gate-teamware | gate-teamware-master/backend/tests/test_misc.py | from django.test import TestCase
from backend.utils.misc import get_value_from_key_path, insert_value_to_key_path
class InsertExtractValuesFromDictWithKeyPath(TestCase):
def test_get_value_with_key_path(self):
target_value = "Test value"
test_dict = {
"path1": {
"path... | 1,882 | 29.868852 | 114 | py |
gate-teamware | gate-teamware-master/backend/tests/test_models.py | import math
from datetime import timedelta
from django.db import models
from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import TestCase, Client
from django.utils import timezone
from backend.models import Project, Document, DocumentType, Annotation, AnnotatorProject
fro... | 55,876 | 44.688471 | 120 | py |
gate-teamware | gate-teamware-master/backend/tests/test_telemetry.py | from urllib.parse import urljoin
from django.test import TestCase
from django.conf import settings
import requests
import requests_mock
from backend.management.commands import load_test_fixture
from backend.utils.telemetry import TelemetrySender
from backend.models import Project
@requests_mock.Mocker()
class TestTe... | 3,260 | 30.057143 | 82 | py |
gate-teamware | gate-teamware-master/backend/tests/__init__.py | 0 | 0 | 0 | py | |
gate-teamware | gate-teamware-master/backend/tests/test_migrations.py | from django.utils import timezone
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
from django.test.testcases import TransactionTestCase
class MigrationTestCase(TransactionTestCase):
"""A Test case for testing migrations"""
# These must be defined by subclasses.
... | 4,928 | 37.507813 | 119 | py |
gate-teamware | gate-teamware-master/backend/tests/test_rpc_server.py | from django.db import transaction
from django.contrib.auth import get_user_model
from django.test import TestCase, Client
import json
from django.test.utils import TZ_SUPPORT
from django.contrib.auth.models import AnonymousUser
from django.test.client import RequestFactory
from backend.models import Annotation, Docume... | 11,628 | 37.003268 | 118 | py |
gate-teamware | gate-teamware-master/backend/utils/telemetry.py | import json
import logging
from threading import Thread
import requests
from urllib.parse import urljoin
from django.conf import settings
log = logging.getLogger(__name__)
class TelemetrySender:
def __init__(self, status: str, data: dict) -> None:
self.url = urljoin(settings.TELEMETRY_BASE_URL, settings.T... | 1,165 | 34.333333 | 113 | py |
gate-teamware | gate-teamware-master/backend/utils/misc.py | import string
import random
def get_value_from_key_path(obj_dict, key_path, delimiter="."):
"""
Gets value from a dictionary following a delimited key_path. Does not work for path with array elements.
:returns: None if path does not exist.
"""
if key_path is None:
return None
key_path_... | 2,038 | 29.893939 | 110 | py |
gate-teamware | gate-teamware-master/backend/utils/__init__.py | 0 | 0 | 0 | py | |
gate-teamware | gate-teamware-master/backend/utils/serialize.py | import logging
import json
from datetime import datetime
from django.db import models
from django.db.models import Model, ManyToOneRel, ManyToManyRel, ForeignKey
from django.utils import timezone
from backend.models import Project
log = logging.getLogger(__name__)
def dsl_val(attr_name, obj, data):
"""
Ins... | 6,068 | 35.125 | 155 | py |
gate-teamware | gate-teamware-master/teamware/wsgi.py | """
WSGI config for teamware project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETT... | 404 | 22.823529 | 79 | py |
gate-teamware | gate-teamware-master/teamware/__init__.py | 0 | 0 | 0 | py | |
gate-teamware | gate-teamware-master/teamware/urls.py | """teamware URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-base... | 1,121 | 39.071429 | 182 | py |
gate-teamware | gate-teamware-master/teamware/asgi.py | """
ASGI config for teamware project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETT... | 393 | 22.176471 | 78 | py |
gate-teamware | gate-teamware-master/teamware/settings/docker-test.py | """
Settings for Dockerised CI tests
"""
from .deployment import *
TELEMETRY_ON = False
FRONTEND_DEV_SERVER_USE = False
| 122 | 12.666667 | 32 | py |
gate-teamware | gate-teamware-master/teamware/settings/base.py | """
Django settings for teamware project.
The base.py file is loaded by default.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com... | 8,634 | 30.746324 | 148 | py |
gate-teamware | gate-teamware-master/teamware/settings/test.py | """
Settings for local backend testing
"""
from .base import *
| 64 | 9.833333 | 34 | py |
gate-teamware | gate-teamware-master/teamware/settings/docker-integration.py | """
Settings for integration testing
Uses a clean database every time
"""
from .deployment import *
DATABASES['default']['NAME'] = "teamware_integration_db"
# Turn off e-mail activation for testing
ACTIVATION_WITH_EMAIL = False
TELEMETRY_ON = False
FRONTEND_DEV_SERVER_USE = False
| 285 | 18.066667 | 56 | py |
gate-teamware | gate-teamware-master/teamware/settings/deployment.py | import logging
import sys
import os
from .base import *
# Enable csrf in production
MIDDLEWARE.append(
'django.middleware.csrf.CsrfViewMiddleware'
)
DEBUG = (os.environ.get('DJANGO_DEBUG', "false").lower() in ['true', 'yes', 'on', '1'])
if 'DJANGO_ALLOWED_HOSTS' in os.environ:
# This looks a bit horrible, but th... | 1,550 | 25.741379 | 117 | py |
gate-teamware | gate-teamware-master/teamware/settings/__init__.py | 0 | 0 | 0 | py | |
gate-teamware | gate-teamware-master/teamware/settings/integration.py | """
Settings for local integration testing
Uses a clean database every time
"""
from .base import *
DATABASES['default']['NAME'] = "teamware_integration_db"
# Turn off e-mail activation for testing
ACTIVATION_WITH_EMAIL = False
TELEMETRY_ON = False
| 253 | 17.142857 | 56 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/setup.py | import os
import os.path as osp
import shutil
import subprocess
import sys
import warnings
from setuptools import find_packages, setup
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
version_file = 'mmedit/version.py'
def get_git_hash():
def _min... | 8,503 | 34.286307 | 125 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.parallel import MMDataParallel
from mmcv.runner import get_dist_info, init_dist, load_checkpoint
from mmedit.apis import multi_gpu_test, set_random_seed, single_gpu_test
fro... | 5,285 | 32.66879 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/evaluate_comp1k.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import re
import mmcv
import numpy as np
from mmedit.core.evaluation import connectivity, gradient_error, mse, sad
from mmedit.utils import modify_args
def evaluate_one(args):
"""Function to evaluate one sample of data.
A... | 5,073 | 36.585185 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/get_flops.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
from mmcv import Config
from mmcv.cnn.utils import get_model_complexity_info
from mmedit.models import build_model
def parse_args():
parser = argparse.ArgumentParser(description='Train a editor')
parser.add_argument('config', help='train config... | 1,956 | 29.578125 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/onnx2tensorrt.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import warnings
from typing import Iterable, Optional
import cv2
import mmcv
import numpy as np
import onnxruntime as ort
import torch
from mmcv.ops import get_onnxruntime_op_path
from mmcv.tensorrt import (TRTWrapper, is_t... | 9,445 | 34.115242 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/publish_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import subprocess
import torch
from packaging import version
def parse_args():
parser = argparse.ArgumentParser(
description='Process a checkpoint to be published')
parser.add_argument('in_file', help='input checkpoint filename')
par... | 1,256 | 29.658537 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/pytorch2onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import warnings
import cv2
import mmcv
import numpy as np
import onnx
import onnxruntime as rt
import torch
from mmcv.onnx import register_extra_symbolics
from mmcv.runner import load_checkpoint
from mmedit.datasets.pipelines import Compose
from mmedit.m... | 7,975 | 35.420091 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/deploy_test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import warnings
from typing import Any
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.parallel import MMDataParallel
from torch import nn
from mmedit.apis import single_gpu_test
from mmedit.core.export import ONNXRuntimeEditing
fr... | 5,983 | 31.879121 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import os.path as osp
import time
import mmcv
import torch
import torch.distributed as dist
from mmcv import Config, DictAction
from mmcv.runner import init_dist
from mmedit import __version__
from mmedit.apis import init_random_see... | 5,738 | 32.758824 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/deployment/test_torchserver.py | # Copyright (c) OpenMMLab. All rights reserved.
from argparse import ArgumentParser
import cv2
import numpy as np
import requests
from PIL import Image
def parse_args():
parser = ArgumentParser()
parser.add_argument('model_name', help='The model name in the server')
parser.add_argument(
'--infere... | 1,364 | 30.022727 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/deployment/mmedit_handler.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import random
import string
from io import BytesIO
import PIL.Image as Image
import torch
from ts.torch_handler.base_handler import BaseHandler
from mmedit.apis import init_model, restoration_inference
from mmedit.core import tensor2img
class MMEditHandler(B... | 2,099 | 34 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tools/deployment/mmedit2torchserve.py | # Copyright (c) OpenMMLab. All rights reserved.
from argparse import ArgumentParser, Namespace
from pathlib import Path
from tempfile import TemporaryDirectory
import mmcv
try:
from model_archiver.model_packaging import package_model
from model_archiver.model_packaging_utils import ModelExportUtils
except Imp... | 3,725 | 32.567568 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/.dev_scripts/github/update_model_index.py | #!/usr/bin/env python
# Copyright (c) OpenMMLab. All rights reserved.
# This tool is used to update model-index.yml which is required by MIM, and
# will be automatically called as a pre-commit hook. The updating will be
# triggered if any change of model information (.md files in configs/) has been
# detected before a... | 11,096 | 33.039877 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_inference.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import shutil
import pytest
import torch
from mmedit.apis import (init_model, restoration_video_inference,
video_interpolation_inference)
def test_restoration_video_inference():
if torch.cuda.is_available():
# recurrent f... | 5,333 | 36.829787 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_optimizer.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmedit.core import build_optimizers
class ExampleModel(nn.Module):
def __init__(self):
super().__init__()
self.model1 = nn.Conv2d(3, 8, kernel_size=3)
self.model2 = nn.Conv2d(3, 4, kernel_size=3)
... | 4,279 | 40.960784 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_visual_hook.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
from unittest.mock import MagicMock
import mmcv
import numpy as np
import pytest
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, Dataset
from mmedit.core import VisualizationHook
from mmedit.utils import ... | 2,480 | 28.891566 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_dataset_builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
from torch.utils.data import ConcatDataset, RandomSampler, SequentialSampler
from mmedit.datasets import (DATASETS, RepeatDataset, build_dataloader,
build_dataset)
from mmedit.datasets.samplers import DistributedSampler
@DATASE... | 4,660 | 32.056738 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_eval_hook.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import tempfile
from unittest.mock import MagicMock
import mmcv.runner
import pytest
import torch
import torch.nn as nn
from mmcv.runner import obj_from_dict
from torch.utils.data import DataLoader, Dataset
from mmedit.core import EvalIterHook
class Exa... | 2,150 | 28.067568 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_apis.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.apis.train import init_random_seed, set_random_seed
def test_init_random_seed():
init_random_seed(0, device='cpu')
init_random_seed(device='cpu')
# test on gpu
if torch.cuda.is_available():
init_random_seed(0, device='cu... | 482 | 24.421053 | 63 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_runtime/test_ema_hook.py | # Copyright (c) OpenMMLab. All rights reserved.
from copy import deepcopy
import pytest
import torch
import torch.nn as nn
from packaging import version
from torch.nn.parallel import DataParallel
from mmedit.core.hooks import ExponentialMovingAverageHook
class SimpleModule(nn.Module):
def __init__(self):
... | 8,288 | 33.682008 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_base_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import unittest
from unittest.mock import patch
import pytest
import torch
from mmedit.models import BaseModel
class TestBaseModel(unittest.TestCase):
@patch.multiple(BaseModel, __abstractmethods__=set())
def test_parse_losses(self):
self.base_model =... | 1,059 | 29.285714 | 72 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_generation_backbones/test_generators.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import numpy as np
import pytest
import torch
from mmedit.models import build_backbone
from mmedit.models.common import (ResidualBlockWithDropout,
UnetSkipConnectionBlock)
def test_unet_skip_connection_block():
_cfg = ... | 10,368 | 27.17663 | 66 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_real_basicvsr_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.real_basicvsr_net import \
RealBasicVSRNet
def test_real_basicvsr_net():
"""Test RealBasicVSR."""
# cpu
# is_fix_cleaning = False
real_basicvsr = RealBasicVSRNet(is_fix_cleaning=F... | 2,058 | 34.5 | 70 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_sr_backbones.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmedit.models.backbones import EDSR, SRCNN, MSRResNet, RRDBNet
from mmedit.models.components import ModifiedVGG
def test_srresnet_backbone():
"""Test SRResNet backbone."""
# x2 model
MSRResNet(
in_... | 7,196 | 26.469466 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_duf.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.duf import DynamicUpsamplingFilter
def test_dynamic_upsampling_filter():
"""Test DynamicUpsamplingFilter."""
with pytest.raises(TypeError):
# The type of filter_size must be tuple
... | 1,223 | 33 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_liif_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models import build_backbone
def test_liif_edsr():
model_cfg = dict(
type='LIIFEDSR',
encoder=dict(
type='EDSR',
in_channels=3,
out_channels=3,
mid_channels=64,
nu... | 2,884 | 25.227273 | 49 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_iconvsr.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.iconvsr import IconVSR
def test_iconvsr():
"""Test IconVSR."""
# gpu (since IconVSR contains DCN, only GPU mode is available)
if torch.cuda.is_available():
iconvsr = IconVSR(
... | 1,695 | 30.407407 | 66 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_tdan_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.tdan_net import TDANNet
def test_tdan_net():
"""Test TDANNet."""
# gpu (DCN is available only on GPU)
if torch.cuda.is_available():
tdan = TDANNet().cuda()
input_tensor = ... | 772 | 29.92 | 69 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_basicvsr_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.basicvsr_net import BasicVSRNet
def test_basicvsr_net():
"""Test BasicVSR."""
# cpu
basicvsr = BasicVSRNet(
mid_channels=64, num_blocks=30, spynet_pretrained=None)
input_tenso... | 1,137 | 30.611111 | 74 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_dic_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmedit.models import build_backbone
from mmedit.models.backbones.sr_backbones.dic_net import (
FeedbackBlock, FeedbackBlockCustom, FeedbackBlockHeatmapAttention)
def test_feedback_block():
x1 = torch.rand(2,... | 2,496 | 24.222222 | 70 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_glean_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.glean_styleganv2 import \
GLEANStyleGANv2
class TestGLEANNet:
@classmethod
def setup_class(cls):
cls.default_cfg = dict(in_size=16, out_size=256, style_channels=512)
cls.s... | 1,834 | 32.981481 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_edvr_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.edvr_net import (EDVRNet,
PCDAlignment,
TSAFusion)
def test_pcd_alignment():
"... | 4,187 | 27.489796 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_tof.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones import TOFlow
def test_tof():
"""Test TOFlow."""
# cpu
tof = TOFlow(adapt_official_weights=True)
input_tensor = torch.rand(1, 7, 3, 32, 32)
tof.init_weights(pretrained=None)
output = tof(i... | 937 | 26.588235 | 57 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_rdn.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmedit.models import build_backbone
def test_rdn():
scale = 4
model_cfg = dict(
type='RDN',
in_channels=3,
out_channels=3,
mid_channels=64,
num_blocks=16,
upscale_factor=s... | 1,353 | 22.344828 | 56 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_sr_backbones/test_basicvsr_plusplus.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.backbones.sr_backbones.basicvsr_pp import BasicVSRPlusPlus
def test_basicvsr_plusplus():
"""Test BasicVSR++."""
# cpu
model = BasicVSRPlusPlus(
mid_channels=64,
num_blocks=7,
is_low_res_... | 2,987 | 30.452632 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_vfi_backbones/test_cain_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import build_backbone
def test_cain_net():
model_cfg = dict(type='CAINNet')
# build model
model = build_backbone(model_cfg)
# test attributes
assert model.__class__.__name__ == 'CAINNet'
# prepar... | 2,023 | 28.333333 | 56 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_vfi_backbones/test_tof_vfi_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import build_backbone
def test_tof_vfi_net():
model_cfg = dict(type='TOFlowVFINet')
# build model
model = build_backbone(model_cfg)
# test attributes
assert model.__class__.__name__ == 'TOFlowVFINet'
... | 1,371 | 25.901961 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_gl_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import build_backbone, build_component
from mmedit.models.backbones import GLDilationNeck
from mmedit.models.common import SimpleGatedConvModule
def test_gl_encdec():
input_x = torch.randn(1, 4, 256, 256)
template_c... | 2,945 | 30.010526 | 75 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_deepfill_encoder.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models.backbones import ContextualAttentionNeck, DeepFillEncoder
from mmedit.models.common import SimpleGatedConvModule
def test_deepfill_enc():
encoder = DeepFillEncoder()
x = torch.randn((2, 5, 256, 256))
outputs = encoder(x)
... | 3,966 | 34.738739 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_aot_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models import build_backbone
from mmedit.models.backbones.encoder_decoders.necks import AOTBlockNeck
def test_gl_encdec():
input_x = torch.randn(1, 4, 256, 256)
template_cfg = dict(type='AOTEncoderDecoder')
aot_encdec = build_backb... | 1,576 | 29.921569 | 71 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_deepfill_decoder.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models.backbones import DeepFillDecoder
def test_deepfill_dec():
decoder = DeepFillDecoder(128, out_act_cfg=None)
assert not decoder.with_out_activation
decoder = DeepFillDecoder(128)
x = torch.randn((2, 128, 64, 64))
inpu... | 1,533 | 34.674419 | 68 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_decoders.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmedit.models.backbones import (VGG16, FBADecoder, IndexedUpsample,
IndexNetDecoder, IndexNetEncoder,
PlainDecoder, ResGCADecoder,
... | 8,503 | 33.710204 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_encoder_decoder.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmedit.models.backbones import SimpleEncoderDecoder
def assert_dict_keys_equal(dictionary, target_keys):
"""Check if the keys of the dictionary is equal to the target key set."""
assert isinstance(dictionary, dict)
asser... | 3,362 | 35.956044 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_encoders.py | # Copyright (c) OpenMMLab. All rights reserved.
from collections.abc import Iterable
import numpy as np
import pytest
import torch
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmedit.models.backbones import (VGG16, DepthwiseIndexBlock,
FBAResnetDilated, HolisticIndexBloc... | 24,631 | 38.22293 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_pconv_encdec.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmedit.models.backbones import PConvEncoder, PConvEncoderDecoder
def test_pconv_encdec():
pconv_enc_cfg = dict(type='PConvEncoder')
pconv_dec_cfg = dict(type='PConvDecoder')
... | 1,280 | 31.025 | 72 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_backbones/test_encoder_decoders/test_deepfill_encdec.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models.backbones import DeepFillEncoderDecoder, GLEncoderDecoder
from mmedit.models.components import DeepFillRefiner
def test_deepfill_encdec():
encdec = DeepFillEncoderDecoder()
assert isinstance(encdec.stage1, GLEncoderDecoder)
a... | 961 | 37.48 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_extractors/test_feedback_hour_glass.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import build_component
from mmedit.models.extractors import Hourglass
from mmedit.models.extractors.feedback_hour_glass import (
ResBlock, reduce_to_five_heatmaps)
def test_res_block():
res_block = ResBlock(16, 32)... | 2,154 | 30.231884 | 68 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_extractors/test_lte.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import build_component
def test_lte():
model_cfg = dict(
type='LTE',
requires_grad=False,
pixel_range=1.,
pretrained=None,
load_pretrained_vgg=False)
lte = build_component(mo... | 863 | 24.411765 | 47 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_synthesizers/test_cyclegan.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
from unittest.mock import patch
import mmcv
import pytest
import torch
from mmcv.parallel import DataContainer as DC
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import ResnetGenerator
from mmedit.m... | 23,294 | 40.747312 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_basicvsr_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones.sr_backbones import BasicVSRNet
from mmedit.models.losses import MSELoss
def test_basicvsr_model():
mod... | 6,854 | 32.602941 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_real_basicvsr.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import RealBasicVSRNet
from mmedit.models.components import UNetDiscriminatorWithSpectralNorm
from mmedit.... | 8,475 | 39.361905 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_tdan.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import TDANNet
from mmedit.models.losses import MSELoss
def test_tdan_model():
model_cfg = dict(
... | 5,090 | 34.110345 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_real_esrgan.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import MSRResNet
from mmedit.models.components import ModifiedVGG
from mmedit.models.losses import GANLoss... | 10,264 | 38.480769 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_glean.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import pytest
import torch
from mmedit.models import build_model
def test_glean():
model_cfg = dict(
type='GLEAN',
generator=dict(
type='GLEANStyleGANv2',
in_size=16,
out_size=64,
style_ch... | 2,269 | 30.971831 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_liif.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
from mmcv.runner import obj_from_dict
from mmcv.utils.config import Config
from mmedit.models import build_model
from mmedit.models.registry import COMPONENTS
@COMPONENTS.register_module()
class BP(nn.Module):
"... | 4,114 | 33.579832 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_dic_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmcv.utils.config import Config
from mmedit.models.builder import build_model
def test_dic_model():
pretrained = 'https://download.openmmlab.com/mmediting/' + \
'restor... | 4,844 | 39.375 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_ttsr.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmcv.runner import obj_from_dict
from mmcv.utils.config import Config
from mmedit.models import build_backbone, build_model
from mmedit.models.backbones.sr_backbones.ttsr_net import (CSFI2, CSFI3, SFE,
... | 7,308 | 33.63981 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_esrgan.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import MSRResNet
from mmedit.models.components import ModifiedVGG
from mmedit.models.losses import GANLoss, L1Loss
def... | 7,807 | 39.666667 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_edvr_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import EDVRNet
from mmedit.models.losses import L1Loss
def test_edvr_model():
model_cfg = dict(
... | 6,625 | 35.406593 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_srgan.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import MSRResNet
from mmedit.models.components import ModifiedVGG
from mmedit.models.losses import GANLoss... | 9,665 | 39.107884 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_restorers/test_basic_restorer.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import MSRResNet
from mmedit.models.losses import L1Loss
def test_basic_restorer():
model_cfg = dict(
... | 6,226 | 35.415205 | 77 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_video_interpolator/test_basic_interpolator.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
import torch.nn as nn
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.losses import L1Loss
from mmedit.models.registry import COMPONENTS
@COMPONENTS.register_module()... | 10,311 | 34.07483 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_video_interpolator/test_cain.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import pytest
import torch
from mmcv.runner import obj_from_dict
from mmedit.models import build_model
from mmedit.models.backbones import CAINNet
from mmedit.models.losses import L1Loss
def test_cain():
model_cfg = dict(
type='... | 4,692 | 33.762963 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_mattors/test_mattors.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from unittest.mock import patch
import mmcv
import numpy as np
import pytest
import torch
from mmedit.models import BaseMattor, build_model
def _get_model_cfg(fname):
"""
Grab configs necessary to create a model. These are deep copied to ... | 14,057 | 37.620879 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_losses/test_losses.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
from unittest.mock import patch
import numpy
import numpy.testing as npt
import pytest
import torch
from mmedit.models import (CharbonnierCompLoss, CharbonnierLoss, DiscShiftLoss,
GANLoss, GaussianBlur, GradientLoss,
... | 18,730 | 34.542694 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_losses/test_feature_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.losses import LightCNNFeatureLoss
def test_light_cnn_feature_loss():
pretrained = 'https://download.openmmlab.com/mmediting/' + \
'restorers/dic/light_cnn_feature.pth'
pred = torch.rand((3, 3, 128, 128))
... | 1,600 | 28.648148 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_common_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmedit.models.common import (ASPP, DepthwiseSeparableConvModule,
GCAModule, LinearModule, MaskConvModule,
PartialConv2d, SimpleGatedConvModule)
def... | 10,851 | 31.984802 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_img_normalize.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models.common import ImgNormalize
def test_normalize_layer():
rgb_mean = (1, 2, 3)
rgb_std = (1, 0.5, 0.25)
layer = ImgNormalize(1, rgb_mean, rgb_std)
x = torch.randn((2, 3, 64, 64))
y = layer(x)
x = x.permute((1, 0, 2, ... | 695 | 29.26087 | 69 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_sampling.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models.common import PixelShufflePack, pixel_unshuffle
def test_pixel_shuffle():
# test on cpu
model = PixelShufflePack(3, 3, 2, 3)
model.init_weights()
x = torch.rand(1, 3, 16, 16)
y = model(x)
assert y.s... | 988 | 23.121951 | 66 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_flow_warp.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmedit.models import flow_warp
def tensor_shift(x, shift=(1, 1), fill_val=0):
"""Shift tensor for testing flow_warp.
Args:
x (Tensor): the input tensor. The shape is (b, c, h, w].
shift (tuple): shift pixel.
... | 1,471 | 26.773585 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_model_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmedit.models.common import (GANImageBuffer, extract_around_bbox,
extract_bbox_patch, generation_init_weights,
set_re... | 5,756 | 38.979167 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_common/test_ensemble.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmedit.models.common import SpatialTemporalEnsemble
def test_ensemble_cpu():
model = nn.Identity()
# spatial ensemble of an image
ensemble = SpatialTemporalEnsemble(is_temporal_ensemb... | 2,575 | 36.882353 | 73 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_transformer/test_search_transformer.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmedit.models.builder import build_component
def test_search_transformer():
model_cfg = dict(type='SearchTransformer')
model = build_component(model_cfg)
lr_pad_level3 = torch.randn((2, 32, 32, 32))
ref_pad_level3 = torch.randn((2, 32... | 806 | 31.28 | 61 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_components/test_stylegan2.py | # Copyright (c) OpenMMLab. All rights reserved.
from copy import deepcopy
import pytest
import torch
import torch.nn as nn
from mmedit.models.components.stylegan2.common import get_module_device
from mmedit.models.components.stylegan2.generator_discriminator import (
StyleGAN2Discriminator, StyleGANv2Generator)
f... | 8,432 | 30.466418 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/tests/test_models/test_components/test_refiners/test_mlp_refiner.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmedit.models.builder import build_component
def test_mlp_refiner():
model_cfg = dict(
type='MLPRefiner', in_dim=8, out_dim=3, hidden_list=[8, 8, 8, 8])
mlp = build_component(model_cfg)
# test attributes
... | 971 | 26.771429 | 73 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.