python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
"""Run validation loop for GILL.""" import collections from PIL import Image import time import tqdm import torch import torch.distributed as dist from torch.utils.tensorboard import SummaryWriter from torch.utils.data import Subset from torchmetrics import BLEUScore import torchvision from gill import losses as losse...
gill-main
gill/validate.py
from enum import Enum import subprocess import sys import shutil import torch import torch.distributed as dist from torchvision.transforms import functional as F from torchvision import transforms as T from transformers import AutoFeatureExtractor from PIL import Image, ImageDraw, ImageFont, ImageOps import random impo...
gill-main
gill/utils.py
"""A slightly modified version of the HuggingFace StableDiffusion pipeline, to allow us to extract text embeddings.""" # 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 ...
gill-main
gill/custom_sd.py
"""Helper file defining some common loss functions.""" from typing import Optional import torch from gill import utils def l1_loss(u: torch.Tensor, v: torch.Tensor) -> torch.Tensor: """ Args: u: (N, D) tensor. v: (N, D) tensor. Returns: l1_loss: (N,) tensor of summed L1 loss. """ assert u.shape ...
gill-main
gill/losses.py
import torch from torch import nn class TextFcLayer(nn.Module): """Layers used in mapping text embeddings to visual outputs.""" def __init__(self, in_dim: int, out_dim: int, num_input_tokens: int = 1, num_output_tokens: int = 1, mode: str = 'linear'): super().__init__() self.num_input_tokens = num_input...
gill-main
gill/layers.py
"""Modified from https://github.com/mlfoundations/open_clip""" from typing import Optional, Tuple, List import collections import logging import os import numpy as np import pandas as pd import torch import torchvision.datasets as datasets from torchvision import transforms as T from PIL import Image, ImageFont from ...
gill-main
gill/data.py
import collections import json import os import PIL from tqdm import tqdm from gill import utils # Download the Visual Storytelling SIS dataset from https://visionandlanguage.net/VIST/json_files/story-in-sequence/SIS-with-labels.tar.gz # Extract the files (there should be three sets: train, val, and test). # We use th...
gill-main
evals/download_vist_images.py
import json import os import numpy as np from PIL import Image from transformers import CLIPProcessor, CLIPModel from tqdm import tqdm # Define the paths to the groundtruth / generated image directories. gen_img_dir = 'gill_vist_outputs/' gt_img_dir = "sis/val_images/" vist_data_path = 'sis/val_formatted.json' if _...
gill-main
evals/compute_clip_similarity_vist.py
import json import os import numpy as np from PIL import Image from transformers import CLIPProcessor, CLIPModel from tqdm import tqdm # Define the paths to the groundtruth / generated image directories. gen_img_dir = 'gill_visdial_outputs/' visdial_dir = 'VisualDialog/' if __name__ == "__main__": # Load CLIP m...
gill-main
evals/compute_clip_similarity_visdial.py
"""Uses GILL to generate images for VIST interleaved image + text sequences. Example usage: python generate_vist_images.py gill_vist_outputs """ from collections import namedtuple import json import os import pickle as pkl import sys from PIL import Image import torch from tqdm import tqdm from gill import model...
gill-main
evals/generate_vist_images.py
import argparse import os import lpips import torchvision from tqdm import tqdm import numpy as np import ssl ssl._create_default_https_context = ssl._create_unverified_context parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-d0','--dir0', type=str, defaul...
gill-main
evals/lpips_2dirs.py
"""Uses GILL to generate images for VisDial dialogue sequences. Example usage: python generate_visdial_images.py gill_visdial_outputs """ from collections import namedtuple import json import os import pickle as pkl import sys from PIL import Image import torch from tqdm import tqdm from gill import models # D...
gill-main
evals/generate_visdial_images.py
"""Runs Stable Diffusion v1.5 to generate images for PartiPrompts. Example usage: python scripts/generate_sd_p2_images.py data/PartiPromptsAllDecisions.tsv partiprompts_sd_v1.5_outputs """ import os import sys import numpy as np import torch from tqdm import tqdm from diffusers import StableDiffusionPipeline p...
gill-main
scripts/generate_sd_p2_images.py
"""Prunes model weights to keep just the necessary trained weights. Example usage: python scripts/prune_model_ckpt.py runs/gill_exp """ import json import os import sys import torch if __name__ == '__main__': model_dir = sys.argv[1] with open(os.path.join(model_dir, 'ckpt_best.pth.tar'), 'rb') as f: ...
gill-main
scripts/prune_model_ckpt.py
"""Preprocesses annotated PartiPrompts decisions to keep only those with high inter-annotator agreement. Example usage: python scripts/process_p2_annotations.py """ import collections if __name__ == "__main__": # Load the annotated PartiPrompts. id2decision = {} with open('data/PartiPromptsAllDecisions...
gill-main
scripts/process_p2_annotations.py
"""This script extracts text embeddings from the text encoder of Stable Diffusion for a given dataset of captions, and saves them to disk. The outputs are used in training GILL. Example usage: python scripts/preprocess_sd_embeddings.py datasets/cc3m_val.tsv data/cc3m/validation/clip_embs """ import numpy as np impor...
gill-main
scripts/preprocess_sd_embeddings.py
from setuptools import setup, find_packages setup( name = 'flash-attention-jax', packages = find_packages(exclude=[]), version = '0.2.0', license='MIT', description = 'Flash Attention - in Jax', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', long_description_content_type = 'text/markdown'...
flash-attention-jax-main
setup.py
import jax from jax import nn from jax import jit, numpy as jnp from jax.numpy import einsum from einops import rearrange EPSILON = 1e-10 MASK_VALUE = -1e10 COSINE_SIM_SCALE = 10 @jit def attention(q, k, v, key_mask): dim, k_len = q.shape[-1], k.shape[-2] scale = 1 / jnp.sqrt(dim) q = q * scale sim ...
flash-attention-jax-main
flash_attention_jax/attention.py
import math from functools import partial import jax from jax import lax, numpy as jnp, jit # constants HIGHEST_PRECISION = jax.lax.Precision.HIGHEST einsum = partial(jnp.einsum, precision = HIGHEST_PRECISION) # Figure 1 from https://arxiv.org/abs/2112.05682 # cleaned up def _query_chunk_attention(q, k, v, k_chun...
flash-attention-jax-main
flash_attention_jax/rabe_attention.py
from flash_attention_jax.flash_attention import flash_attention from flash_attention_jax.cosine_sim_flash_attention import cosine_sim_flash_attention from flash_attention_jax.causal_flash_attention import causal_flash_attention from flash_attention_jax.rabe_attention import rabe_attention from flash_attention_jax.atten...
flash-attention-jax-main
flash_attention_jax/__init__.py
import math import jax from functools import partial from jax import nn from jax import custom_vjp from jax import numpy as jnp, lax, jit # constants EPSILON = 1e-10 MASK_VALUE = -1e10 Q_CHUNK_SIZE = 1024 K_CHUNK_SIZE = 1024 COSINE_SIM_SCALE = 10 # this may need to be a function of log(sequence length), but 16 was s...
flash-attention-jax-main
flash_attention_jax/cosine_sim_flash_attention.py
import math import jax from functools import partial from jax import nn from jax import custom_vjp from jax import numpy as jnp, lax, jit # constants EPSILON = 1e-10 MASK_VALUE = -1e10 Q_CHUNK_SIZE = 1024 K_CHUNK_SIZE = 1024 # flash attention def _query_chunk_flash_attention(q_range_chunk, k_range, q, k, v): q...
flash-attention-jax-main
flash_attention_jax/causal_flash_attention.py
import jax from functools import partial import jax.numpy as jnp from jax import random from jax import value_and_grad def value_and_grad_wrapper(fn, **kwargs): @partial(value_and_grad, **kwargs) def inner(*args, **kwargs): return jnp.sum(fn(*args, **kwargs)) return inner def diff(t1, t2): ret...
flash-attention-jax-main
flash_attention_jax/utils.py
import math import jax from functools import partial from jax import nn from jax import custom_vjp from jax import numpy as jnp, lax, jit from jax.numpy import einsum from einops import rearrange # constants EPSILON = 1e-10 MASK_VALUE = -1e10 Q_CHUNK_SIZE = 1024 K_CHUNK_SIZE = 1024 # flash attention def _query_ch...
flash-attention-jax-main
flash_attention_jax/flash_attention.py
Shuurai-main
example.py
Shuurai-main
shuurai/__init__.py
import torch from kosmos.model import Kosmos2 #usage img = torch.randn(1, 3, 256, 256) text = torch.randint(0, 20000, (1, 4096)) model = Kosmos2() output = model(img, text)
Kosmos-2-main
example.py
from kosmos.model import Kosmos2, Kosmos2Tokenizer
Kosmos-2-main
kosmos/__init__.py
import logging import torch from transformers import AutoTokenizer, CLIPProcessor from kosmos.transformer import Decoder, Transformer, ViTransformerWrapper, Encoder logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') # Implement classes with type hints and error handling cla...
Kosmos-2-main
kosmos/model.py
from functools import partial from typing import Optional import torch from torch import nn, einsum, Tensor import torch.nn.functional as F from collections import namedtuple from functools import wraps from packaging import version from dataclasses import dataclass from einops import rearrange # constants Efficie...
Kosmos-2-main
kosmos/attend.py
import math from dataclasses import dataclass from functools import partial, wraps from inspect import isfunction # constants from math import ceil from random import random from typing import Callable, List, Optional import torch import torch.nn.functional as F from einops import pack, rearrange, reduce, repeat, unp...
Kosmos-2-main
kosmos/transformer.py
import torch from alpha_dev.model import AlphaDev model = AlphaDev().cuda() x = torch.randint(0, 256, (1, 1024)).cuda() model(x) # (1, 1024, 20000)
AlphaDev-main
example.py
import collections import functools import math from typing import Any, Callable, Dict, NamedTuple, Optional, Sequence import chex import haiku as hk import jax import jax.lax import jax.numpy as jnp import ml_collections import numpy import optax ############################ ###### 1. Environment ###### class Ta...
AlphaDev-main
alpha_dev/pseudocode.py
from alpha_dev.model import AlphaDev
AlphaDev-main
alpha_dev/__init__.py
from torch.nn import Module from alpha_dev.transformer import AutoregressiveWrapper, Decoder, Transformer class AlphaDev(Module): """ AlphaDev is a transformer-based model architecture. It initializes with a Transformer and AutoregressiveWrapper with default or user-specified parameters. Initialize ...
AlphaDev-main
alpha_dev/model.py
from functools import partial from typing import Optional import torch from torch import nn, einsum, Tensor import torch.nn.functional as F from collections import namedtuple from functools import wraps from packaging import version from dataclasses import dataclass from einops import rearrange # constants Efficie...
AlphaDev-main
alpha_dev/attend.py
import math from dataclasses import dataclass from functools import partial, wraps from inspect import isfunction # constants from math import ceil from random import random from typing import Callable, List, Optional import torch import torch.nn.functional as F from einops import pack, rearrange, reduce, repeat, unp...
AlphaDev-main
alpha_dev/transformer.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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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 """ import os import sys from omegaconf import OmegaConf from lavis.common.registry import registry ...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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....
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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 ...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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 ...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/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...
3D-LLM-main
3DLLM_BLIP2-base/lavis/datasets/builders/classification_builder.py
import json from typing import Iterable from torch.utils.data import Dataset, ConcatDataset from torch.utils.data.dataloader import default_collate class BaseDataset(Dataset): def __init__(self, vis_processor=None, text_processor=None, vis_root=None, ann_paths=[]): self.vis_root = vis_root self....
3D-LLM-main
3DLLM_BLIP2-base/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 time import random import torch from lavis.datasets.data_utils import move_to_cuda from tor...
3D-LLM-main
3DLLM_BLIP2-base/lavis/datasets/datasets/dataloader_utils.py
import torch from lavis.datasets.datasets.base_dataset import BaseDataset class VQADataset(BaseDataset): def __init__(self, vis_processor, text_processor, vis_root, ann_paths): super().__init__(vis_processor, text_processor, vis_root, ann_paths) def collater(self, samples): pc_list, points_l...
3D-LLM-main
3DLLM_BLIP2-base/lavis/datasets/datasets/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 import json import torch import numpy as np from PIL import Image from PIL import Image...
3D-LLM-main
3DLLM_BLIP2-base/lavis/datasets/datasets/threedvqa_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 Based on huggingface code base https://github.com/huggingface/transformers/blob/v4.15.0/src/transfo...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/med.py
from collections import OrderedDict from itertools import repeat import collections.abc import math import torch import torch.nn.functional as F from torch import nn from fairscale.nn.checkpoint.checkpoint_activations import checkpoint_wrapper from lavis.models.eva_vit import convert_weights_to_fp16 from lavis.commo...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/clip_vit.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 # -------------------------...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import logging import torch from omegaconf import OmegaConf from lavis.common.registry import regi...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 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 lavis.common....
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/base_model.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 Based on timm code base https://github.com/rwightman/pytorch-image-models/tree/master/timm """ imp...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/vit.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 torch import torch.nn.functional as F from lavis.common.registry import registry from lavis...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/blip2_image_text_matching.py
import logging import torch import torch.nn as nn from torch.cuda.amp import autocast as autocast from transformers import T5TokenizerFast from lavis.common.registry import registry from lavis.models.blip2_models.blip2 import Blip2Base, disabled_train from lavis.models.blip2_models.modeling_t5 import T5Config, T5ForC...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/blip2_t5.py
""" Copyright (c) 2023, 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 torch import torch.distributed as dist import torch.nn as nn from torch.cuda...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/blip2_qformer.py
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/__init__.py
""" Copyright (c) 2023, 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 torch from torch.cuda.amp import autocast as autocast import torch.nn as nn ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/blip2_opt.py
# Copyright 2018 Mesh TensorFlow authors, T5 Authors and HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/modeling_t5.py
# coding=utf-8 # Copyright 2022 The Fairseq Authors and The HuggingFace Inc. 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 at # # http://www.apache.org/licenses/...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_models/modeling_opt.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...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_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 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 torch.n...
3D-LLM-main
3DLLM_BLIP2-base/lavis/models/blip2_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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import warnings import torch def _is_tensor_video_clip(clip): if not torch.is_tensor(clip):...
3D-LLM-main
3DLLM_BLIP2-base/lavis/processors/functional_video.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 re from lavis.common.registry import registry from lavis.processors.base_processor import ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from lavis.processors.base_processor import BaseProcessor from lavis.processors.blip_processors i...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from omegaconf import OmegaConf class BaseProcessor: def __init__(self): self.transf...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 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): return ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/processors/randaugment.py
#!/usr/bin/env python3 """ 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 numbers import random from torchvision.transforms import ( Ran...
3D-LLM-main
3DLLM_BLIP2-base/lavis/processors/transforms_video.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 from lavis.common.registry import registry @registry.register_lr_scheduler("linear_...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 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 lavis.com...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ class Registry: mapping = { "builder_name_mapping": {}, "task_name_mapping": ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/registry.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 datetime import logging import time from collections import defaultdict, deque import torc...
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/logger.py
import os import sys from easydict import EasyDict CONF = EasyDict() # path CONF.PATH = EasyDict() CONF.PATH.BASE = "." # TODO: change this CONF.PATH.DATA = os.path.join(CONF.PATH.BASE, "data") CONF.PATH.SCANNET = os.path.join(CONF.PATH.DATA, "scannet") CONF.PATH.LIB = os.path.join(CONF.PATH.BASE, "lib") CONF.PATH....
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/config_scanqa.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 io import json import logging import os import pickle import re import shutil import urllib...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 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 import t...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ __author__ = "aagrawal"
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/vqa_tools/__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 """ # coding=utf-8 __author__ = "aagrawal" # This code is based on the code written by Tsung-Yi Lin ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/vqa_tools/vqa_eval.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 """ __author__ = "aagrawal" __version__ = "0.9" # Interface for accessing the VQA dataset. # This co...
3D-LLM-main
3DLLM_BLIP2-base/lavis/common/vqa_tools/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 lavis.runners.runner_base import RunnerBase from lavis.runners.runner_iter import RunnerIter ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/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 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 import ...
3D-LLM-main
3DLLM_BLIP2-base/lavis/runners/runner_base.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 datetime import logging import os import time import torch import torch.distributed as dis...
3D-LLM-main
3DLLM_BLIP2-base/lavis/runners/runner_iter.py
# Copyright (c) Facebook, Inc. and its affiliates. # Copied from: https://github.com/facebookresearch/detectron2/blob/master/demo/predictor.py import atexit import bisect import multiprocessing as mp from collections import deque import cv2 import torch from detectron2.data import MetadataCatalog from detectron2.engi...
3D-LLM-main
three_steps_3d_feature/first_step/predictor.py