python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from typing import Union
from transformers import (AutoTokenizer, PreTrainedTokenizer,
PreTrainedTokenizerFast)
Tokenizer = Union[PreTrainedTokenizer, PreTrainedTokenizerFast]
# For consistency with T5 Toke... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/utils/adapt_tokenizer.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import math
import warnings
from collections.abc import Sequence
from functools import partial
from typing import Optional, Tuple, Union
import torch
from torch import nn
from llmfoundry.models.layers.norm import NORM_CLASS_REGISTRY
... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/utils/param_init_fns.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from llmfoundry.models.utils.adapt_tokenizer import (
AutoTokenizerForMOD, adapt_tokenizer_for_denoising)
from llmfoundry.models.utils.hf_prefixlm_converter import (
add_bidirectional_mask_if_missing, convert_hf_causal_lm_to_pr... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/utils/__init__.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Team. 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 a... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/utils/meta_init_context.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Converts Huggingface Causal LM to Prefix LM.
Conversion does lightweight surgery on a HuggingFace
Causal LM to convert it to a Prefix LM.
Prefix LMs accepts a `bidirectional_mask` input in `forward`
and treat the input prompt as t... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/utils/hf_prefixlm_converter.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from llmfoundry.models.hf.hf_causal_lm import ComposerHFCausalLM
from llmfoundry.models.hf.hf_fsdp import (prepare_hf_causal_lm_model_for_fsdp,
prepare_hf_enc_dec_model_for_fsdp,
... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/__init__.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Implements a Hugging Causal LM wrapped inside a :class:`.ComposerModel`."""
from typing import Union
from composer.metrics.nlp import (InContextLearningLMAccuracy,
InContextLearningLMExpectedCalib... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/hf_causal_lm.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Re-usable :class:`.ComposerModel` for LLM HF Models."""
from __future__ import annotations
import inspect
from collections import UserDict
from typing import List, Optional, Union
import torch
import transformers
from composer.mo... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/model_wrapper.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Implements a Hugging Prefix LM wrapped inside a :class:`.ComposerModel`."""
from __future__ import annotations
from composer.metrics.nlp import LanguageCrossEntropy, MaskedAccuracy
from omegaconf import DictConfig
from omegaconf i... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/hf_prefix_lm.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Implements a Hugging Face T5 wrapped inside a :class:`.ComposerModel`."""
from __future__ import annotations
from composer.metrics.nlp import LanguageCrossEntropy, MaskedAccuracy
from omegaconf import DictConfig
from omegaconf imp... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/hf_t5.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
# helper functions from https://github.com/CarperAI/trlx/blob/main/trlx/utils/modeling.py
# which is MIT licensed
import functools
from typing import Any, Iterable, List
from transformers import PreTrainedModel
from transformers.mode... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/models/hf/hf_fsdp.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Streaming dataloader for (mixture of) denoising task(s)."""
import logging
import random
import sys
from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Union
import numpy as np
import torch
from omegaconf im... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/denoising.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Datasets for converting to MDS Shards."""
import os
import warnings
from typing import Dict, Iterable, Union
import datasets as hf_datasets
import numpy as np
from torch.utils.data import IterableDataset
from transformers import Pr... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/datasets.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from llmfoundry.data.datasets import ConcatTokensDataset, NoConcatDataset
from llmfoundry.data.denoising import (MixtureOfDenoisersCollator,
build_text_denoising_dataloader)
from llmfoundry.data.f... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/__init__.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
from typing import Callable, Dict, List, Literal, Optional, Tuple
import numpy as np
import torch
class BinPackWrapper:
"""Utility collator for packing to reduce padding."""
def __init__(self,
col... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/packing.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Build a StreamingTextDataset dataset and dataloader for training."""
import os
from itertools import islice
from typing import Any, Callable, Dict, List, Optional, Sequence, Union
import numpy as np
import torch
import transformer... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/text_data.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Includes code for task-specific seq-to-seq data formatting.
This file provides some templates/examples of preprocessing functions
that format examples for use in seq-to-seq finetuning tasks.
These preprocessing functions take indiv... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/finetuning/tasks.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import logging
import warnings
from typing import Any, Dict, List, Optional, Union
import torch
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast
log = logging.getLogger(__name__)
# HuggingFace hardcodes the igno... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/finetuning/collator.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from llmfoundry.data.finetuning.collator import Seq2SeqFinetuningCollator
from llmfoundry.data.finetuning.dataloader import build_finetuning_dataloader
__all__ = ['Seq2SeqFinetuningCollator', 'build_finetuning_dataloader']
| EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/finetuning/__init__.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import logging
from typing import Union
import torch
from composer.utils import dist
from omegaconf import DictConfig
from torch.utils.data import DataLoader
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast
from ... | EXA-1-master | exa/libraries/llm-foundry/llmfoundry/data/finetuning/dataloader.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import copy
import os
import warnings
from typing import cast
from unittest import mock
import pytest
import torch
import torch.nn as nn
from composer.core.precision import get_precision_context
from composer.optim import DecoupledAda... | EXA-1-master | exa/libraries/llm-foundry/tests/test_model.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
from typing import List, Optional
import pytest
from composer.utils import reproducibility
# Allowed options for pytest.mark.world_size()
# Important: when updating this list, make sure to also up ./.ci/test.sh
# (so tests ... | EXA-1-master | exa/libraries/llm-foundry/tests/conftest.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import shutil
import sys
import tempfile
from argparse import Namespace
import pytest
import torch
from omegaconf import OmegaConf as om
from llmfoundry import (build_finetuning_dataloader,
build_tex... | EXA-1-master | exa/libraries/llm-foundry/tests/test_dataloader.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from composer.utils import reproducibility
from omegaconf import OmegaConf as om
def allclose_helper(t0, t1, rtol=1e-2, atol=1e-2):
return torch.allclose(t0, t1, rtol=rtol, atol=atol)
@pytest.mark.gpu... | EXA-1-master | exa/libraries/llm-foundry/tests/test_flash_triton_torch.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
from omegaconf import OmegaConf as om
from transformers import AutoTokenizer
def get_config(conf_path='scripts/train/yamls/mpt/125m.yaml'):
with open(conf_path) as f:
test_cfg = om.load(f)
return test_cfg
def test_l... | EXA-1-master | exa/libraries/llm-foundry/tests/test_tokenizer.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import math
from collections import OrderedDict
from collections.abc import Sequence
from functools import partial
import pytest
import torch
from composer.utils import reproducibility
from omegaconf import OmegaConf as om
from torch ... | EXA-1-master | exa/libraries/llm-foundry/tests/test_init_fn.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import torch
from composer.utils import reproducibility
from transformers import AutoConfig, AutoModelForCausalLM
from llmfoundry import MPTConfig, MPTForCausalLM
def gen_random_batch(batch_size: int, vocab_size: int, max_seq_len: i... | EXA-1-master | exa/libraries/llm-foundry/tests/test_onnx.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import random
import shutil
from pathlib import Path
import pytest
from omegaconf import OmegaConf as om
from transformers import AutoTokenizer
from llmfoundry.utils.builders import build_icl_evaluators
def load_icl_confi... | EXA-1-master | exa/libraries/llm-foundry/tests/test_icl_datasets.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import warnings
import pytest
import torch
from composer.utils import reproducibility
from omegaconf import OmegaConf as om
from llmfoundry import COMPOSER_MODEL_REGISTRY
@pytest.mark.gpu
@pytest.mark.xfail(reason='CUDA OOM expecte... | EXA-1-master | exa/libraries/llm-foundry/tests/test_hf_v_mpt.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import warnings
import pytest
import torch
from omegaconf import OmegaConf as om
# Add repo root to path so we can import scripts and test it
repo_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..... | EXA-1-master | exa/libraries/llm-foundry/tests/test_training.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import shutil
import sys
from argparse import Namespace
# Add repo root to path so we can import scripts and test it
repo_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(repo_dir)
from sc... | EXA-1-master | exa/libraries/llm-foundry/tests/test_data_prep_scripts.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import tempfile
from argparse import ArgumentParser, Namespace
from collections import OrderedDict
from copy import deepcopy
from pathlib import Path
from typing import Any, Dict, Optional, Union
import torch
from composer.u... | EXA-1-master | exa/libraries/llm-foundry/scripts/misc/convert_examples_ckpt.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import os
import platform
from argparse import ArgumentParser, Namespace
from typing import Dict, Iterable, List, Optional, Union
import datasets as hf_datasets
from streaming import MDSWriter
from torch.utils.data import DataLoader, ... | EXA-1-master | exa/libraries/llm-foundry/scripts/data_prep/convert_finetuning_dataset.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Streaming dataset conversion scripts for json files."""
import os
import platform
from argparse import ArgumentParser, Namespace
from enum import Enum
from glob import glob
from typing import Dict, Iterable, Optional
import dataset... | EXA-1-master | exa/libraries/llm-foundry/scripts/data_prep/convert_dataset_json.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Streaming dataset conversion scripts for C4 and The Pile."""
import os
import platform
from argparse import ArgumentParser, Namespace
from dataclasses import dataclass
from enum import Enum
from typing import Dict, Iterable, Optiona... | EXA-1-master | exa/libraries/llm-foundry/scripts/data_prep/convert_dataset_hf.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import contextlib
import os
import sys
import warnings
from composer import Trainer
from composer.core import Evaluator
from composer.utils import dist, get_device, reproducibility
from omegaconf import OmegaConf as om
from llmfoundr... | EXA-1-master | exa/libraries/llm-foundry/scripts/train/train.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import argparse
import math
import os
import requests
import yaml
from mcli.models.run_config import SchedulingConfig
from mcli.sdk import RunConfig, create_run, get_clusters
def _get_cluster_info():
clusters = get_clusters()
... | EXA-1-master | exa/libraries/llm-foundry/scripts/train/benchmarking/submit_benchmarks.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import argparse
import csv
import math
from typing import Any, Dict
from mcli import sdk as msdk
GPU_AVAILABLE_FLOPS = 312_000_000_000_000
def str_to_bool(value):
# helper fn
if isinstance(value, bool):
return value... | EXA-1-master | exa/libraries/llm-foundry/scripts/train/benchmarking/collect_results.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import time
import warnings
from argparse import ArgumentParser, ArgumentTypeError, Namespace
from typing import Any, Dict, Tuple, Union
import torch
from transformers import (AutoConfig, AutoModelForCausalLM, AutoTokenizer,
... | EXA-1-master | exa/libraries/llm-foundry/scripts/inference/hf_chat.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
__all__ = []
| EXA-1-master | exa/libraries/llm-foundry/scripts/inference/__init__.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""Basic HuggingFace -> ONNX export script.
This scripts show a basic HuggingFace -> ONNX export workflow. This works for a MPT model
that has been saved using `MPT.save_pretrained`. For more details and examples
of exporting and work... | EXA-1-master | exa/libraries/llm-foundry/scripts/inference/convert_hf_to_onnx.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import ast
import importlib
import json
import os
import tempfile
from argparse import ArgumentParser, Namespace
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
import sentencepiece as spm
import torch
imp... | EXA-1-master | exa/libraries/llm-foundry/scripts/inference/convert_composer_to_hf.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import random
import time
import warnings
from argparse import ArgumentParser, ArgumentTypeError, Namespace
from contextlib import nullcontext
import torch
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
def... | EXA-1-master | exa/libraries/llm-foundry/scripts/inference/hf_generate.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import contextlib
import sys
import time
import numpy as np
import torch
# You can use this to load the model weights
from omegaconf import OmegaConf as om
from llmfoundry import COMPOSER_MODEL_REGISTRY
def get_precision(precision)... | EXA-1-master | exa/libraries/llm-foundry/scripts/inference/benchmarking/benchmark.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
import sys
import time
from typing import List
import torch
from composer.loggers import InMemoryLogger, LoggerDestination
from composer.trainer import Trainer
from composer.utils import dist, get_device, reproducibility
from omegacon... | EXA-1-master | exa/libraries/llm-foundry/scripts/eval/eval.py |
# Copyright 2022 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 MosaicML Composer authors
# SPDX-License-Identifier: Apache-2.0
"""Run pytest using MCP."""
import argparse
import time
from mcli.sdk import (RunConfig, RunStatus, create_run, follow_run_logs,
... | EXA-1-master | exa/libraries/llm-foundry/.github/mcp/mcp_pytest.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from setuptools import setup, find_namespace_packages
import platform
DEPENDENCY_LINKS = []
if pl... | EXA-1-master | exa/libraries/LAVIS/setup.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE 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.backends.cud... | EXA-1-master | exa/libraries/LAVIS/train.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import argparse
import random
import numpy as np
import torch
import torch.backends.cudnn as cudn... | EXA-1-master | exa/libraries/LAVIS/evaluate.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from PIL import Image
import requests
import torch
import os
from lavis.common.registry ... | EXA-1-master | exa/libraries/LAVIS/app/calculate_coco_features.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import plotly.graph_objects as go
import requests
import streamlit as st
import torch
from... | EXA-1-master | exa/libraries/LAVIS/app/classification.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import math
import numpy as np
import streamlit as st
from lavis.models.blip_models.blip_... | EXA-1-master | exa/libraries/LAVIS/app/text_localization.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from PIL import Image
import requests
import streamlit as st
import torch
@st.cache()
d... | EXA-1-master | exa/libraries/LAVIS/app/__init__.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import numpy as np
import streamlit as st
import torch
from lavis.models.blip_models.blip_... | EXA-1-master | exa/libraries/LAVIS/app/image_text_match.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import random
from collections import OrderedDict
from functools import reduce
from tkinte... | EXA-1-master | exa/libraries/LAVIS/app/dataset_browser.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import streamlit as st
from app import device, load_demo_image
from app.utils import load_... | EXA-1-master | exa/libraries/LAVIS/app/caption.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import numpy as np
import streamlit as st
import torch
from lavis.models import BlipBase, ... | EXA-1-master | exa/libraries/LAVIS/app/utils.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
import numpy as np
import streamlit as st
import torch
import torch.nn.function... | EXA-1-master | exa/libraries/LAVIS/app/multimodal_search.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
"""
This file is the framework for generating multiple Streamlit applications
through an o... | EXA-1-master | exa/libraries/LAVIS/app/multipage.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import streamlit as st
from app import load_demo_image, device
from app.utils import load_... | EXA-1-master | exa/libraries/LAVIS/app/vqa.py |
"""
# Copyright (c) 2022, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from app.multipage import MultiPage
from app import vqa, caption
from app import image_tex... | EXA-1-master | exa/libraries/LAVIS/app/main.py |
#!/usr/bin/env python
# coding: utf-8
# <a href="https://colab.research.google.com/github/anthonytmh/lavis-pnpvqa/blob/pnp_vqa/projects/pnp-vqa/pnp_vqa.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
# ## Img2Prompt-VQA: Inference Demo
# In[2]:
... | EXA-1-master | exa/libraries/LAVIS/projects/img2llm-vqa/img2llm_vqa.py |
"""
#
# Copyright (c) 2022 salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
Integration tests for PNP-VQA model.
"""
import pytest
import torch
from lavis.models import l... | EXA-1-master | exa/libraries/LAVIS/tests/models/test_pnp_vqa.py |
"""
#
# Copyright (c) 2022 salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
Integration tests for ALBEF models.
"""
import pytest
import torch
from lavis.models import lo... | EXA-1-master | exa/libraries/LAVIS/tests/models/test_albef.py |
"""
#
# Copyright (c) 2022 salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
Integration tests for BLIP2 models.
"""
import pytest
import torch
from lavis.models import lo... | EXA-1-master | exa/libraries/LAVIS/tests/models/test_blip2.py |
"""
#
# Copyright (c) 2022 salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
Integration tests for BLIP models.
"""
import pytest
import torch
from lavis.models import loa... | EXA-1-master | exa/libraries/LAVIS/tests/models/test_blip.py |
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | EXA-1-master | exa/libraries/LAVIS/docs/conf.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
import sys
from omegaconf import OmegaConf
from lavis.common.registry import registry
... | EXA-1-master | exa/libraries/LAVIS/lavis/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE 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 lavis.common.dist_uti... | EXA-1-master | exa/libraries/LAVIS/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.tasks.base_task import BaseTask
from lavis.t... | EXA-1-master | exa/libraries/LAVIS/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
import logging
import os
import numpy as np
import torch
from lavis.common.dist_utils... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/retrieval.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.tasks.base_task import BaseTask
@registry.... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/image_text_pretrain.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
import os
from lavis.common.dist_utils import main_process
from lavis.common.logger i... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/dialogue.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
import os
from lavis.common.dist_utils import main_process
from lavis.common.registry... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/captioning.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import json
import os
import lavis.common.dist_utils as dist_utils
from lavis.comm... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/vqa.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import json
import os
import torch
import torch.distributed as dist
from itertools ... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/vqa_reading_comprehension.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
import os
import logging
import numpy as np
import torch
from lavis.common.dist_utils... | EXA-1-master | exa/libraries/LAVIS/lavis/tasks/multimodal_classification.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE 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
import de... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/data_utils.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from lavis.common.registry import registry
from lavis.datasets.builders.base_dataset_bu... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/imagefolder_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import logging
import os
import shutil
import warnings
import lavis.common.utils as utils
import ... | EXA-1-master | exa/libraries/LAVIS/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.common.utils import get_cache_path
from lavi... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/video_qa_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.datasets.builders.base_dataset_builder import load_dataset_config
from lavis.datasets.b... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/__init__.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.datasets.builders.base_dataset_builder import BaseDatasetBuilder
from lavis.datasets.da... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/retrieval_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.datasets.builders.base_dataset_builder import BaseDatasetBuilder
from lavis.common.reg... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/vqa_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.datasets.builders.base_dataset_builder impor... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/dialogue_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from lavis.common.registry import registry
from lavis.datasets.builders.base_dataset_bu... | EXA-1-master | exa/libraries/LAVIS/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.datasets.builders.base_dataset_builder import BaseDatasetBuilder
from lavis.datasets.da... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/caption_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.datasets.builders.base_dataset_builder impor... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/builders/classification_builder.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from collections import OrderedDict
from lavis.datasets.datasets.base_dataset import Ba... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/imagefolder_dataset.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import webdataset as wds
from lavis.datasets.datasets.base_dataset import BaseDataset
class Laio... | EXA-1-master | exa/libraries/LAVIS/lavis/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 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
from ... | EXA-1-master | exa/libraries/LAVIS/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
import random
from collections import OrderedDict
from lavis.datasets.datasets.multimo... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/nlvr_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import time
import random
import torch
from lavis.datasets.data_utils import move_to_cuda
from tor... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/dataloader_utils.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from PIL import Image
from lavis.datasets.datasets.vqa_datasets import VQADataset
cl... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/vg_vqa_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from abc import abstractmethod
from lavis.datasets.datasets.base_dataset import BaseDataset
clas... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/multimodal_classification_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from collections import OrderedDict
from lavis.datasets.datasets.base_dataset import Ba... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/image_text_pair_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from lavis.datasets.datasets.base_dataset import BaseDataset
from lavis.datasets.datase... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/video_caption_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import json
import os
from collections import OrderedDict
from lavis.datasets.datasets.multimodal... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/video_vqa_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
from collections import OrderedDict
from PIL import Image
from lavis.datasets.datasets... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/dialogue_datasets.py |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
import os
import json
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_I... | EXA-1-master | exa/libraries/LAVIS/lavis/datasets/datasets/coco_caption_datasets.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.