Upload FloSmolV
Browse files- configuration_flosmolv.py +2 -4
- modeling_flosmolv.py +2 -2
configuration_flosmolv.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
from transformers import AutoConfig, PretrainedConfig
|
2 |
-
|
3 |
class FloSmolVConfig(PretrainedConfig):
|
4 |
model_type = "flosmolV"
|
5 |
-
is_composition = True
|
6 |
|
7 |
def __init__(
|
8 |
self,
|
@@ -10,11 +8,11 @@ class FloSmolVConfig(PretrainedConfig):
|
|
10 |
llm_config=None,
|
11 |
**kwargs,
|
12 |
):
|
|
|
13 |
|
14 |
if vision_config is None:
|
15 |
vision_config = AutoConfig.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True)
|
16 |
if llm_config is None:
|
17 |
llm_config = AutoConfig.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct", trust_remote_code=True)
|
18 |
self.vision_config = vision_config
|
19 |
-
self.llm_config = llm_config
|
20 |
-
super().__init__(**kwargs)
|
|
|
1 |
from transformers import AutoConfig, PretrainedConfig
|
|
|
2 |
class FloSmolVConfig(PretrainedConfig):
|
3 |
model_type = "flosmolV"
|
|
|
4 |
|
5 |
def __init__(
|
6 |
self,
|
|
|
8 |
llm_config=None,
|
9 |
**kwargs,
|
10 |
):
|
11 |
+
super().__init__(**kwargs)
|
12 |
|
13 |
if vision_config is None:
|
14 |
vision_config = AutoConfig.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True)
|
15 |
if llm_config is None:
|
16 |
llm_config = AutoConfig.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct", trust_remote_code=True)
|
17 |
self.vision_config = vision_config
|
18 |
+
self.llm_config = llm_config
|
|
modeling_flosmolv.py
CHANGED
@@ -7,8 +7,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
|
|
7 |
class FloSmolV(PreTrainedModel):
|
8 |
config_class = FloSmolVConfig
|
9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
10 |
-
|
11 |
-
def __init__(self, config):
|
12 |
super().__init__(config)
|
13 |
self.florence2_model = AutoModelForCausalLM.from_pretrained(
|
14 |
self.config.vision_config._name_or_path,
|
|
|
7 |
class FloSmolV(PreTrainedModel):
|
8 |
config_class = FloSmolVConfig
|
9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
10 |
+
|
11 |
+
def __init__(self, config: FloSmolVConfig):
|
12 |
super().__init__(config)
|
13 |
self.florence2_model = AutoModelForCausalLM.from_pretrained(
|
14 |
self.config.vision_config._name_or_path,
|