python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
""" 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 copy import deepcopy import torch import torch.nn.functional as F from lavis.common.registry...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_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 dataclasses import dataclass from typing import Optional import torch from transformers.mode...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_outputs.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 lavis.common.dist_utils as dist_utils...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_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 warnings import torch import torch.nn.functional as F from lavis.common.registry import re...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_feature_extractor.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 from copy import deepcopy import torch import torch.nn.functional as F f...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_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 copy import deepcopy import torch import torch.nn.functional as F from lavis.common.registry...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_nlvr.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 from copy import deepcopy import torch import torch.nn.functional as F from lavis...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_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 """ from copy import deepcopy import numpy as np import torch import torch.nn.functional as F from la...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/albef_models/albef_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 torch import torch.nn as nn from lavis.common.registry import registry from lavis.models.ba...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/gpt_models/gpt_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 torch
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/img2prompt_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 random import spacy import torch import torch.nn.functional as F from transformers import ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/img2prompt_models/img2prompt_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 copy import deepcopy import torch import torch.nn.functional as F from lavis.common.registry...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_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 torch import torch.nn.functional as F from lavis.common.registry import registry from lavis...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_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 from typing import List from torch import nn def tie_encoder_decoder_weights( ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_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 torch import torch.nn.functional as F from lavis.common.registry import registry from lavis...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_image_text_matching.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 from lavis.common.dist_utils import download_cached_file fr...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip.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 typing import Tuple import torch import torch.utils.checkpoint from torch import...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/nlvr_encoder.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 from lavis.common.registry import registry from lavis.models.blip_models.blip import...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_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 warnings import torch import torch.nn.functional as F from lavis.common.registry import re...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_feature_extractor.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 copy import deepcopy import torch import torch.nn.functional as F from lavis.common.registry...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_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 dataclasses import dataclass from typing import Optional import torch from transformers.mode...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_outputs.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 torch import torch.nn.functional as F from lavis.common.dist_utils import downlo...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_nlvr.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 copy import deepcopy import torch import torch.nn.functional as F from lavis.common.registry...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/blip_models/blip_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 Based on https://github.com/facebookresearch/TimeSformer """ # Copyright 2020 Ross Wightman # Conv2d...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/conv2d_same.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 """ """ Linear layer (alternate definition) """ import torch import torch.nn.functional as F from torc...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/linear.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 https://github.com/facebookresearch/TimeSformer """
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/__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 Based on https://github.com/facebookresearch/TimeSformer """ # Copyright 2020 Ross Wightman from co...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/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 Based on https://github.com/facebookresearch/TimeSformer """ # Copyright (c) Facebook, Inc. and its ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/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 Based on https://github.com/facebookresearch/TimeSformer """ # Copyright 2020 Ross Wightman # Variou...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/vit_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 Based on https://github.com/facebookresearch/TimeSformer """ # Copyright (c) Facebook, Inc. and its ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/timesformer/helpers.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
three_steps_3d_feature/second_step/lavis/models/blip2_models/blip2_image_text_matching.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.nn as nn from torch.cuda.amp import autocast as autocast ...
3D-LLM-main
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/lavis/models/blip2_models/blip2_qformer.py
3D-LLM-main
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/lavis/models/blip2_models/blip2_opt.py
# coding=utf-8 # 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...
3D-LLM-main
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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 logging import os import time import datetime import torch import torch.nn as nn import tor...
3D-LLM-main
three_steps_3d_feature/second_step/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 Based on https://github.com/mlfoundations/open_clip """ from dataclasses import dataclass from typi...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/clip_outputs.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 https://github.com/mlfoundations/open_clip """ import hashlib import os import urllib impor...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/pretrained.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 https://github.com/mlfoundations/open_clip """ """ OpenAI pretrained model functions Adapte...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_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 Based on https://github.com/mlfoundations/open_clip """ """ CLIP Model Adapted from https://github.c...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/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 https://github.com/mlfoundations/open_clip """ """ CLIP tokenizer Copied from https://githu...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/tokenizer.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 import torch.distributed.nn from torch import distributed as dist, nn ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/loss.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 https://github.com/mlfoundations/open_clip """ from torch import nn as nn from torchvision....
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/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 Based on https://github.com/mlfoundations/open_clip """ from typing import Optional, Sequence, Tuple...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/transform.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 https://github.com/mlfoundations/open_clip """ """ timm model adapter Wraps timm (https://g...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/clip_models/timm_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 """ from dataclasses import dataclass from typing import Optional import torch from transformers.mode...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/alpro_models/alpro_outputs.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.nn.functional as F from lavis.common.dist_util...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/alpro_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 datetime import logging import time import lavis.common.dist_utils as dist_utils import nu...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/alpro_models/alpro_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 warnings import warn import torch import torch.nn.functional as F from lavis.common.config i...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/models/alpro_models/alpro_qa.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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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.common.registry import registry from lavis.processors.blip_processors import BlipImageB...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/processors/clip_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 """ import torch from lavis.common.registry import registry from lavis.datasets.data_utils import load...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/processors/alpro_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.alpro_processors ...
3D-LLM-main
three_steps_3d_feature/second_step/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 """ import re from lavis.common.registry import registry from lavis.processors.base_processor import ...
3D-LLM-main
three_steps_3d_feature/second_step/lavis/processors/gpt_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 omegaconf import OmegaConf class BaseProcessor: def __init__(self): self.transf...
3D-LLM-main
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/lavis/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 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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/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
three_steps_3d_feature/second_step/lavis/runners/runner_iter.py
import numpy as np from argparse import Namespace import quaternion from habitat.utils.geometry_utils import quaternion_to_list from scipy.spatial.transform import Rotation as R class Pos2Map: def __init__(self, x, y, heading) -> None: self.x = x self.y = y self.heading = heading class P...
3D-LLM-main
three_steps_3d_feature/third_step/tools.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os import json import argparse import numpy as np import copy import cv2 from habitat.utils.geometry_utils import q...
3D-LLM-main
three_steps_3d_feature/third_step/direct_3d.py
#liquid attention import torch import torch.nn as nn from torch.nn import TransformerEncoder, TransformerEncoderLayer import torch.nn.functional as F import math class LeakyIntegrator(nn.Module): def __init__(self, tau=0.5): super(LeakyIntegrator, self).__init__() self.tau = tau def forward(s...
Liquid-main
LeakyAttention.py
# Adapted from https://github.com/NVIDIA/apex/blob/master/setup.py import sys import warnings import os from pathlib import Path from setuptools import setup, find_packages import subprocess import torch from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME with open("README.m...
FLASHATTENION-LION-OPTIMIZE-main
setup.py
# Adapted from https://github.com/NVIDIA/apex/blob/master/setup.py import torch from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME from setuptools import setup, find_packages import subprocess import sys import warnings import os # ninja build does not work unless include_dir...
FLASHATTENION-LION-OPTIMIZE-main
csrc/ft_attention/setup.py
# Copied from https://github.com/NVIDIA/apex/tree/master/csrc/megatron # We add the case where seqlen = 4k and seqlen = 8k import os import subprocess import torch from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME def get_cuda_bare_metal_version(cuda_dir): ...
FLASHATTENION-LION-OPTIMIZE-main
csrc/fused_softmax/setup.py
# Adapted from https://github.com/NVIDIA/apex/blob/master/setup.py import torch from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME from setuptools import setup, find_packages import subprocess import sys import warnings import os # ninja build does not work unless include_dir...
FLASHATTENION-LION-OPTIMIZE-main
csrc/xentropy/setup.py
# Adapted from https://github.com/NVIDIA/apex/blob/master/setup.py import torch from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME from setuptools import setup, find_packages import subprocess import sys import warnings import os # ninja build does not work unless include_dir...
FLASHATTENION-LION-OPTIMIZE-main
csrc/layer_norm/setup.py
# Adapted from https://github.com/NVIDIA/apex/blob/master/setup.py import torch from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension, CUDA_HOME from setuptools import setup, find_packages import subprocess import sys import warnings import os # ninja build does not work unless include_dir...
FLASHATTENION-LION-OPTIMIZE-main
csrc/rotary/setup.py
import os import subprocess import torch from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME def get_cuda_bare_metal_version(cuda_dir): raw_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"], universal_newlines=True) output = raw_output.spl...
FLASHATTENION-LION-OPTIMIZE-main
csrc/fused_dense_lib/setup.py
from typing import Callable import dotenv import hydra from omegaconf import OmegaConf, DictConfig # load environment variables from `.env` file if it exists # recursively searches for `.env` in all folders starting from work dir dotenv.load_dotenv(override=True) OmegaConf.register_new_resolver('eval', eval) OmegaCo...
FLASHATTENION-LION-OPTIMIZE-main
training/run.py
import os from pathlib import Path current_dir = Path(__file__).parent.absolute() import pytest import torch import dotenv from src.datamodules.language_modeling_hf import LMDataModule # load environment variables from `.env` file if it exists # recursively searches for `.env` in all folders starting from work di...
FLASHATTENION-LION-OPTIMIZE-main
training/tests/datamodules/test_language_modeling_hf.py
from typing import List, Optional, Sequence from pathlib import Path import hydra from omegaconf import OmegaConf, DictConfig from pytorch_lightning import ( Callback, LightningDataModule, LightningModule, Trainer, seed_everything, ) from pytorch_lightning.loggers import LightningLoggerBase from s...
FLASHATTENION-LION-OPTIMIZE-main
training/src/train.py
from typing import List, Optional from pathlib import Path import torch import hydra from omegaconf import OmegaConf, DictConfig from pytorch_lightning import ( Callback, LightningDataModule, LightningModule, Trainer, seed_everything, ) from pytorch_lightning.loggers import LightningLoggerBase fr...
FLASHATTENION-LION-OPTIMIZE-main
training/src/eval.py
from typing import Any, Dict, Optional import torch from torch import Tensor from torchmetrics import Metric class NumTokens(Metric): """Keep track of how many tokens we've seen. """ # TODO: how do we prevent the reset between the epochs? The reset happens on the 1st batch # of the next epoch. #...
FLASHATTENION-LION-OPTIMIZE-main
training/src/metrics/num_tokens.py
# Inspired by https://github.com/NVIDIA/NeMo/blob/main/nemo/collections/common/metrics/perplexity.py # But we compute the perplexity correctly: exp(average(nll)), not average(exp(nll)) # Also adapted from https://github.com/Lightning-AI/metrics/blob/master/src/torchmetrics/text/perplexity.py # But we pass in the loss t...
FLASHATTENION-LION-OPTIMIZE-main
training/src/metrics/perplexity.py
import torch from torch import Tensor from torchmetrics import Metric, Accuracy class AccuracyMine(Accuracy): """Wrap torchmetrics.Accuracy to take argmax of y in case of Mixup. """ def update(self, preds: Tensor, target: Tensor) -> None: # type: ignore super().update(preds, target.argmax(dim=-1...
FLASHATTENION-LION-OPTIMIZE-main
training/src/metrics/accuracy.py
from typing import Any, List import inspect import torch import hydra from pytorch_lightning import LightningModule, LightningDataModule from torchmetrics import MetricCollection from einops import rearrange from omegaconf import OmegaConf from src.utils.utils import get_logger from src.optim.param_grouping import ...
FLASHATTENION-LION-OPTIMIZE-main
training/src/tasks/seq.py
# Adapted from https://pytorch.org/docs/stable/_modules/torch/distributed/algorithms/ddp_comm_hooks/default_hooks.html # We divide by world_size first before converting to fp16, so it's safer. from typing import Any, Callable import torch import torch.distributed as dist def fp16_compress_hook( process_group: di...
FLASHATTENION-LION-OPTIMIZE-main
training/src/distributed/ddp_comm_hooks.py
# Adapted from https://github.com/rwightman/pytorch-image-models/blob/master/benchmark.py from typing import Any, List, Sequence import torch from pytorch_lightning import Callback, Trainer, LightningModule from pytorch_lightning.utilities import rank_zero_only from pytorch_lightning.utilities.parsing import Attribut...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/flop_count.py
import subprocess from pathlib import Path from typing import List import matplotlib.pyplot as plt import seaborn as sn import torch import wandb from pytorch_lightning import Callback, Trainer from pytorch_lightning.loggers import LoggerCollection, WandbLogger from pytorch_lightning.utilities import rank_zero_only fr...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/wandb_callbacks.py
import torch from pytorch_lightning import Callback, Trainer, LightningModule import logging log = logging.getLogger(__name__) # We want a logger for each process, not just the rank 0 def l2_promote(): import ctypes _libcudart = ctypes.CDLL('libcudart.so') # Set device limit on the current device ...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/gpu_affinity.py
# Inspired by https://github.com/Lightning-AI/lightning/blob/master/src/pytorch_lightning/utilities/grads.py # However, they compute grad at every iteration (I think), and the .item() calls incur a lot of overhead # (6-7% slow down on GPT-2 small). Instead we only compute for iterations where we need to log, and don't ...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/norm_monitor.py
import pytorch_lightning as pl from pytorch_lightning import Callback from pytorch_lightning.utilities import rank_zero_only import torch from torch.autograd import grad class CausalityMonitor(Callback): r"""Monitor causality of a model by tracking gradient leakage forward in time. In a fully causal model, ...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/causality_monitor.py
# Inspired by https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/callbacks/stochastic_weight_avg.py # https://github.com/PyTorchLightning/Lightning-Bolts/blob/master/pl_bolts/callbacks/byol_updates.py # https://forums.pytorchlightning.ai/t/adopting-exponential-moving-average-ema-for-pl-...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/ema.py
# Adapted from https://pytorch-lightning.readthedocs.io/en/latest/_modules/pytorch_lightning/callbacks/gpu_stats_monitor.html#GPUStatsMonitor # We only need the speed monitoring, not the GPU monitoring import time from typing import Any from pytorch_lightning import Callback, Trainer from pytorch_lightning.utilities i...
FLASHATTENION-LION-OPTIMIZE-main
training/src/callbacks/speed_monitor.py