Text Generation
Transformers
Safetensors
English
Chinese
emova_qwen2
Omni-modal-LLM
Multi-modal-LLM
Emotional-spoken-dialogue
conversational
Eval Results
KaiChen1998 commited on
Commit
db915aa
·
verified ·
1 Parent(s): 22342be

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -64
README.md CHANGED
@@ -223,71 +223,8 @@ model-index:
223
 
224
  ## Usage
225
 
226
- This repo contains the **EMOVA-Qwen2.5-7B** checkpoint organized in the **HuggingFace format**, and thus, and be directly loaded with **transformers Auto APIs**.
227
 
228
- ```python
229
- from transformers import AutoModel, AutoProcessor
230
- from PIL import Image
231
- import torch
232
-
233
- ### Uncomment if you want to use Ascend NPUs
234
- # import torch_npu
235
- # from torch_npu.contrib import transfer_to_npu
236
-
237
- # prepare models and processors
238
- model = AutoModel.from_pretrained(
239
- "Emova-ollm/emova-qwen-2-5-7b-hf",
240
- torch_dtype=torch.bfloat16,
241
- attn_implementation='flash_attention_2', # OR 'sdpa' for Ascend NPUs
242
- low_cpu_mem_usage=True,
243
- trust_remote_code=True).eval().cuda()
244
- processor = AutoProcessor.from_pretrained("Emova-ollm/emova-qwen-2-5-7b-hf", trust_remote_code=True)
245
-
246
- # only necessary for spoken dialogue
247
- # Note to inference with speech inputs/outputs, **emova_speech_tokenizer** is still a necessary dependency (https://huggingface.co/Emova-ollm/emova_speech_tokenizer_hf#install).
248
- speeck_tokenizer = AutoModel.from_pretrained("Emova-ollm/emova_speech_tokenizer_hf", torch_dtype=torch.float32, trust_remote_code=True).eval().cuda()
249
- processor.set_speech_tokenizer(speeck_tokenizer)
250
-
251
- # Example 1: image-text
252
- inputs = dict(
253
- text=[
254
- {"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]},
255
- {"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "What's shown in this image?"}]},
256
- {"role": "assistant", "content": [{"type": "text", "text": "This image shows a red stop sign."}]},
257
- {"role": "user", "content": [{"type": "text", "text": "Describe the image in more details."}]},
258
- ],
259
- images=Image.open('path/to/image')
260
- )
261
-
262
- # Example 2: text-audio
263
- inputs = dict(
264
- text=[{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]}],
265
- audios='path/to/audio'
266
- )
267
-
268
- # Example 3: image-text-audio
269
- inputs = dict(
270
- text=[{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]}],
271
- images=Image.open('path/to/image'),
272
- audios='path/to/audio'
273
- )
274
-
275
- # run processors
276
- has_speech = 'audios' in inputs.keys()
277
- inputs = processor(**inputs, return_tensors="pt")
278
- inputs = inputs.to(model.device)
279
-
280
- # prepare generation arguments
281
- gen_kwargs = {"max_new_tokens": 4096, "do_sample": False} # add if necessary
282
- speech_kwargs = {"speaker": "female", "output_wav_prefix": "output"} if has_speech else {}
283
-
284
- # run generation
285
- # for speech outputs, we will return the saved wav paths (c.f., output_wav_prefix)
286
- with torch.no_grad():
287
- outputs = model.generate(**inputs, **gen_kwargs)
288
- outputs = outputs[:, inputs['input_ids'].shape[1]:]
289
- print(processor.batch_decode(outputs, skip_special_tokens=True, **speech_kwargs))
290
- ```
291
 
292
  ## Citation
293
 
 
223
 
224
  ## Usage
225
 
226
+ This repo contains the **EMOVA-Qwen2.5-7B** checkpoint organized in the **original format** of our [EMOVA codebase](https://github.com/emova-ollm/EMOVA), and thus, it should be utilized together with EMOVA codebase. Its paired config file is provided [here](https://github.com/emova-ollm/EMOVA/blob/main/configs/example/emova/qwen2_5_qwen2vit_nativeAnyres_7b/2.finetune.py). Check [here](https://github.com/emova-ollm/EMOVA#gradio-web-demo) to launch a web demo using this checkpoint.
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  ## Citation
230