python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
from math import ceil import torch import torch.nn.functional as F from einops import pack, rearrange, unpack from torch import nn def exists(val): return val is not None def eval_decorator(fn): def inner(self, *args, **kwargs): was_training = self.training self.eval() out = fn(self,...
SayCan-main
saycan/autoregressive.py
from saycan.model import SayCan
SayCan-main
saycan/__init__.py
from torch.nn import Module from transformers import AutoTokenizer from saycan.transformer import ( Decoder, Transformer, ViTransformerWrapper, Encoder ) from saycan.autoregressive import AutoregressiveWrapper class SayCanTokenizer: def __init__(self): self.tokenizer= AutoTokenizer.from_...
SayCan-main
saycan/model.py
from collections import namedtuple from dataclasses import dataclass from functools import partial, wraps from typing import Optional import torch import torch.nn.functional as F from einops import rearrange, repeat from packaging import version from torch import Tensor, einsum, nn # constants EfficientAttentionConf...
SayCan-main
saycan/attend.py
import math from dataclasses import dataclass from functools import partial, wraps from inspect import isfunction from random import random from typing import Callable, List, Optional import torch import torch.nn.functional as F from einops import rearrange, reduce, repeat from torch import Tensor, einsum, nn from sa...
SayCan-main
saycan/transformer.py
import torch from neox.model import NeoCortex #usage img = torch.randn(1, 3, 256, 256) caption = torch.randint(0, 20000, (1, 1024)) model = NeoCortex() output = model(img, caption) print(output.shape) # (1, 1024, 20000)
NeoCortex-main
example.py
from neox.model import NeoCortex
NeoCortex-main
neox/__init__.py
import torch import torch.nn as nn from transformers import AutoTokenizer, CLIPProcessor from neox.transformer import ( Decoder, Encoder, Transformer, ViTransformerWrapper, ) class NeoCortexTokenizer: def __init__(self): try: self.processor = CLIPProcessor.from_pretrained("l...
NeoCortex-main
neox/model.py
from collections import namedtuple from dataclasses import dataclass from functools import partial, wraps from typing import Optional import torch import torch.nn.functional as F from einops import rearrange from packaging import version from torch import Tensor, einsum, nn # constants EfficientAttentionConfig = nam...
NeoCortex-main
neox/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...
NeoCortex-main
neox/transformer.py
from robocat.model import ImageDataGenerator model = ImageDataGenerator() img = model.generate(prompt="A robot looking at a soda can in first perrson") print(img)
RoboCAT-master
image_example.py
from setuptools import setup, find_packages setup( name = 'robocat', packages = find_packages(exclude=[]), version = '0.0.4', license='MIT', description = 'Robo CAT- Pytorch', author = 'Kye Gomez', author_email = 'kye@apac.ai', long_description_content_type = 'text/markdown', url = 'https://github.co...
RoboCAT-master
setup.py
import torch from robocat.model import RoboCat model = RoboCat() video = torch.randn(2, 3, 6, 224, 224) instructions = [ 'bring me that apple sitting on the table', 'please pass the butter' ] result = model.forward(video, instructions) print(result)
RoboCAT-master
example.py
from robocat.model import VideoDataGenerator model = VideoDataGenerator() model.generate(prompt="4 legged robot walking to counter")
RoboCAT-master
video_example.py
from robocat.model import ImageDataGenerator, VideoDataGenerator, RoboCat
RoboCAT-master
robocat/__init__.py
import torch import torch.nn.functional as F from torch import nn, einsum from typing import List, Optional, Callable, Tuple from beartype import beartype from einops import pack, unpack, repeat, reduce, rearrange from einops.layers.torch import Rearrange, Reduce from functools import partial from classifier_free_g...
RoboCAT-master
robocat/model.py
import math import multiprocessing import os from datetime import timedelta from functools import partial from itertools import chain import torch from torch.distributed.fsdp import ( FullyShardedDataParallel, MixedPrecision, BackwardPrefetch, ShardingStrategy, ) from accelerate import Accelerator from...
RoboCAT-master
robocat/train.py
RoboCAT-master
robocat/utils/__init__.py
import torch # This is the unfused version of StableAdamW. It is slower than the fused version (coming). class StableAdamWUnfused(torch.optim.Optimizer): def __init__( self, params, lr=0.002, weight_decay=0.2, betas=(0.9, 0.99), eps=1e-8, clip_thresh=1.0, ...
RoboCAT-master
robocat/utils/stabe_adam.py
from torch.utils.data import DataLoader from transformers import AdamW from datasets import load_dataset from robocat import robo_cat import torch # Step 1: Load the dataset dataset = load_dataset("your_dataset_name") # Step 2: Preprocess the dataset def preprocess(example): video = torch.tensor(example["video"]...
RoboCAT-master
robocat/utils/training.py
Model-Infra-Template-main
example.py
Model-Infra-Template-main
model/__init__.py
class ModelAPI: def __init__(self): pass def forward(self): pass
Model-Infra-Template-main
model/app.py
Model-Infra-Template-main
model/subfolder/__init__.py
Model-Infra-Template-main
model/subfolder/main.py
""" Apply the delta weights on top of a base model. Adapted from: https://github.com/lm-sys/FastChat/blob/main/fastchat/model/apply_delta.py. """ import argparse import torch from tqdm import tqdm from transformers import AutoTokenizer, AutoModelForCausalLM def apply_delta(base_model_path, target_model_path, delta_p...
MovieChat-main
apply_delta.py
""" Adapted from: https://github.com/Vision-CAIR/MiniGPT-4/blob/main/demo.py """ import argparse import os import random import numpy as np import torch import torch.backends.cudnn as cudnn from MovieChat.common.config import Config from MovieChat.common.dist_utils import get_rank from MovieChat.common.registry impor...
MovieChat-main
inference.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import os import sys from omegaconf import OmegaConf from MovieChat.common.registry import...
MovieChat-main
MovieChat/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import logging import os import torch import torch.distributed as dist from MovieChat.commo...
MovieChat-main
MovieChat/tasks/base_task.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.common.registry import registry from MovieChat.tasks.base_task import BaseTas...
MovieChat-main
MovieChat/tasks/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.common.registry import registry from MovieChat.tasks.base_task import BaseTas...
MovieChat-main
MovieChat/tasks/video_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_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.common.registry import registry from MovieChat.tasks.base_task import BaseTas...
MovieChat-main
MovieChat/tasks/image_text_pretrain.py
MovieChat-main
MovieChat/datasets/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import gzip import logging import os import random as rnd import tarfile import zipfile impo...
MovieChat-main
MovieChat/datasets/data_utils.py
""" This file is from Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import logging import os import shutil import warnings from omegaconf im...
MovieChat-main
MovieChat/datasets/builders/base_dataset_builder.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.datasets.builders.base_dataset_builder import load_dataset_config from MovieC...
MovieChat-main
MovieChat/datasets/builders/__init__.py
import os import logging import warnings from MovieChat.common.registry import registry from MovieChat.datasets.builders.base_dataset_builder import BaseDatasetBuilder from MovieChat.datasets.datasets.laion_dataset import LaionDataset from MovieChat.datasets.datasets.llava_instruct_dataset import Instruct_Dataset from...
MovieChat-main
MovieChat/datasets/builders/instruct_builder.py
import os import logging import warnings from MovieChat.common.registry import registry from MovieChat.datasets.builders.base_dataset_builder import BaseDatasetBuilder from MovieChat.datasets.datasets.laion_dataset import LaionDataset from MovieChat.datasets.datasets.cc_sbu_dataset import CCSBUDataset, CCSBUAlignDatas...
MovieChat-main
MovieChat/datasets/builders/image_text_pair_builder.py
import os import logging import warnings from MovieChat.common.registry import registry from MovieChat.datasets.builders.base_dataset_builder import BaseDatasetBuilder from MovieChat.datasets.datasets.webvid_datasets import WebvidDataset @registry.register_builder("webvid") class WebvidBuilder(BaseDatasetBuilder): ...
MovieChat-main
MovieChat/datasets/builders/video_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_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import webdataset as wds from MovieChat.datasets.datasets.base_dataset import BaseDataset ...
MovieChat-main
MovieChat/datasets/datasets/laion_dataset.py
import os from MovieChat.datasets.datasets.base_dataset import BaseDataset from MovieChat.datasets.datasets.caption_datasets import CaptionDataset import pandas as pd import decord from decord import VideoReader import random import torch from torch.utils.data.dataloader import default_collate from PIL import Image fro...
MovieChat-main
MovieChat/datasets/datasets/video_instruct_dataset.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import json from typing import Iterable from torch.utils.data import Dataset, ConcatDataset...
MovieChat-main
MovieChat/datasets/datasets/base_dataset.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import time import random import torch from MovieChat.datasets.data_utils import move_to_cud...
MovieChat-main
MovieChat/datasets/datasets/dataloader_utils.py
import os from MovieChat.datasets.datasets.base_dataset import BaseDataset from MovieChat.datasets.datasets.caption_datasets import CaptionDataset import pandas as pd import decord from decord import VideoReader import random import torch from torch.utils.data.dataloader import default_collate from PIL import Image fro...
MovieChat-main
MovieChat/datasets/datasets/llava_instruct_dataset.py
MovieChat-main
MovieChat/datasets/datasets/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import os from MovieChat.datasets.datasets.base_dataset import BaseDataset from MovieChat.datasets...
MovieChat-main
MovieChat/datasets/datasets/webvid_datasets.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import os from collections import OrderedDict from MovieChat.datasets.datasets.base_dataset...
MovieChat-main
MovieChat/datasets/datasets/caption_datasets.py
import os from PIL import Image import webdataset as wds from MovieChat.datasets.datasets.base_dataset import BaseDataset from MovieChat.datasets.datasets.caption_datasets import CaptionDataset class CCSBUDataset(BaseDataset): def __init__(self, vis_processor, text_processor, location): super().__init__(v...
MovieChat-main
MovieChat/datasets/datasets/cc_sbu_dataset.py
import logging import random import torch from torch.cuda.amp import autocast as autocast import torch.nn as nn from MovieChat.common.registry import registry from MovieChat.models.blip2 import Blip2Base, disabled_train from MovieChat.models.modeling_llama import LlamaForCausalLM from transformers import LlamaTokeniz...
MovieChat-main
MovieChat/models/moviechat.py
""" Adapted from salesforce@LAVIS. Below is the original copyright: Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from dataclasses import data...
MovieChat-main
MovieChat/models/blip2_outputs.py
# Based on EVA, BEIT, timm and DeiT code bases # https://github.com/baaivision/EVA # https://github.com/rwightman/pytorch-image-models/tree/master/timm # https://github.com/microsoft/unilm/tree/master/beit # https://github.com/facebookresearch/deit/ # https://github.com/facebookresearch/dino # -------------------------...
MovieChat-main
MovieChat/models/eva_vit.py
""" Adapted from salesforce@LAVIS Vision-CAIR@MiniGPT-4. Below is the original copyright: Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import...
MovieChat-main
MovieChat/models/__init__.py
""" Adapted from salesforce@LAVIS. Below is the original copyright: Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import logging import os im...
MovieChat-main
MovieChat/models/base_model.py
#!/usr/bin/env python3 # Portions Copyright (c) Meta Platforms, Inc. and 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 gzip import html import io import math from functools import lru_cache from typing ...
MovieChat-main
MovieChat/models/multimodal_preprocessors.py
# This script is based on https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py """ PyTorch LLaMA model.""" import math from typing import List, Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss...
MovieChat-main
MovieChat/models/modeling_llama.py
# Based on ToMe, EVA, BEIT, timm and DeiT code bases # https://github.com/facebookresearch/ToMe # 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/...
MovieChat-main
MovieChat/models/eva_vit_with_tome.py
#!/usr/bin/env python3 # Portions Copyright (c) Meta Platforms, Inc. and 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 logging import math import torch import torch.nn as nn import torchaudio from PIL ...
MovieChat-main
MovieChat/models/process_video_data.py
""" Adapted from salesforce@LAVIS. Below is the original copyright: * 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 hug...
MovieChat-main
MovieChat/models/Qformer.py
#!/usr/bin/env python3 # Portions Copyright (c) Meta Platforms, Inc. and 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 einops import numpy as np import torch import torch.nn as nn class Normalize(nn....
MovieChat-main
MovieChat/models/helpers.py
""" Adapted from salesforce@LAVIS. Below is the original copyright: Copyright (c) 2023, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import contextlib import logg...
MovieChat-main
MovieChat/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):...
MovieChat-main
MovieChat/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_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import re from MovieChat.common.registry import registry from MovieChat.processors.base_pro...
MovieChat-main
MovieChat/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 """ import torch from MovieChat.common.registry import registry from decord import VideoReader import ...
MovieChat-main
MovieChat/processors/video_processor.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.processors.base_processor import BaseProcessor from MovieChat.processors.blip...
MovieChat-main
MovieChat/processors/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from omegaconf import OmegaConf class BaseProcessor: def __init__(self): self....
MovieChat-main
MovieChat/processors/base_processor.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import cv2 import numpy as np import torch ## aug functions def identity_func(img): r...
MovieChat-main
MovieChat/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...
MovieChat-main
MovieChat/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_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import math from MovieChat.common.registry import registry @registry.register_lr_schedule...
MovieChat-main
MovieChat/common/optims.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import logging import json from typing import Dict from omegaconf import OmegaConf from Mov...
MovieChat-main
MovieChat/common/config.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ class Registry: mapping = { "builder_name_mapping": {}, "task_name_mapp...
MovieChat-main
MovieChat/common/registry.py
MovieChat-main
MovieChat/common/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import datetime import logging import time from collections import defaultdict, deque impor...
MovieChat-main
MovieChat/common/logger.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import io import json import logging import os import pickle import re import shutil import ...
MovieChat-main
MovieChat/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...
MovieChat-main
MovieChat/common/gradcam.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import datetime import functools import os import torch import torch.distributed as dist im...
MovieChat-main
MovieChat/common/dist_utils.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ from MovieChat.runners.runner_base import RunnerBase __all__ = ["RunnerBase"]
MovieChat-main
MovieChat/runners/__init__.py
""" Copyright (c) 2022, salesforce.com, inc. All rights reserved. SPDX-License-Identifier: BSD-3-Clause For full license text, see the LICENSE_Lavis file in the repo root or https://opensource.org/licenses/BSD-3-Clause """ import datetime import json import logging import os import time from pathlib import Path i...
MovieChat-main
MovieChat/runners/runner_base.py
MovieChat-main
MovieChat/runners/test.py
MovieChat-main
MovieChat/conversation/__init__.py
""" Conversation prompt template of Video-LLaMA. Adapted from: https://github.com/Vision-CAIR/MiniGPT-4/blob/main/minigpt4/conversation/conversation.py """ import argparse import time from PIL import Image import sys sys.path.append('/mnt/workspace/videoGPT/Video-llama/') import os import torch from transformers impor...
MovieChat-main
MovieChat/conversation/conversation_video.py
""" Adapted from: https://github.com/Vision-CAIR/MiniGPT-4/blob/main/demo.py """ import argparse import os import random import numpy as np import torch import json import torch.backends.cudnn as cudnn from MovieChat.common.config import Config from MovieChat.common.dist_utils import get_rank from MovieChat.common.regi...
MovieChat-main
eval_code/run_inference_qa_msrvtt.py
""" Adapted from: https://github.com/Vision-CAIR/MiniGPT-4/blob/main/demo.py """ import argparse import os import random import numpy as np import torch import json import torch.backends.cudnn as cudnn from MovieChat.common.config import Config from MovieChat.common.dist_utils import get_rank from MovieChat.common.regi...
MovieChat-main
eval_code/run_inference_qa_msvd.py
""" Adapted from: https://github.com/mbzuai-oryx/Video-ChatGPT/blob/main/quantitative_evaluation/evaluate_activitynet_qa.py """ import openai import os import argparse import json import ast from multiprocessing.pool import Pool def parse_args(): parser = argparse.ArgumentParser(description="question-answer-genera...
MovieChat-main
eval_code/run_eval_qa.py
""" Adapted from: https://github.com/Vision-CAIR/MiniGPT-4/blob/main/demo.py """ import argparse import os import random import numpy as np import torch import json import torch.backends.cudnn as cudnn from MovieChat.common.config import Config from MovieChat.common.dist_utils import get_rank from MovieChat.common.regi...
MovieChat-main
eval_code/run_inference_qa_activitynet.py
import argparse import os import random import numpy as np import torch import torch.backends.cudnn as cudnn from MovieChat.common.config import Config from MovieChat.common.dist_utils import get_rank from MovieChat.common.registry import registry from MovieChat.conversation.conversation_video import Chat, Conversati...
MovieChat-main
Gradio_demo/app_gradio.py
MovieChat-main
src/examples/__init__.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: compress_sim_storage.py Description: Compresses a simulation for replay demos. """ import shutil import json from global_methods import * def compress(sim_code): sim_storage = f"../environment/frontend_server/storage/{sim_code}" compressed_storage = f"../en...
generative_agents-main
reverie/compress_sim_storage.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: global_methods.py Description: Contains functions used throughout my projects. """ import random import string import csv import time import datetime as dt import pathlib import os import sys import numpy import math import shutil, errno from os import listdir ...
generative_agents-main
reverie/global_methods.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: path_finder.py Description: Implements various path finding functions for generative agents. Some of the functions are defunct. """ import numpy as np def print_maze(maze): for row in maze: for item in row: print(item, end='') print() def path...
generative_agents-main
reverie/backend_server/path_finder.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: global_methods.py Description: Contains functions used throughout my projects. """ import random import string import csv import time import datetime as dt import pathlib import os import sys import numpy import math import shutil, errno from os import listdir ...
generative_agents-main
reverie/backend_server/global_methods.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: gpt_structure.py Description: Wrapper functions for calling OpenAI APIs. """ import json import random import openai import time from utils import * openai.api_key = openai_api_key def ChatGPT_request(prompt): """ Given a prompt and a dictionary of GPT pa...
generative_agents-main
reverie/backend_server/test.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: maze.py Description: Defines the Maze class, which represents the map of the simulated world in a 2-dimensional matrix. """ import json import numpy import datetime import pickle import time import math from global_methods import * from utils import * class Ma...
generative_agents-main
reverie/backend_server/maze.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: reverie.py Description: This is the main program for running generative agent simulations that defines the ReverieServer class. This class maintains and records all states related to the simulation. The primary mode of interaction for those running the simula...
generative_agents-main
reverie/backend_server/reverie.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: persona.py Description: Defines the Persona class that powers the agents in Reverie. Note (May 1, 2023) -- this is effectively GenerativeAgent class. Persona was the term we used internally back in 2022, taking from our Social Simulacra paper. """ import math ...
generative_agents-main
reverie/backend_server/persona/persona.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: plan.py Description: This defines the "Plan" module for generative agents. """ import datetime import math import random import sys import time sys.path.append('../../') from global_methods import * from persona.prompt_template.run_gpt_prompt import * from per...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/plan.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: execute.py Description: This defines the "Act" module for generative agents. """ import sys import random sys.path.append('../../') from global_methods import * from path_finder import * from utils import * def execute(persona, maze, personas, plan): """ ...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/execute.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: perceive.py Description: This defines the "Perceive" module for generative agents. """ import sys sys.path.append('../../') from operator import itemgetter from global_methods import * from persona.prompt_template.gpt_structure import * from persona.prompt_temp...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/perceive.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: retrieve.py Description: This defines the "Retrieve" module for generative agents. """ import sys sys.path.append('../../') from global_methods import * from persona.prompt_template.gpt_structure import * from numpy import dot from numpy.linalg import norm de...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/retrieve.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: converse.py Description: An extra cognitive module for generating conversations. """ import math import sys import datetime import random sys.path.append('../') from global_methods import * from persona.memory_structures.spatial_memory import * from persona.me...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/converse.py
""" Author: Joon Sung Park (joonspk@stanford.edu) File: reflect.py Description: This defines the "Reflect" module for generative agents. """ import sys sys.path.append('../../') import datetime import random from numpy import dot from numpy.linalg import norm from global_methods import * from persona.prompt_templa...
generative_agents-main
reverie/backend_server/persona/cognitive_modules/reflect.py