python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict from functools import partial from typing import Any, Callable, Dict, Itera...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/loss.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """Collections of utilities related to optimization.""" from bisect import bisect_right import torch def upd...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/optimizer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import argparse import json import random from copy import deepcopy from pathlib import Path import numpy as n...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/vqa_eval.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import random import pytest import torch from examples.mdetr.matcher import HungarianMatcher from tests.test_u...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/tests/test_matcher.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from copy import deepcopy import pytest import torch from examples.mdetr.data.postprocessors import PostProces...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/tests/test_postprocessors.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from examples.mdetr.loss import construct_positive_map, contrastive_alignment_loss f...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/tests/test_loss.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Various utilities related to track and report metrics """ import datetime import time from collections impo...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/utils/metrics.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, List, Optional import torch from torch import Tensor def interpolate( inpu...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/utils/misc.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/utils/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import argparse def get_args_parser(): parser = argparse.ArgumentParser("MDETR", add_help=False) par...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/utils/args_parse.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import functools import io import os import torch import torch.distributed as dist _LOCAL_PROCESS_GROUP = Non...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/utils/dist.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import random from typing import Any, Callable, Dict, Iterable, Union import PIL import torch import torchvisi...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/transforms.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json from pathlib import Path import torch from data.transforms import ConvertCocoPolysToMask, create_...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functools import partial from typing import Callable, Optional import torch from data.dataset import buil...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/datamodule.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import List import numpy as np import torch import torch.nn.functional as F from torch import Tens...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/postprocessors.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ Evaluator for Flickr30k """ import xml.etree.ElementTree as Et from pathlib import Path from typing import ...
EXA-1-master
exa/libraries/multimodal-main/examples/mdetr/data/flickr_eval.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from examples.mugen.retrieval.video_clip import ( Projection, TextEncoder, ...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/tests/retrieval/test_video_clip.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from examples.mugen.generation.video_vqvae import video_vqvae_mugen from tests.test...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/tests/generation/test_video_vqvae.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from examples.mugen.generation.text_video_gpt import text_video_gpt from tests.te...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/tests/generation/test_text_video_gpt.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Any, Dict, Optional, Tuple from examples.mugen.data.mugen...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/retrieval/definitions.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import warnings from typing import Any, Tuple import torch from examples.mugen.retrieval.video_clip import vi...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/retrieval/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from examples.mugen.data.mugen_datamodules import MUGENDataModule from examples.mugen.data.mugen_dataset import...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/retrieval/train.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import warnings from typing import Any, Dict, Optional import torch from torch import nn from torchmultimoda...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/retrieval/video_clip.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from examples.mugen.data.mugen_datamodules import MUGENDataModule from examples.mugen.data.mugen_dataset import...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/retrieval/eval.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json import os from dataclasses import dataclass import numpy as np import torch from examples.mugen.da...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/mugen_dataset.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from tqdm import tqdm label_color_map = { 0: torch.FloatTensor((0, 0, 0)), 1: torch.Floa...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/video_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import av import numpy as np # Audio constants are from MUGEN's audio VQVAE implementation # (https://github....
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/audio_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional import pytorch_lightning as pl import torch import torch.distributed as ...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/mugen_datamodules.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json class Game: def __init__(self, **kwargs): self.game_id = -1 self.level_seed =...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/coinrun/game.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import os import numpy as np from PIL import Image DEATH_ANIM_LENGTH = 30 FINISHED_LEVEL_ANIM_LEN...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/coinrun/construct_from_json.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json class Sequence: def __init__( self, start_frame, end_frame, pose_type, start_x, start...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/data/coinrun/generate_text_desc.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional from torchmultimodal.models.video_vqvae import ( preprocess_int_conv_params, ...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/generation/video_vqvae.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import List, Optional, Tuple import torch from examples.mugen.generation.video_vqvae import video...
EXA-1-master
exa/libraries/multimodal-main/examples/mugen/generation/text_video_gpt.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from torchmultimodal.utils.file_io import _get_path_manager _PATH_MANAGER = _get_path_manager()
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch from torch import Tensor def get_extended_attention_mask(attention_...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/attention.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import warnings from typing import Any, List, NamedTuple, Optional, Tuple import torch from torch import nn, T...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/generate.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Sized def assert_equal_lengths( *args: Sized, msg: str = "iterable arguments must have...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/assertion.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import List import torch from torch import Tensor from torch.distributed import all_gather as all_...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/distributed.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import warnings from collections import OrderedDict from copy import deepcopy from dataclasses import fields fr...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/common.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from iopath.common.file_io import HTTPURLHandler, PathManager def _get_path_manager() -> PathManager: try...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/utils/file_io.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, cast, List, Optional, Tuple, Union from torch import nn, Size, Tensor from torchmulti...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/video_vqvae.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict from typing import Dict, List, NamedTuple, Optional from torch import nn, ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/two_tower.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Tuple from torch import nn from torchmultimodal.models.gpt import ( MultimodalGPT, ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/video_gpt.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Dict import torch from torch import nn class LateFusion(nn.Module): """A generic arch...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/late_fusion.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, List, Optional import torch import torchmultimodal.utils.common as common_utils ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/omnivore.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import NamedTuple, Tuple, Union from torch import nn, Size, Tensor from torchmultimodal.modules.la...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/vqvae.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functools import partial from typing import Any, Callable, Dict, NamedTuple, Optional, Tuple, Union impor...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/gpt.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/flava/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Code for some of the transformers components in this file are initialized # from their counterparts in Huggin...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/flava/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functools import partial from typing import Callable from torch import nn from torchmultimodal.models.fla...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/flava/text_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functools import partial from typing import Any, Callable, Optional import torch from torch import nn, Te...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/flava/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import warnings from functools import partial from typing import Any, Callable, Dict, Optional, Tup...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/flava/image_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/clip/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import NamedTuple import torch import torch.nn.functional as F from torch import nn from torchmu...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/clip/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn, Tensor from torch.nn import TransformerEncoder, TransformerEncoderLayer fr...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/clip/text_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # This code is based on https://github.com/openai/CLIP/blob/main/clip/model.py from collections import Ordered...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/clip/image_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional from torch import nn, Tensor from torchmultimodal.modules.layers.transf...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/albef/multimodal_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/albef/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy from collections import namedtuple from typing import Tuple import torch import torch.nn.functiona...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/albef/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from functools import partial from torch import nn, Tensor from torchvision.models.feature_extraction import c...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/albef/image_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/mdetr/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from collections import OrderedDict from typing import Dict, List, NamedTuple, Optional, Tuple im...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/mdetr/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch from torch import nn, Tensor from torchmultimodal.modules.encoders.be...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/mdetr/text_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, NamedTuple, Optional import torch from torch import nn, Tensor from torchmultimod...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/mdetr/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Tuple import torch import torch.nn.functional as F from torch import nn, Tensor f...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/models/mdetr/image_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import List import torch from torchtext.transforms import ( AddToken, BERTTokenizer, ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/transforms/bert_text_transform.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import random import warnings from typing import Any, Dict, List, Mapping, Optional, Tuple, Union ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/transforms/flava_transform.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/transforms/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Tuple import torch import torch.nn.functional as F from torchmultimodal.utils.common import...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/transforms/video_transform.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, List, Optional, Tuple, Union import torch from PIL.Image import Image from torch ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/transforms/clip_transform.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import warnings from dataclasses import dataclass, field from typing import Any, Callable, Optional...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/flava.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any from torch import nn, Tensor from torch.nn import functional as F class CommitmentLos...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/vqvae.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from dataclasses import dataclass from typing import Any, Dict, Optional, OrderedDict, Tuple, Union...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/contrastive_loss_with_temperature.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch import torch.nn.functional as F from torch import nn, Tensor class ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/albef.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import List, NamedTuple, Tuple import torch import torch.nn.functional as F from torch import Tens...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/losses/mdetr.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional import torch from torch import nn, Tensor class AttentionFusionModul...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/fusions/attention_fusion.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Dict import torch from torch import nn class ConcatFusionModule(nn.Module): """Module...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/fusions/concat_fusion.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/fusions/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Dict, Optional, Tuple import torch import torch.nn.functional as F from torch imp...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/fusions/deepset_fusion.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, Optional, Tuple, Union import torch from torch import nn, Tensor from torch.nn i...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/attention.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch from torch import nn, Tensor class BERTTextEmbeddings(nn.Module): ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/text_embedding.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, List, Mapping, NamedTuple, Tuple, Union import torch from torch import nn, Size, Tenso...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/codebook.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, List, Optional, Union import torch from torch import nn class MLP(nn.Module): ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/mlp.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any from torch import nn, Tensor class Fp32LayerNorm(nn.LayerNorm): def __init__(self...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/normalizations.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn, Tensor class SiLU(nn.Module): r"""Sigmoid Linear Unit .. math:: \...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/activation.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Code for some of the transformers components in this file are initialized # from their counterparts in Huggin...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import itertools from typing import Tuple import torch from torch import nn, Tensor class BroadcastedPositio...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/position_embedding.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import warnings from itertools import repeat from typing import Any, Tuple, Union from torch import nn, Size, ...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/conv.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch.nn.functional as F from torch import nn, Tensor class MultiHeadSelf...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/layers/multi_head_attention.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn, Tensor POOLING_TYPES = ["sum", "mean", "max"] class EmbeddingEncoder(nn....
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/encoders/embedding_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Modified from 2d Swin Transformers in torchvision: # https://github.com/pytorch/vision/blob/main/torchvision/...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/encoders/swin_transformer_3d_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, List, Optional, Union import torch from torch import nn, Tensor from torchmultimo...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/encoders/mil_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/encoders/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Tuple, Union import torch from torch import nn, Tensor class WeightedEmbeddingE...
EXA-1-master
exa/libraries/multimodal-main/torchmultimodal/modules/encoders/weighted_embedding_encoder.py