ccloud0525 commited on
Commit ·
b11fb36
1
Parent(s): 7909ec4
feat: "first commit"
Browse files- modality_connector.py +0 -10
- ts_generation_mixin.py +0 -4
- util_functions.py +0 -9
modality_connector.py
CHANGED
|
@@ -8,7 +8,6 @@ from torchvision.transforms import Resize
|
|
| 8 |
from transformers import ViTImageProcessor, ViTModel, BertModel, ViTConfig, BertConfig
|
| 9 |
|
| 10 |
from .configuration_aurora import AuroraConfig
|
| 11 |
-
from .util_functions import resolve_subdir
|
| 12 |
|
| 13 |
|
| 14 |
class VisionEncoder(nn.Module):
|
|
@@ -22,9 +21,6 @@ class VisionEncoder(nn.Module):
|
|
| 22 |
|
| 23 |
vit_config_file = os.path.join(self.config_path, "config.json")
|
| 24 |
|
| 25 |
-
if not os.path.exists(vit_config_file):
|
| 26 |
-
resolve_subdir(repo_id="DecisionIntelligence/Aurora", subdir="vit_config", file_name="config.json")
|
| 27 |
-
|
| 28 |
self.model = ViTModel(ViTConfig.from_json_file(vit_config_file))
|
| 29 |
|
| 30 |
for param in self.model.parameters():
|
|
@@ -84,9 +80,6 @@ class UnifiedImageProcessor(nn.Module):
|
|
| 84 |
self.config_path = vit_config_path
|
| 85 |
|
| 86 |
processor_file = os.path.join(self.config_path, "preprocessor_config.json")
|
| 87 |
-
if not os.path.exists(processor_file):
|
| 88 |
-
resolve_subdir(repo_id="DecisionIntelligence/Aurora", subdir="vit_config", file_name="preprocessor_config.json")
|
| 89 |
-
|
| 90 |
self.vit_processor = ViTImageProcessor.from_json_file(processor_file)
|
| 91 |
|
| 92 |
self.target_size = self.vit_processor.size["height"]
|
|
@@ -145,9 +138,6 @@ class TextEncoder(nn.Module):
|
|
| 145 |
|
| 146 |
bert_config_file = os.path.join(self.config_path, "config.json")
|
| 147 |
|
| 148 |
-
if not os.path.exists(bert_config_file):
|
| 149 |
-
resolve_subdir(repo_id="DecisionIntelligence/Aurora", subdir="bert_config", file_name="config.json")
|
| 150 |
-
|
| 151 |
self.model = BertModel(BertConfig.from_json_file(bert_config_file))
|
| 152 |
|
| 153 |
for param in self.model.parameters():
|
|
|
|
| 8 |
from transformers import ViTImageProcessor, ViTModel, BertModel, ViTConfig, BertConfig
|
| 9 |
|
| 10 |
from .configuration_aurora import AuroraConfig
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
class VisionEncoder(nn.Module):
|
|
|
|
| 21 |
|
| 22 |
vit_config_file = os.path.join(self.config_path, "config.json")
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
self.model = ViTModel(ViTConfig.from_json_file(vit_config_file))
|
| 25 |
|
| 26 |
for param in self.model.parameters():
|
|
|
|
| 80 |
self.config_path = vit_config_path
|
| 81 |
|
| 82 |
processor_file = os.path.join(self.config_path, "preprocessor_config.json")
|
|
|
|
|
|
|
|
|
|
| 83 |
self.vit_processor = ViTImageProcessor.from_json_file(processor_file)
|
| 84 |
|
| 85 |
self.target_size = self.vit_processor.size["height"]
|
|
|
|
| 138 |
|
| 139 |
bert_config_file = os.path.join(self.config_path, "config.json")
|
| 140 |
|
|
|
|
|
|
|
|
|
|
| 141 |
self.model = BertModel(BertConfig.from_json_file(bert_config_file))
|
| 142 |
|
| 143 |
for param in self.model.parameters():
|
ts_generation_mixin.py
CHANGED
|
@@ -6,7 +6,6 @@ from transformers import BertTokenizer
|
|
| 6 |
from transformers import GenerationMixin, LogitsProcessorList, StoppingCriteriaList
|
| 7 |
from transformers.generation.utils import GenerationConfig, GenerateOutput
|
| 8 |
from transformers.utils import ModelOutput
|
| 9 |
-
from .util_functions import resolve_subdir
|
| 10 |
|
| 11 |
class TSGenerationMixin(GenerationMixin):
|
| 12 |
_tokenizer = None
|
|
@@ -16,9 +15,6 @@ class TSGenerationMixin(GenerationMixin):
|
|
| 16 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 17 |
tokenizer_dir = os.path.join(base_dir, "bert_config")
|
| 18 |
|
| 19 |
-
if not os.path.isdir(tokenizer_dir):
|
| 20 |
-
resolve_subdir(repo_id="DecisionIntelligence/Aurora", subdir="bert_config", file_name="config.json")
|
| 21 |
-
|
| 22 |
self._tokenizer = BertTokenizer.from_pretrained(
|
| 23 |
tokenizer_dir,
|
| 24 |
local_files_only=True
|
|
|
|
| 6 |
from transformers import GenerationMixin, LogitsProcessorList, StoppingCriteriaList
|
| 7 |
from transformers.generation.utils import GenerationConfig, GenerateOutput
|
| 8 |
from transformers.utils import ModelOutput
|
|
|
|
| 9 |
|
| 10 |
class TSGenerationMixin(GenerationMixin):
|
| 11 |
_tokenizer = None
|
|
|
|
| 15 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 16 |
tokenizer_dir = os.path.join(base_dir, "bert_config")
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
self._tokenizer = BertTokenizer.from_pretrained(
|
| 19 |
tokenizer_dir,
|
| 20 |
local_files_only=True
|
util_functions.py
CHANGED
|
@@ -1,18 +1,9 @@
|
|
| 1 |
-
import os
|
| 2 |
from typing import Tuple
|
| 3 |
|
| 4 |
import math
|
| 5 |
import torch
|
| 6 |
import torch.nn as nn
|
| 7 |
import torch.nn.functional as F
|
| 8 |
-
from huggingface_hub import hf_hub_download
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def resolve_subdir(repo_id: str, subdir: str, file_name: str) -> str:
|
| 12 |
-
hf_hub_download(
|
| 13 |
-
repo_id=repo_id,
|
| 14 |
-
filename=f"{subdir}/{file_name}"
|
| 15 |
-
)
|
| 16 |
|
| 17 |
|
| 18 |
def resize(x_tensor, new_shape):
|
|
|
|
|
|
|
| 1 |
from typing import Tuple
|
| 2 |
|
| 3 |
import math
|
| 4 |
import torch
|
| 5 |
import torch.nn as nn
|
| 6 |
import torch.nn.functional as F
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def resize(x_tensor, new_shape):
|