AnwenHu commited on
Commit
abef6af
1 Parent(s): a2fe607

Update mplug_docowl/model/builder.py

Browse files
Files changed (1) hide show
  1. mplug_docowl/model/builder.py +4 -2
mplug_docowl/model/builder.py CHANGED
@@ -39,8 +39,8 @@ def load_pretrained_model(model_path, model_base, model_name, load_8bit=False, l
39
  bnb_4bit_quant_type='nf4'
40
  )
41
  else:
42
- # kwargs['torch_dtype'] = torch.float16
43
- kwargs['torch_dtype'] = torch.bfloat16
44
  if 'paperowl' or 'docowl' in model_name.lower():
45
  if model_base is not None:
46
  # this may be mm projector only
@@ -48,6 +48,8 @@ def load_pretrained_model(model_path, model_base, model_name, load_8bit=False, l
48
  tokenizer = AutoTokenizer.from_pretrained(model_base, use_fast=False)
49
  cfg_pretrained = AutoConfig.from_pretrained(model_path)
50
  model = MPLUGDocOwlLlamaForCausalLM.from_pretrained(model_base, low_cpu_mem_usage=True, config=cfg_pretrained, **kwargs)
 
 
51
  else:
52
  tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
53
  model = MPLUGDocOwlLlamaForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, **kwargs)
 
39
  bnb_4bit_quant_type='nf4'
40
  )
41
  else:
42
+ kwargs['torch_dtype'] = torch.float16
43
+
44
  if 'paperowl' or 'docowl' in model_name.lower():
45
  if model_base is not None:
46
  # this may be mm projector only
 
48
  tokenizer = AutoTokenizer.from_pretrained(model_base, use_fast=False)
49
  cfg_pretrained = AutoConfig.from_pretrained(model_path)
50
  model = MPLUGDocOwlLlamaForCausalLM.from_pretrained(model_base, low_cpu_mem_usage=True, config=cfg_pretrained, **kwargs)
51
+ # adjust for zero environment of huggingface space
52
+ model.to("cuda:0")
53
  else:
54
  tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
55
  model = MPLUGDocOwlLlamaForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, **kwargs)