python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import logging
from pathlib import Path
from typing import Any, Dict
if __name__ == "__main... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/batch_fetch_results.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
"""
A script to run multinode training with submitit.
Almost copy-paste from https://github.com/facebookresearch/deit/bl... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/run_with_submitit.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import logging
import os
from enum import Enum
from pathlib import Path
from typing import D... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/run_tasks.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import os
import uuid
from datetime import date
from pathlib import Path
from typing import Dict, Itera... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/run_grid_search.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Adapted from https://github.com/mlpen/Nystromformer
import logging
import os
import pickle
import random
i... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/setup/pathfinder.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Adapted from https://github.com/mlpen/Nystromformer
import logging
import pickle
import sys
import numpy a... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/setup/listops.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Adapted from https://github.com/mlpen/Nystromformer
import logging
import pickle
import sys
import numpy a... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/setup/text.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Adapted from https://github.com/mlpen/Nystromformer
import logging
import pickle
import sys
import numpy a... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/setup/retrieval.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Adapted from https://github.com/mlpen/Nystromformer
import logging
import pickle
import sys
sys.path.appen... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/setup/cifar10.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/code/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: adapted from the Nystromformer repo
# https://github.com/mlpen/Nystromformer
from enum import Enum
from typi... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/code/model_wrapper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Almost as-is from the Nystromformer repo
# https://github.com/mlpen/Nystromformer
import logging
import pick... | EXA-1-master | exa/libraries/xformers/xformers/benchmarks/LRA/code/dataset.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Dict, Optional, Sequence, Tuple, Union
import torch
import torch.nn... | EXA-1-master | exa/libraries/xformers/xformers/ops/swiglu_op.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import List, Optional, Sequence, Tuple, Union
import torch
def get_stack_strides(
tensors: Sequence[to... | EXA-1-master | exa/libraries/xformers/xformers/ops/unbind.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from .fmha import (
AttentionBias,
AttentionOp,
AttentionOpBase,
AttentionOpDispatch,
L... | EXA-1-master | exa/libraries/xformers/xformers/ops/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Dict, List, Type, TypeVar
import torch
def get_operator(library: str, name: str):
def no_s... | EXA-1-master | exa/libraries/xformers/xformers/ops/common.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional, Sequence
import torch
from .common import BaseOperator, get_xformers_operator, register_o... | EXA-1-master | exa/libraries/xformers/xformers/ops/indexing.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import replace
from typing import TYPE_CHECKING, Any, List, Optional, Set, Tuple
import torch
from ..... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/triton.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import textwrap
from typing import List, Type, TypeVar
from . import cutlass, flash, small_k, triton
from .attn_bias im... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/dispatch.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Optional, Tuple, Type, Union
import torch
from . import cutlass, flash, small_k, triton
from .a... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from dataclasses import dataclass
from typing import Iterable, List, Optional, Sequence, Tuple, Union
impor... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/attn_bias.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from dataclasses import dataclass
from typing import Any, List, Mapping, Optional, Set, Tuple, Type, Union
i... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/common.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import replace
from typing import Any, List, Optional, Set, Tuple
import torch
from ..common import g... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/flash.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, List, Mapping, Optional, Set, Tuple, Union
import torch
from ..common import get_xformers_opera... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/small_k.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, List, Mapping, Optional, Set, Tuple, Union
import torch
from ..common import get_xformers_oper... | EXA-1-master | exa/libraries/xformers/xformers/ops/fmha/cutlass.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from dataclasses import dataclass, field
from typing import Mapping, Tuple
import torch
@dataclass
class D... | EXA-1-master | exa/libraries/xformers/xformers/profiler/device_limits.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from .api import profile, step
from .profiler import MemSnapshotsProfiler, NsightProfiler, PyTorchProfiler
from .slow_ops... | EXA-1-master | exa/libraries/xformers/xformers/profiler/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Optional, Sequence, Tuple
import torch.nn as nn
from .profiler import MemSnapshotsProfiler, Nsi... | EXA-1-master | exa/libraries/xformers/xformers/profiler/api.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import json
import math
import os
from collections import defaultdict
from dataclasses import dataclass,... | EXA-1-master | exa/libraries/xformers/xformers/profiler/slow_ops_profiler.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import queue
import socket
import weakref
from dataclasses import dataclass
from typing import ... | EXA-1-master | exa/libraries/xformers/xformers/profiler/profiler.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from .utils import _csr_to_coo, _transpose_with_info
def _should_use_coo(a, sparsity):
if not a.is_c... | EXA-1-master | exa/libraries/xformers/xformers/sparse/_csr_ops.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from .blocksparse_tensor import BlockSparseTensor # noqa: F401
from .csr_tensor import SparseCSRTensor # noqa: F401
| EXA-1-master | exa/libraries/xformers/xformers/sparse/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
def _coo_to_csr(m, n, row_indices, column_indices):
# assumes coalesced coo
row_offsets = row_ind... | EXA-1-master | exa/libraries/xformers/xformers/sparse/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
import torch
from xformers.ops import masked_matmul
logger = logging.getLogger("xformers")
try:
f... | EXA-1-master | exa/libraries/xformers/xformers/sparse/blocksparse_tensor.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.ops import masked_matmul
from xformers.sparse import _csr_ops
from xformers.sparse.utils imp... | EXA-1-master | exa/libraries/xformers/xformers/sparse/csr_tensor.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import sys
import tempfile
import torch
is_windows = False
if sys.platform == "win32": # pytorch on windows uses gloo... | EXA-1-master | exa/libraries/xformers/xformers/helpers/test_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import copy
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
from xformers.components.res... | EXA-1-master | exa/libraries/xformers/xformers/helpers/hierarchical_configs.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from .timm_sparse_attention import TimmSparseAttention # noqa
| EXA-1-master | exa/libraries/xformers/xformers/helpers/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.components.attention.core import scaled_dot_product_attention
class TimmSparseAttention(to... | EXA-1-master | exa/libraries/xformers/xformers/helpers/timm_sparse_attention.py |
from xformers.components import MultiHeadDispatchConfig # noqa
from xformers.components.attention import AttentionConfig # noqa
from xformers.components.feedforward import FeedforwardConfig # noqa
from xformers.components.positional_embedding import PositionEmbeddingConfig # noqa
from .block_factory import xFormer... | EXA-1-master | exa/libraries/xformers/xformers/factory/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# register components configs into Hydra ConfigStore
# component config classes could be used to validate configs
import ... | EXA-1-master | exa/libraries/xformers/xformers/factory/hydra_helper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import asdict
from typing import Optional, Tuple, Union
import torch
import torch.nn as... | EXA-1-master | exa/libraries/xformers/xformers/factory/block_factory.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union
import torch
from... | EXA-1-master | exa/libraries/xformers/xformers/factory/model_factory.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional
from xformers.components... | EXA-1-master | exa/libraries/xformers/xformers/factory/block_configs.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: Reusing a lot of code from the Timm repo
# main difference is probably the handling of deepnorm init, and adap... | EXA-1-master | exa/libraries/xformers/xformers/factory/weight_init.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import argparse
import os
import random
import numpy as np
import torch
import torch.backen... | EXA-1-master | exa/models/MiniGPT-4-main/train.py |
import argparse
import os
import random
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import gradio as gr
from minigpt4.common.config import Config
from minigpt4.common.dist_utils import get_rank
from minigpt4.common.registry import registry
from minigpt4.conversation.conversation import Chat, ... | EXA-1-master | exa/models/MiniGPT-4-main/demo.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
import sys
from omegaconf import OmegaConf
from minigpt4.common.registry import ... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import os
import torch
import torch.distributed as dist
from minigpt4.common... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/tasks/base_task.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from minigpt4.common.registry import registry
from minigpt4.tasks.base_task import BaseTask
... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/tasks/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from minigpt4.common.registry import registry
from minigpt4.tasks.base_task import BaseTask
... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/tasks/image_text_pretrain.py |
EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/__init__.py | |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import gzip
import logging
import os
import random as rnd
import tarfile
import zipfile
impo... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/data_utils.py |
"""
This file is from
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import os
import shutil
import warnings
from omegaconf im... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/builders/base_dataset_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from minigpt4.datasets.builders.base_dataset_builder import load_dataset_config
from minigpt... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/builders/__init__.py |
import os
import logging
import warnings
from minigpt4.common.registry import registry
from minigpt4.datasets.builders.base_dataset_builder import BaseDatasetBuilder
from minigpt4.datasets.datasets.laion_dataset import LaionDataset
from minigpt4.datasets.datasets.cc_sbu_dataset import CCSBUDataset, CCSBUAlignDataset
... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/builders/image_text_pair_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import webdataset as wds
from minigpt4.datasets.datasets.base_dataset import BaseDataset
c... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/laion_dataset.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
from typing import Iterable
from torch.utils.data import Dataset, ConcatDataset... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/base_dataset.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import time
import random
import torch
from minigpt4.datasets.data_utils import move_to_cuda... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/dataloader_utils.py |
EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/__init__.py | |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from collections import OrderedDict
from minigpt4.datasets.datasets.base_dataset ... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/caption_datasets.py |
import os
from PIL import Image
import webdataset as wds
from minigpt4.datasets.datasets.base_dataset import BaseDataset
from minigpt4.datasets.datasets.caption_datasets import CaptionDataset
class CCSBUDataset(BaseDataset):
def __init__(self, vis_processor, text_processor, location):
super().__init__(vis... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/datasets/datasets/cc_sbu_dataset.py |
import logging
import random
import torch
from torch.cuda.amp import autocast as autocast
import torch.nn as nn
from minigpt4.common.registry import registry
from minigpt4.models.blip2 import Blip2Base, disabled_train
from minigpt4.models.modeling_llama import LlamaForCausalLM
from transformers import LlamaTokenizer
... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/mini_gpt4.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from dataclasses import dataclass
from typing import Optional
import torch
from transformer... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/blip2_outputs.py |
# Based on EVA, BEIT, timm and DeiT code bases
# https://github.com/baaivision/EVA
# https://github.com/rwightman/pytorch-image-models/tree/master/timm
# https://github.com/microsoft/unilm/tree/master/beit
# https://github.com/facebookresearch/deit/
# https://github.com/facebookresearch/dino
# -------------------------... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/eva_vit.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import torch
from omegaconf import OmegaConf
from minigpt4.common.registry i... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import os
import numpy as np
import torch
import torch.nn as nn
from minigpt... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/base_model.py |
# This script is based on https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py
""" PyTorch LLaMA model."""
import math
from typing import List, Optional, Tuple, Union
import torch
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/modeling_llama.py |
"""
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
* Based on huggingface code base
* https://github.com/huggingface/transformer... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/Qformer.py |
"""
Copyright (c) 2023, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import contextlib
import logging
import os
import time
import datetime
import torch
import t... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/models/blip2.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import re
from minigpt4.common.registry import registry
from minigpt4.processors.base_proce... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/processors/blip_processors.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from minigpt4.processors.base_processor import BaseProcessor
from minigpt4.processors.blip_p... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/processors/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from omegaconf import OmegaConf
class BaseProcessor:
def __init__(self):
self.... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/processors/base_processor.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import cv2
import numpy as np
import torch
## aug functions
def identity_func(img):
r... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/processors/randaugment.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import math
from minigpt4.common.registry import registry
@registry.register_lr_scheduler... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/optims.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import json
from typing import Dict
from omegaconf import OmegaConf
from min... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/config.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
class Registry:
mapping = {
"builder_name_mapping": {},
"task_name_mapp... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/registry.py |
EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/__init__.py | |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import datetime
import logging
import time
from collections import defaultdict, deque
impor... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/logger.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import io
import json
import logging
import os
import pickle
import re
import shutil
import ... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/utils.py |
import numpy as np
from matplotlib import pyplot as plt
from scipy.ndimage import filters
from skimage import transform as skimage_transform
def getAttMap(img, attMap, blur=True, overlap=True):
attMap -= attMap.min()
if attMap.max() > 0:
attMap /= attMap.max()
attMap = skimage_transform.resize(att... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/gradcam.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import datetime
import functools
import os
import torch
import torch.distributed as dist
im... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/common/dist_utils.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from minigpt4.runners.runner_base import RunnerBase
__all__ = ["RunnerBase"]
| EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/runners/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import datetime
import json
import logging
import os
import time
from pathlib import Path
i... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/runners/runner_base.py |
import argparse
import time
from PIL import Image
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, LlamaTokenizer
from transformers import StoppingCriteria, StoppingCriteriaList
import dataclasses
from enum import auto, Enum
from typing import List, Tuple, Any
from minigpt4.common.registry ... | EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/conversation/conversation.py |
EXA-1-master | exa/models/MiniGPT-4-main/minigpt4/conversation/__init__.py | |
import json
import csv
# specify input and output file paths
input_file = 'laion_synthetic_filtered_large.json'
output_file = 'laion_synthetic_filtered_large.tsv'
# load JSON data from input file
with open(input_file, 'r') as f:
data = json.load(f)
# extract header and data from JSON
header = data[0].keys()
rows... | EXA-1-master | exa/models/MiniGPT-4-main/dataset/convert_laion.py |
import json
import csv
# specify input and output file paths
input_file = 'ccs_synthetic_filtered_large.json'
output_file = 'ccs_synthetic_filtered_large.tsv'
# load JSON data from input file
with open(input_file, 'r') as f:
data = json.load(f)
# extract header and data from JSON
header = data[0].keys()
rows = [... | EXA-1-master | exa/models/MiniGPT-4-main/dataset/convert_cc_sbu.py |
import os
import argparse
import torch
import json
from collections import defaultdict
def parse_args():
parser = argparse.ArgumentParser(description='Extract MMProjector weights')
parser.add_argument('--model_name_or_path', type=str, help='model folder')
parser.add_argument('--output', type=str, help='ou... | EXA-1-master | exa/models/LLaVA-main/scripts/extract_mm_projector.py |
import dataclasses
from enum import auto, Enum
from typing import List, Tuple
class SeparatorStyle(Enum):
"""Different separator style."""
SINGLE = auto()
TWO = auto()
@dataclasses.dataclass
class Conversation:
"""A class that keeps all conversation history."""
system: str
roles: List[str]
... | EXA-1-master | exa/models/LLaVA-main/llava/conversation.py |
CONTROLLER_HEART_BEAT_EXPIRATION = 2 * 60
WORKER_HEART_BEAT_INTERVAL = 30
LOGDIR = "."
| EXA-1-master | exa/models/LLaVA-main/llava/constants.py |
EXA-1-master | exa/models/LLaVA-main/llava/__init__.py | |
import datetime
import logging
import logging.handlers
import os
import sys
import requests
from llava.constants import LOGDIR
server_error_msg = "**NETWORK ERROR DUE TO HIGH TRAFFIC. PLEASE REGENERATE OR REFRESH THIS PAGE.**"
moderation_msg = "YOUR INPUT VIOLATES OUR CONTENT MODERATION GUIDELINES. PLEASE TRY AGAIN.... | EXA-1-master | exa/models/LLaVA-main/llava/utils.py |
"""
Usage:
python3 -m fastchat.model.make_delta --base ~/model_weights/llama-7b --target ~/model_weights/vicuna-7b --delta ~/model_weights/vicuna-7b-delta --hub-repo-id lmsys/vicuna-7b-delta
"""
import argparse
import torch
from tqdm import tqdm
from transformers import AutoTokenizer, AutoModelForCausalLM
def make_d... | EXA-1-master | exa/models/LLaVA-main/llava/model/make_delta.py |
EXA-1-master | exa/models/LLaVA-main/llava/model/__init__.py | |
"""
Usage:
python3 -m fastchat.model.apply_delta --base ~/model_weights/llama-7b --target ~/model_weights/vicuna-7b --delta lmsys/vicuna-7b-delta
"""
import argparse
import torch
from tqdm import tqdm
from transformers import AutoTokenizer, AutoModelForCausalLM
def apply_delta(base_model_path, target_model_path, del... | EXA-1-master | exa/models/LLaVA-main/llava/model/apply_delta.py |
# Adopted from https://github.com/lm-sys/FastChat. Below is the original copyright:
# Adopted from tatsu-lab@stanford_alpaca. Below is the original copyright:
# Make it more memory efficient by monkey patching the LLaMA model with FlashAttn.
# Need to call this before importing transformers.
from llava.train.llama_fla... | EXA-1-master | exa/models/LLaVA-main/llava/train/train_mem.py |
# Adopted from https://github.com/lm-sys/FastChat. Below is the original copyright:
from typing import List, Optional, Tuple
import torch
from torch import nn
import transformers
from transformers.models.llama.modeling_llama import apply_rotary_pos_emb
from einops import rearrange
from flash_attn.flash_attn_interfa... | EXA-1-master | exa/models/LLaVA-main/llava/train/llama_flash_attn_monkey_patch.py |
# Adopted from https://github.com/lm-sys/FastChat. Below is the original copyright:
# Adopted from tatsu-lab@stanford_alpaca. Below is the original copyright:
# Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
#
# Licensed under the Apache License, Version 2.0 (the "License");
#... | EXA-1-master | exa/models/LLaVA-main/llava/train/train.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.