Vision-CAIR commited on
Commit
dc2b1a4
1 Parent(s): 26ca17a

Push model using huggingface_hub.

Browse files
Files changed (1) hide show
  1. mini_gpt4_llama_v2.py +7 -5
mini_gpt4_llama_v2.py CHANGED
@@ -28,6 +28,7 @@ import os
28
  from transformers import PretrainedConfig
29
  from transformers import PreTrainedModel
30
  from typing import List
 
31
  class minigpt4_video_config(PretrainedConfig):
32
  model_type="minigpt4_video"
33
  PRETRAINED_MODEL_CONFIG_DICT = {
@@ -42,9 +43,6 @@ class minigpt4_video_config(PretrainedConfig):
42
  setattr(self, key, value)
43
  super().__init__(**kwargs)
44
 
45
- # def to_dict(self):
46
- # output = super().to_dict()
47
- # return output
48
 
49
  @registry.register_model("mini_gpt4_llama_v2")
50
  class MiniGPT4_Video(Blip2Base, PreTrainedModel):
@@ -62,8 +60,8 @@ class MiniGPT4_Video(Blip2Base, PreTrainedModel):
62
  cfg={},
63
  ):
64
  ## loop through the config minigpt4_video_config object and set the attributes
65
- if isinstance(cfg, minigpt4_video_config):
66
- cfg = cfg.to_dict()
67
 
68
  for key, value in cfg.items():
69
  try:
@@ -72,6 +70,10 @@ class MiniGPT4_Video(Blip2Base, PreTrainedModel):
72
  print(f"Error setting attribute {key} with value {value}")
73
  PreTrainedModel.__init__(self, minigpt4_video_config(cfg))
74
  Blip2Base.__init__(self)
 
 
 
 
75
  if "Mistral" in self.llama_model:
76
  from minigpt4_video.modeling_mistral import MistralForCausalLM as llm_model
77
  print("Mistral model")
 
28
  from transformers import PretrainedConfig
29
  from transformers import PreTrainedModel
30
  from typing import List
31
+ from collections import defaultdict
32
  class minigpt4_video_config(PretrainedConfig):
33
  model_type="minigpt4_video"
34
  PRETRAINED_MODEL_CONFIG_DICT = {
 
43
  setattr(self, key, value)
44
  super().__init__(**kwargs)
45
 
 
 
 
46
 
47
  @registry.register_model("mini_gpt4_llama_v2")
48
  class MiniGPT4_Video(Blip2Base, PreTrainedModel):
 
60
  cfg={},
61
  ):
62
  ## loop through the config minigpt4_video_config object and set the attributes
63
+ # if isinstance(cfg, minigpt4_video_config):
64
+ cfg = cfg.to_dict()
65
 
66
  for key, value in cfg.items():
67
  try:
 
70
  print(f"Error setting attribute {key} with value {value}")
71
  PreTrainedModel.__init__(self, minigpt4_video_config(cfg))
72
  Blip2Base.__init__(self)
73
+
74
+ vis_processor_cfg = {"name": "blip2_image_train","image_size": 224}
75
+ print(vis_processor_cfg)
76
+ self.vis_processor = registry.get_processor_class(vis_processor_cfg["name"]).from_config(vis_processor_cfg)
77
  if "Mistral" in self.llama_model:
78
  from minigpt4_video.modeling_mistral import MistralForCausalLM as llm_model
79
  print("Mistral model")