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 |
|---|---|---|---|---|---|---|
archive-query-log | archive-query-log-main/archive_query_log/results/test/test_utils.py | from pathlib import Path
from webbrowser import open_new_tab
from approvaltests import verify_as_json, ApprovalException
from approvaltests.core.options import Options
from approvaltests.namer.cli_namer import CliNamer
from slugify import slugify
from tqdm.auto import tqdm
from archive_query_log import PROJECT_DIRECT... | 3,114 | 29.539216 | 75 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/test_services.py | from archive_query_log.config import SERVICES_PATH
from archive_query_log.services import read_services
def test_services_can_be_parsed():
assert read_services(
SERVICES_PATH,
ignore_parsing_errors=False
) is not None
| 244 | 23.5 | 52 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/search_forms.py | import re
import pandas as pd
from tqdm import tqdm
from requests_html import HTMLSession
from bs4 import BeautifulSoup
import argparse
pattern = re.compile(r'(?i).*search.*')
# noinspection PyUnresolvedReferences,PyBroadException
class SearchFormIdentifier:
"""
Class that takes in a CSV-file containing serv... | 7,993 | 38.97 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/alexa.py | from asyncio import run
from csv import reader
from dataclasses import dataclass
from datetime import datetime
from functools import cached_property
from io import TextIOWrapper
from itertools import islice
from math import floor, log10
from pathlib import Path
from tempfile import gettempdir
from typing import Sized, ... | 10,694 | 34.413907 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/__init__.py | from pathlib import Path
from typing import Mapping
from yaml import safe_load
from archive_query_log.model import Service
def read_services(
path: Path, ignore_parsing_errors=True
) -> Mapping[str, Service]:
with path.open("r") as file:
services_dict = safe_load(file)
services = []
... | 1,114 | 29.972222 | 74 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/update_yaml.py | from typing import Sequence
import pandas as pd
import yaml
from pandas import concat, DataFrame
from archive_query_log import DATA_DIRECTORY_PATH
from archive_query_log.cli.external import load_services, load_domains, \
service_domains, load_url_prefixes, \
load_query_parsers, query_parser, load_page_offset_... | 5,168 | 33.925676 | 78 | py |
archive-query-log | archive-query-log-main/archive_query_log/services/aggregate_services.py | import pandas as pd
def combine_alexa_manual(manual_csv: str, alexa_csv: str):
"""
Function to combine the CSV created by search_forms.py
with a manual collection of search engines
:param manual_csv: Path to the CSV containing a manual collection
of search engines
:param alexa_csv: Path... | 2,010 | 42.717391 | 75 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/http_session.py | from requests import Session
from requests.adapters import HTTPAdapter
from urllib3 import Retry
def backoff_session() -> Session:
session = Session()
retries = Retry(
total=10,
backoff_factor=1,
status_forcelist=[502, 503, 504],
)
session.mount("https://", HTTPAdapter(max_retr... | 353 | 22.6 | 63 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/html.py | from bleach import clean
from bs4 import Tag
_HIGHLIGHT_TAGS = ["em", "strong", "mark", "b", "i", "u"]
def clean_html(html: str | Tag) -> str:
if isinstance(html, Tag):
html = html.decode_contents()
html = clean(
html,
tags=_HIGHLIGHT_TAGS,
attributes=[],
protocols=[],... | 546 | 22.782609 | 57 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/archive_http.py | from contextlib import asynccontextmanager
from aiohttp import ClientSession, TCPConnector, ClientTimeout, \
ClientConnectorError, ServerTimeoutError, ClientPayloadError
from aiohttp_retry import RetryClient, JitterRetry
@asynccontextmanager
async def archive_http_session(limit: int = 10) -> ClientSession:
#... | 1,466 | 30.212766 | 70 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/iterable.py | from typing import runtime_checkable, TypeVar, Protocol, Sized, Iterable
T = TypeVar("T", covariant=True)
@runtime_checkable
class SizedIterable(Sized, Iterable[T], Protocol):
pass
| 188 | 20 | 72 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/text.py | from typing import IO, Iterator
_LINE_COUNT_BUFFER_SIZE = 1024 * 1024
def _chunks(reader: IO[bytes]) -> Iterator[bytes]:
buffer = reader.read(_LINE_COUNT_BUFFER_SIZE)
while buffer:
yield buffer
buffer = reader.read(_LINE_COUNT_BUFFER_SIZE)
def count_lines(file: IO[bytes]) -> int:
return... | 374 | 24 | 63 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/__init__.py | 0 | 0 | 0 | py | |
archive-query-log | archive-query-log-main/archive_query_log/util/urls.py | from urllib.parse import quote
def safe_quote_url(url: str) -> str:
return quote(url, safe="")
| 101 | 16 | 36 | py |
archive-query-log | archive-query-log-main/archive_query_log/util/serialization.py | from marshmallow.fields import Field
from archive_query_log.model import HighlightedText
class HighlightedTextField(Field):
"""
Field that serializes to an HTML string and deserializes
to a highlighted text.
"""
def _serialize(self, value: HighlightedText, attr, obj, **kwargs):
if value ... | 530 | 24.285714 | 70 | py |
archive-query-log | archive-query-log-main/archive_query_log/queries/iterable.py | from dataclasses import dataclass
from gzip import GzipFile
from io import TextIOWrapper
from pathlib import Path
from typing import Sized, Iterable, Iterator, IO
from archive_query_log.model import ArchivedQueryUrl
from archive_query_log.util.text import count_lines
@dataclass(frozen=True)
class ArchivedQueryUrls(S... | 1,384 | 29.777778 | 64 | py |
archive-query-log | archive-query-log-main/archive_query_log/queries/__init__.py | 0 | 0 | 0 | py | |
archive-query-log | archive-query-log-main/archive_query_log/queries/parse.py | from dataclasses import dataclass
from gzip import GzipFile
from io import TextIOWrapper
from pathlib import Path
from typing import Sequence, NamedTuple, Pattern
from urllib.parse import parse_qsl, unquote, quote
from tqdm.auto import tqdm
from archive_query_log.model import ArchivedQueryUrl, \
ArchivedUrl, Page... | 10,716 | 30.895833 | 75 | py |
archive-query-log | archive-query-log-main/archive_query_log/serps/iterable.py | from dataclasses import dataclass
from gzip import GzipFile
from io import TextIOWrapper
from pathlib import Path
from typing import Sized, Iterable, Iterator, IO
from archive_query_log.model import ArchivedParsedSerp
from archive_query_log.util.text import count_lines
@dataclass(frozen=True)
class ArchivedParsedSer... | 1,398 | 30.088889 | 64 | py |
archive-query-log | archive-query-log-main/archive_query_log/serps/__init__.py | 0 | 0 | 0 | py | |
archive-query-log | archive-query-log-main/archive_query_log/urls/fetch.py | from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from functools import cached_property
from gzip import GzipFile
from io import TextIOWrapper
from itertools import chain
from pathlib import Path
from typing import AbstractSet, Sequence, Any, Iterable, Iterator, NamedTuple
from urlli... | 10,716 | 31.874233 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/urls/iterable.py | from dataclasses import dataclass
from gzip import GzipFile
from io import TextIOWrapper
from pathlib import Path
from typing import Sized, Iterable, Iterator, IO
from archive_query_log.model import ArchivedUrl
from archive_query_log.util.text import count_lines
@dataclass(frozen=True)
class ArchivedUrls(Sized, Iter... | 1,347 | 28.955556 | 64 | py |
archive-query-log | archive-query-log-main/archive_query_log/urls/__init__.py | 0 | 0 | 0 | py | |
archive-query-log | archive-query-log-main/archive_query_log/model/highlight.py | from dataclasses import dataclass
from functools import cached_property
from html.parser import HTMLParser
from typing import List, Union, Optional
class Highlight(str):
depth: int
def __new__(cls, value: str, depth: int):
result = super().__new__(cls, value)
result.depth = depth
retu... | 2,943 | 26.259259 | 71 | py |
archive-query-log | archive-query-log-main/archive_query_log/model/__init__.py | from dataclasses import dataclass, field
from datetime import datetime, timezone
from functools import cached_property
from hashlib import md5
from pathlib import Path
from typing import Sequence, Any
from urllib.parse import SplitResult, urlsplit
from uuid import UUID, uuid5, NAMESPACE_URL
from dataclasses_json impor... | 16,441 | 26.221854 | 88 | py |
archive-query-log | archive-query-log-main/archive_query_log/model/parse.py | from re import compile, IGNORECASE
from typing import Sequence, Protocol, runtime_checkable, Any, Mapping, Union
from marshmallow.fields import Field
from archive_query_log.model import ArchivedUrl, ArchivedSearchResultSnippet, \
ArchivedRawSerp
@runtime_checkable
class QueryParser(Protocol):
def parse(self... | 8,728 | 34.628571 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/download/warc.py | from dataclasses import dataclass
from io import BytesIO
from itertools import count, groupby, chain
from pathlib import Path
from random import Random
from tempfile import TemporaryFile
from typing import Sequence, NamedTuple, Iterable
from urllib.parse import quote, parse_qsl
from aiohttp import ClientResponseError
... | 12,668 | 31.992188 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/download/iterable.py | from dataclasses import dataclass
from functools import cached_property
from json import JSONDecodeError
from pathlib import Path
from typing import Sized, Iterable, Iterator
from fastwarc import GZipStream, FileStream, ArchiveIterator, WarcRecordType, \
WarcRecord
from marshmallow import Schema
from archive_quer... | 3,088 | 31.861702 | 79 | py |
archive-query-log | archive-query-log-main/archive_query_log/download/raw.py | from asyncio import sleep
from pathlib import Path
from random import random
from typing import Iterable, Callable, Mapping
from aiohttp import ClientResponseError
from aiohttp_retry import RetryClient
from asyncio_pool import AioPool
from tqdm.auto import tqdm
from archive_query_log.model import ArchivedUrl
from arc... | 4,981 | 35.632353 | 77 | py |
archive-query-log | archive-query-log-main/archive_query_log/download/__init__.py | 0 | 0 | 0 | py | |
archive-query-log | archive-query-log-main/scripts/create_corpus.py | from argparse import ArgumentParser
from datetime import datetime
from gzip import GzipFile
from json import loads, JSONDecodeError, dumps
from pathlib import Path
from random import shuffle
from typing import Optional, Iterator, Literal
from urllib.parse import urlparse
from uuid import uuid5, NAMESPACE_URL
from fast... | 13,418 | 37.560345 | 131 | py |
archive-query-log | archive-query-log-main/scripts/create_url_list.py | from datetime import datetime
from gzip import GzipFile
from json import loads, JSONDecodeError, dumps
from pathlib import Path
from random import shuffle
from typing import Optional, Iterator
from urllib.parse import urlparse
from uuid import uuid5, NAMESPACE_URL
from fastwarc import FileStream, ArchiveIterator, Warc... | 5,481 | 33.049689 | 98 | py |
archive-query-log | archive-query-log-main/integrations/tira/aql-experiment-baseline.py | #!/usr/bin/env python3
from argparse import ArgumentParser
from json import dump
from pathlib import Path
from pandas import concat, read_json
def parse_args():
parser = ArgumentParser(description="Archive Query Log Demo")
parser.add_argument(
'--input',
type=Path,
help="The directo... | 1,000 | 24.025 | 71 | py |
archive-query-log | archive-query-log-main/integrations/ir_datasets/archive_query_log_ir_datasets_integration.py | """
This script registers the Archive Query Log dataset in ir_datasets.
See: https://github.com/allenai/ir_datasets/
Note: This script is intended to be executed with the Docker image provided.
"""
from pathlib import Path
from typing import NamedTuple, List, Mapping, Optional, Iterator
from ir_datasets import regist... | 6,855 | 29.471111 | 77 | py |
anticipatr | anticipatr-main/src/main.py | import os
import argparse
import random
import numpy as np
import time
from pathlib import Path
import json
import datetime
import pickle
import torch
from torch.utils.data import DataLoader
import datasets
import utils.misc as utils
from datasets import build_dataset
from models import build_model
from engine import t... | 10,477 | 46.627273 | 208 | py |
anticipatr | anticipatr-main/src/engine.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
import os,sys
import copy
import numpy as np
import math
from typing import Iterable
import time
import utils.misc as utils
import datasets
from metrics.longfuture_metrics import AnticipationEvaluator
def train_one_epoch(epo... | 4,794 | 37.36 | 141 | py |
anticipatr | anticipatr-main/src/snippet_models/model.py | import torch
import torch.nn.functional as F
from torch import nn
from .transformer import build_transformer
from .joiner import build_joiner
import numpy as np
from utils.misc import accuracy, get_world_size, get_rank,is_dist_avail_and_initialized
class MLP(nn.Module):
""" Very simple multi-layer perceptron (al... | 6,287 | 35.77193 | 156 | py |
anticipatr | anticipatr-main/src/snippet_models/position_encoding.py | """
Various positional encodings for the transformer.
"""
import math
import torch
from torch import nn
class PositionEmbeddingSineIndex(nn.Module):
"""
Sinusoidal positional encodings based on sequence timestamps
"""
def __init__(self, num_pos_feats, temperature=10000, normalize=True, scale=... | 1,693 | 33.571429 | 97 | py |
anticipatr | anticipatr-main/src/snippet_models/transformer.py | """
Transformer class.
Copy-paste from torch.nn.Transformer with modifications:
* positional encodings are passed in MHattention
* extra LN at the end of encoder is removed
* decoder returns a stack of activations from all decoding layers
"""
import copy
from typing import Optional, List
import torch
impo... | 12,622 | 39.458333 | 139 | py |
anticipatr | anticipatr-main/src/snippet_models/joiner.py | """
Joiner modules.
"""
from collections import OrderedDict
import torch
import torch.nn.functional as F
import torchvision
from torch import nn
from torchvision.models._utils import IntermediateLayerGetter
from typing import Dict, List
from .position_encoding import build_position_encoding
class Joiner(nn.Sequentia... | 959 | 29.967742 | 118 | py |
anticipatr | anticipatr-main/src/snippet_models/__init__.py | from .model import build
def build_snippet_model(args):
return build(args)
| 83 | 9.5 | 30 | py |
anticipatr | anticipatr-main/src/models/matcher.py | import torch
from scipy.optimize import linear_sum_assignment
from torch import nn
import numpy as np
import utils.segment_utils as segment_utils
class GreedyMatcher(nn.Module):
"""This class computes an assignment between the targets and the predictions of the network
For efficiency reasons, the targets don'... | 3,980 | 46.392857 | 152 | py |
anticipatr | anticipatr-main/src/models/antr.py | import torch
import torch.nn.functional as F
from torch import nn
from .transformer import build_transformer
from .joiner import build_joiner
from .matcher import build_matcher
import snippet_models
import numpy as np
from utils.misc import accuracy, get_world_size, get_rank,is_dist_avail_and_initialized
from utils im... | 15,660 | 46.457576 | 163 | py |
anticipatr | anticipatr-main/src/models/position_encoding.py | """
Various positional encodings for the transformer.
"""
import math
import torch
from torch import nn
class PositionEmbeddingSineIndex(nn.Module):
def __init__(self, num_pos_feats, temperature=10000, normalize=True, scale=None):
super().__init__()
self.num_pos_feats = num_pos_feats
sel... | 1,604 | 33.891304 | 97 | py |
anticipatr | anticipatr-main/src/models/transformer.py | """
Transformer class.
Code inspired by torch.nn.Transformer with modifications:
* positional encodings are passed in MHattention
* decoder handles multiple encoders
* decoder returns a stack of activations from all decoding layers
"""
import copy
from typing import Optional, List
import os, sys
import tor... | 14,850 | 43.199405 | 180 | py |
anticipatr | anticipatr-main/src/models/joiner.py | """
Joiner modules.
"""
from collections import OrderedDict
import torch
import torch.nn.functional as F
import torchvision
from torch import nn
from torchvision.models._utils import IntermediateLayerGetter
from typing import Dict, List
from .position_encoding import build_position_encoding
class Joiner(nn.Sequentia... | 873 | 28.133333 | 118 | py |
anticipatr | anticipatr-main/src/models/__init__.py | from .antr import build
def build_model(args):
return build(args)
| 72 | 11.166667 | 23 | py |
anticipatr | anticipatr-main/src/metrics/__init__.py | 0 | 0 | 0 | py | |
anticipatr | anticipatr-main/src/metrics/longfuture_metrics.py | """
Evaluator class for action anticipation benchmarks
"""
import math
import numpy as np
import torch
import warnings
from collections import OrderedDict
warnings.filterwarnings("ignore", category=UserWarning)
import sklearn.metrics as skmetrics
class AnticipationEvaluator(object):
def __init__(self,dataset)... | 4,064 | 40.907216 | 151 | py |
anticipatr | anticipatr-main/src/datasets/bf.py | """
Constructs a dataloader for breakfast dataset for the task of long term action anticipation.
"""
import numpy as np
import lmdb
from tqdm import tqdm
from torch.utils.data import Dataset
import pandas as pd
from .baseds_longfuture import SequenceDatasetLongFuture
def build_bf_anticipation(args,mode,override_mo... | 1,600 | 33.804348 | 126 | py |
anticipatr | anticipatr-main/src/datasets/ek.py | """
Constructs a dataloader for Epic-Kitchens-55 for the task of long term action anticipation.
"""
import numpy as np
import lmdb
from tqdm import tqdm
from torch.utils.data import Dataset
import pandas as pd
from .baseds_longfuture import SequenceDatasetLongFuture
#verbs, nouns,action: 125,3522,3806
#train_many_sh... | 1,834 | 38.042553 | 153 | py |
anticipatr | anticipatr-main/src/datasets/ds_utils.py | import numpy as np
import os,sys
def getVideoId(dataset,vidname):
if dataset == 'ek':
return getVideoId_ek(vidname)
elif dataset == 'bf':
return getVideoId_bf(vidname)
def getVideoName(dataset,vidid):
if dataset == 'ek':
return getVideoName_ek(vidid)
elif dataset == 'bf':
... | 2,211 | 28.891892 | 146 | py |
anticipatr | anticipatr-main/src/datasets/__init__.py | import torch.utils.data
import torchvision
def build_dataset(args, mode):
if args.dataset == 'ek':
from datasets.ek import build_ek_anticipation
return build_ek_anticipation(args=args, mode=mode)
elif args.dataset == 'bf':
from datasets.bf import build_bf_anticipation
return bu... | 363 | 27 | 58 | py |
anticipatr | anticipatr-main/src/datasets/baseds_longfuture.py | import bisect
import copy
import os
import os.path as osp
import random
from functools import partial
import itertools
import numpy as np
import pickle as pkl
import collections
from collections import Sequence
import tqdm
import torch
from torch.utils.data import Dataset
from torchvision import transforms
from PIL i... | 16,321 | 42.641711 | 280 | py |
anticipatr | anticipatr-main/src/utils/misc.py | """
Misc functions, including distributed helpers.
Mostly copy-paste from torchvision references and
https://github.com/facebookresearch/detr
"""
import os
import subprocess
import time
from collections import defaultdict, deque
import datetime
import pickle
from typing import Optional, List
import torch
import torch... | 13,447 | 30.716981 | 137 | py |
anticipatr | anticipatr-main/src/utils/__init__.py | 0 | 0 | 0 | py | |
anticipatr | anticipatr-main/src/utils/segment_utils.py | import torch
import numpy as np
def segment_iou(target_segment,candidate_segments):
tt1 = torch.max(target_segment[0], candidate_segments[:, 0])
tt2 = torch.min(target_segment[1], candidate_segments[:, 1])
# Intersection including Non-negative overlap score.
segments_intersection = (tt2 - tt1).clamp(mi... | 1,137 | 33.484848 | 139 | py |
anticipatr | anticipatr-main/pretraining/main_pretraining.py | import os
import argparse
import random
import numpy as np
import time
from pathlib import Path
import json
import datetime
import pickle
import torch
from torch.utils.data import DataLoader
import utils.misc as utils
from tasks import build_task
from engine_pretraining import train_one_epoch, evaluate
parser = argpa... | 9,503 | 45.817734 | 208 | py |
anticipatr | anticipatr-main/pretraining/engine_pretraining.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
import os,sys
import copy
import numpy as np
import math
from typing import Iterable
import time
import utils.misc as utils
import datasets
from metrics.longfuture_metrics import AnticipationEvaluator
def train_one_epoch(epoch... | 5,666 | 39.769784 | 208 | py |
anticipatr | anticipatr-main/pretraining/models/model.py | import torch
import torch.nn.functional as F
from torch import nn
from .transformer import build_transformer
from .joiner import build_joiner
import numpy as np
class MLP(nn.Module):
""" Very simple multi-layer perceptron (also called FFN)"""
def __init__(self, input_dim, hidden_dim, output_dim, num_layers):... | 6,367 | 38.308642 | 136 | py |
anticipatr | anticipatr-main/pretraining/models/position_encoding.py | """
Various positional encodings for the transformer.
"""
import math
import torch
from torch import nn
class PositionEmbeddingSineIndex(nn.Module):
"""
Sinusoidal positional encodings based on sequence timestamps
"""
def __init__(self, num_pos_feats, temperature=10000, normalize=True, scale=... | 1,693 | 33.571429 | 97 | py |
anticipatr | anticipatr-main/pretraining/models/transformer.py | """
Transformer class.
Copy-paste from torch.nn.Transformer with modifications:
* positional encodings are passed in MHattention
* extra LN at the end of encoder is removed
* decoder returns a stack of activations from all decoding layers
"""
import copy
from typing import Optional, List
import torch
impo... | 12,622 | 39.458333 | 139 | py |
anticipatr | anticipatr-main/pretraining/models/joiner.py | """
Joiner modules.
"""
from collections import OrderedDict
import torch
import torch.nn.functional as F
import torchvision
from torch import nn
from torchvision.models._utils import IntermediateLayerGetter
from typing import Dict, List
from .position_encoding import build_position_encoding
class Joiner(nn.Sequentia... | 959 | 29.967742 | 118 | py |
anticipatr | anticipatr-main/pretraining/models/__init__.py | from .model import build
def build_model(args):
return build(args)
| 75 | 8.5 | 24 | py |
anticipatr | anticipatr-main/pretraining/metrics/__init__.py | 0 | 0 | 0 | py | |
anticipatr | anticipatr-main/pretraining/metrics/longfuture_metrics.py | import math
import numpy as np
import torch
import warnings
from collections import OrderedDict
warnings.filterwarnings("ignore", category=UserWarning)
import sklearn.metrics as skmetrics
class AnticipationEvaluator(object):
""" The pretraining task is multilabel classification problem."""
def __init__(self):... | 1,809 | 31.909091 | 151 | py |
anticipatr | anticipatr-main/pretraining/datasets/bf.py | """
Builds a dataloader class for snippet-level anticipation task
"""
import numpy as np
import lmdb
from tqdm import tqdm
from torch.utils.data import Dataset
import pandas as pd
from .baseds_snippetprediction import SequenceDatasetLongFuture
def build_bf_pretraining(args,mode,override_modality=None):
path... | 1,770 | 36.680851 | 130 | py |
anticipatr | anticipatr-main/pretraining/datasets/ek.py | import numpy as np
import lmdb
from tqdm import tqdm
from torch.utils.data import Dataset
import pandas as pd
from .baseds_snippetprediction import SequenceDatasetLongFuture
def build_ek_pretraining(args,mode,override_modality=None):
path_to_features = "{}/{}/{}/features/".format(args.root, args.dataset, args... | 1,866 | 41.431818 | 157 | py |
anticipatr | anticipatr-main/pretraining/datasets/baseds_snippetprediction.py | """
Implementation of dataloader for snippet anticipation.
Code inspired by: https://github.com/facebookresearch/ego-topo
"""
import bisect
import copy
import os
import os.path as osp
import random
from functools import partial
import itertools
import numpy as np
import pickle as pkl
import collections
from colle... | 12,985 | 38.956923 | 246 | py |
anticipatr | anticipatr-main/pretraining/datasets/ds_utils.py | import numpy as np
import os,sys
def getVideoId(dataset,vidname):
if dataset == 'ek':
return getVideoId_ek(vidname)
elif dataset == 'bf':
return getVideoId_bf(vidname)
def getVideoName(dataset,vidid):
if dataset == 'ek':
return getVideoName_ek(vidid)
elif dataset == 'bf':
... | 2,225 | 28.289474 | 146 | py |
anticipatr | anticipatr-main/pretraining/datasets/__init__.py | import torch.utils.data
import torchvision
def build_dataset(args):
if args.dataset == 'ek':
from datasets.ek import build_ek_pretraining
dataset_train = build_ek_pretraining(args,mode='train')
dataset_val = build_ek_pretraining(args,mode='val')
return dataset_train, dataset_val
... | 568 | 34.5625 | 63 | py |
anticipatr | anticipatr-main/pretraining/utils/misc.py | """
Misc functions, including distributed helpers.
Mostly copy-paste from torchvision references and
https://github.com/facebookresearch/detr
"""
import os
import subprocess
import time
from collections import defaultdict, deque
import datetime
import pickle
from typing import Optional, List
import torch
import torch... | 13,549 | 30.807512 | 138 | py |
anticipatr | anticipatr-main/pretraining/utils/__init__.py | 0 | 0 | 0 | py | |
anticipatr | anticipatr-main/pretraining/tasks/__init__.py | import torch
from datasets import build_dataset
from models import build_model
def build_task(args):
dataset_train,dataset_test = build_dataset(args)
model, criterion = build_model(args)
return dataset_train, dataset_test, model, criterion
| 257 | 18.846154 | 56 | py |
benchmarks | benchmarks-master/tools/run_distributed_benchmarks.py | # Copyright 2017 The TensorFlow 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 by applica... | 8,449 | 33.917355 | 80 | py |
benchmarks | benchmarks-master/tools/kubectl_util_test.py | # Copyright 2017 The TensorFlow 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 by applica... | 2,633 | 35.082192 | 80 | py |
benchmarks | benchmarks-master/tools/k8s_tensorflow_lib.py | # Copyright 2017 The TensorFlow 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 by applica... | 10,159 | 29.881459 | 80 | py |
benchmarks | benchmarks-master/tools/k8s_tensorflow_test.py | # Copyright 2017 The TensorFlow 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 by applica... | 4,331 | 31.328358 | 80 | py |
benchmarks | benchmarks-master/tools/kubectl_util.py | # Copyright 2017 The TensorFlow 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 by applica... | 6,712 | 33.076142 | 80 | py |
benchmarks | benchmarks-master/tools/run_all_CNN_benchmarks.py | # Copyright 2017 Ioannis Athanasiadis(supernlogn). 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 ... | 1,482 | 24.135593 | 80 | py |
benchmarks | benchmarks-master/dashboard_app/main.py | # Copyright 2017 The TensorFlow 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 by applica... | 5,504 | 32.981481 | 80 | py |
benchmarks | benchmarks-master/dashboard_app/main_test.py | # Copyright 2017 The TensorFlow 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 by applica... | 2,934 | 33.940476 | 92 | py |
benchmarks | benchmarks-master/my_tests/reportLmdbError.py | from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import division
import numpy as np
import tensorflow as tf
from tensorflow.python.framework import dtypes
from six.moves import xrange # pylint: disable=redefined-builtin
import lmdb
import PIL.Image
from StringIO import St... | 1,388 | 27.9375 | 65 | py |
benchmarks | benchmarks-master/my_tests/LmdbInputImagePreprocessor.py | # Copyright 2017 Ioannis Athanasiadis(supernlogn). 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 ... | 5,750 | 29.754011 | 101 | py |
benchmarks | benchmarks-master/scripts/util/convert_csv_to_json.py | # Copyright 2017 The TensorFlow 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 by applica... | 3,034 | 32.351648 | 89 | py |
benchmarks | benchmarks-master/scripts/util/convert_csv_to_json_test.py | # Copyright 2017 The TensorFlow 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 by applica... | 3,356 | 36.719101 | 80 | py |
benchmarks | benchmarks-master/scripts/util/benchmark_util.py | # Copyright 2017 The TensorFlow 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 by applica... | 3,476 | 36.387097 | 80 | py |
benchmarks | benchmarks-master/scripts/util/benchmark_util_test.py | # Copyright 2017 The TensorFlow 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 by applica... | 2,276 | 36.95 | 80 | py |
benchmarks | benchmarks-master/scripts/util/__init__.py | 0 | 0 | 0 | py | |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/preprocessing.py | # Copyright 2017 The TensorFlow 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 by applica... | 31,472 | 39.505792 | 90 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/power_logger.py | """ Descr:
A power consumption logger for nvidia gpus in a system using python.
author:
Ioannis Athanasiadis (supernlogn)
"""
import numpy as np
import subprocess
import threading
import time, datetime
import re
from json import dump
class NvidiaPowerReader(object):
def __init__(self, time_step=1, ... | 3,372 | 33.418367 | 102 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/constants.py | """Constants used in tf_cnn_benchmarks."""
from enum import Enum
class NetworkTopology(str, Enum):
"""Network topology describes how multiple GPUs are inter-connected.
"""
# DGX-1 uses hybrid cube mesh topology with the following device peer to peer
# matrix:
# DMA: 0 1 2 3 4 5 6 7
# 0: Y Y Y Y Y N N N... | 936 | 25.771429 | 79 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py | """Benchmark script for TensorFlow.
See the README for more information.
"""
from __future__ import print_function
from absl import app
from absl import flags as absl_flags
import tensorflow as tf
import benchmark_cnn
import cnn_util
import flags
import sys
from cnn_util import log_fn
sys.path.append("/usr/local/cu... | 1,290 | 27.065217 | 80 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/variable_mgr_util.py | # Copyright 2017 The TensorFlow 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 by applica... | 19,904 | 37.500967 | 107 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/convnet_builder.py | # Copyright 2017 The TensorFlow 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 by applica... | 20,618 | 40.403614 | 133 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/batch_allreduce.py | # # Copyright 2018 The TensorFlow 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 r... | 26,549 | 43.176373 | 82 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/data_utils.py | # Copyright 2018 The TensorFlow 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 by applica... | 5,421 | 38.007194 | 80 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/cnn_util.py | # Copyright 2017 The TensorFlow 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 by applica... | 8,485 | 32.541502 | 80 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/datasets.py | # Copyright 2017 The TensorFlow 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 by applica... | 7,179 | 30.353712 | 80 | py |
benchmarks | benchmarks-master/scripts/tf_cnn_benchmarks/variable_mgr.py | # Copyright 2017 The TensorFlow 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 by applica... | 30,926 | 37.610487 | 80 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.