Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- 'vision '
|
| 8 |
+
- speech
|
| 9 |
+
- image-text-text
|
| 10 |
+
- audio-text-text
|
| 11 |
+
- Multi-Modal
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# ADD VISION
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
print('Add Vision...')
|
| 23 |
+
# ADD HEAD
|
| 24 |
+
# Combine pre-trained encoder and pre-trained decoder to form a Seq2Seq model
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
Vmodel = VisionEncoderDecoderModel.from_encoder_decoder_pretrained(
|
| 29 |
+
"google/vit-base-patch16-224-in21k", "LeroyDyer/Mixtral_AI_Tiny"
|
| 30 |
+
)
|
| 31 |
+
_Encoder_ImageProcessor = Vmodel.encoder
|
| 32 |
+
_Decoder_ImageTokenizer = Vmodel.decoder
|
| 33 |
+
_VisionEncoderDecoderModel = Vmodel
|
| 34 |
+
# Add Pad tokems
|
| 35 |
+
LM_MODEL.VisionEncoderDecoder = _VisionEncoderDecoderModel
|
| 36 |
+
# Add Sub Components
|
| 37 |
+
LM_MODEL.Encoder_ImageProcessor = _Encoder_ImageProcessor
|
| 38 |
+
LM_MODEL.Decoder_ImageTokenizer = _Decoder_ImageTokenizer
|
| 39 |
+
LM_MODEL
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
# ADD AUDIO
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
print('Add Audio...')
|
| 51 |
+
#Add Head
|
| 52 |
+
# Combine pre-trained encoder and pre-trained decoder to form a Seq2Seq model
|
| 53 |
+
_AudioFeatureExtractor = AutoFeatureExtractor.from_pretrained("openai/whisper-small")
|
| 54 |
+
_AudioTokenizer = AutoTokenizer.from_pretrained("openai/whisper-small")
|
| 55 |
+
_SpeechEncoderDecoder = SpeechEncoderDecoderModel.from_encoder_decoder_pretrained("openai/whisper-small","openai/whisper-small")
|
| 56 |
+
|
| 57 |
+
# Add Pad tokems
|
| 58 |
+
_SpeechEncoderDecoder.config.decoder_start_token_id = _AudioTokenizer.cls_token_id
|
| 59 |
+
_SpeechEncoderDecoder.config.pad_token_id = _AudioTokenizer.pad_token_id
|
| 60 |
+
LM_MODEL.SpeechEncoderDecoder = _SpeechEncoderDecoder
|
| 61 |
+
# Add Sub Components
|
| 62 |
+
LM_MODEL.Decoder_AudioTokenizer = _AudioTokenizer
|
| 63 |
+
LM_MODEL.Encoder_AudioFeatureExtractor = _AudioFeatureExtractor
|
| 64 |
+
LM_MODEL
|
| 65 |
+
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
# SAVE
|
| 69 |
+
```python
|
| 70 |
+
print('Final stages:...')
|
| 71 |
+
print('Add tokenizer...')
|
| 72 |
+
LM_MODEL.resize_token_embeddings(len(tokenizer))
|
| 73 |
+
LM_MODEL.tokenizer = tokenizer
|
| 74 |
+
print('Save model...')
|
| 75 |
+
LM_MODEL.to(torch.float16)
|
| 76 |
+
LM_MODEL.save_pretrained("Mixtral_AI_MiniModalTron")
|
| 77 |
+
print('Save tokenizer...')
|
| 78 |
+
tokenizer.save_pretrained("Mixtral_AI_MiniModalTron")
|
| 79 |
+
|
| 80 |
+
```
|