zhoudong
commited on
Commit
•
483b1a4
1
Parent(s):
cb8f140
modify_license
Browse files- configuration_megrezo.py +14 -0
- image_processing_megrezo.py +15 -0
- modeling_megrezo.py +15 -10
- processing_megrezo.py +13 -3
- resampler.py +15 -0
- tokenizer_wrapper.py +14 -0
configuration_megrezo.py
CHANGED
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""MegrezO model configuration"""
|
2 |
|
3 |
from typing import Optional
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
"""MegrezO model configuration"""
|
16 |
|
17 |
from typing import Optional
|
image_processing_megrezo.py
CHANGED
@@ -1,3 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from typing import Optional, Union, Dict, Any, List
|
2 |
|
3 |
import torch
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""This file is copied from https://huggingface.co/openbmb/MiniCPM-V-2_6/resolve/main/image_processing_minicpmv.py and modified as needed."""
|
15 |
+
|
16 |
from typing import Optional, Union, Dict, Any, List
|
17 |
|
18 |
import torch
|
modeling_megrezo.py
CHANGED
@@ -1,19 +1,24 @@
|
|
1 |
-
#
|
2 |
-
#
|
3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
|
6 |
import torch
|
7 |
-
from torch.nn.utils.rnn import pad_sequence
|
8 |
from transformers import AutoProcessor
|
9 |
from transformers import LlamaForCausalLM
|
10 |
from transformers.modeling_utils import PreTrainedModel
|
11 |
from transformers.utils import add_start_docstrings
|
12 |
-
from transformers.utils import add_start_docstrings_to_model_forward
|
13 |
-
from transformers.utils import is_flash_attn_2_available
|
14 |
-
from transformers.utils import is_flash_attn_greater_or_equal_2_10
|
15 |
-
from transformers.utils import logging
|
16 |
-
from transformers.utils import replace_return_docstrings
|
17 |
|
18 |
from .audio import AudioEncoder
|
19 |
from .configuration_megrezo import MegrezOConfig
|
@@ -313,7 +318,7 @@ class MegrezO(MegrezOPreTrainedModel):
|
|
313 |
}
|
314 |
else:
|
315 |
generation_config = {
|
316 |
-
"num_beams":
|
317 |
"repetition_penalty": 1.2,
|
318 |
}
|
319 |
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""This file contains the implementation of the Megrez-Omni model."""
|
15 |
|
16 |
|
17 |
import torch
|
|
|
18 |
from transformers import AutoProcessor
|
19 |
from transformers import LlamaForCausalLM
|
20 |
from transformers.modeling_utils import PreTrainedModel
|
21 |
from transformers.utils import add_start_docstrings
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
from .audio import AudioEncoder
|
24 |
from .configuration_megrezo import MegrezOConfig
|
|
|
318 |
}
|
319 |
else:
|
320 |
generation_config = {
|
321 |
+
"num_beams": 1,
|
322 |
"repetition_penalty": 1.2,
|
323 |
}
|
324 |
|
processing_megrezo.py
CHANGED
@@ -1,6 +1,16 @@
|
|
1 |
-
#
|
2 |
-
#
|
3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
import io
|
6 |
import re
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
|
15 |
import io
|
16 |
import re
|
resampler.py
CHANGED
@@ -1,3 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from functools import partial
|
2 |
from typing import Optional, Tuple
|
3 |
import numpy as np
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""This file is copied from https://huggingface.co/openbmb/MiniCPM-V-2_6/blob/main/resampler.py and modified as needed."""
|
15 |
+
|
16 |
from functools import partial
|
17 |
from typing import Optional, Tuple
|
18 |
import numpy as np
|
tokenizer_wrapper.py
CHANGED
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import LlamaTokenizerFast
|
2 |
|
3 |
|
|
|
1 |
+
# Copyright 2024 Infinigence AI Team. All rights reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
from transformers import LlamaTokenizerFast
|
16 |
|
17 |
|