taesiri commited on
Commit
57a6685
1 Parent(s): 2cf99de
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
5
- from transformers import AutoConfig, AutoModelForCausalLM, AutoProcessor
6
  from peft import PeftModel
7
  from huggingface_hub import login
8
  import spaces
@@ -31,18 +31,30 @@ login(token=os.environ["HF_TOKEN"], add_to_git_credential=True)
31
  base_model_path = "taesiri/BugsBunny-LLama-3.2-11B-Vision-Instruct-Medium-FullModel"
32
  # lora_weights_path = "taesiri/BugsBunny-LLama-3.2-11B-Vision-Base-Medium-LoRA"
33
 
34
- try:
35
- processor = AutoProcessor.from_pretrained(base_model_path, trust_remote_code=True)
36
- model = AutoModelForCausalLM.from_pretrained(
37
- base_model_path,
38
- torch_dtype=torch.bfloat16,
39
- device_map="cuda",
40
- trust_remote_code=True,
41
- )
42
- model.tie_weights()
43
- except Exception as e:
44
- print(f"Error loading model: {e}")
45
- raise
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  # model = PeftModel.from_pretrained(model, lora_weights_path)
48
 
 
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
5
+ from transformers import MllamaForConditionalGeneration, AutoProcessor
6
  from peft import PeftModel
7
  from huggingface_hub import login
8
  import spaces
 
31
  base_model_path = "taesiri/BugsBunny-LLama-3.2-11B-Vision-Instruct-Medium-FullModel"
32
  # lora_weights_path = "taesiri/BugsBunny-LLama-3.2-11B-Vision-Base-Medium-LoRA"
33
 
34
+ # processor = AutoProcessor.from_pretrained(base_model_path)
35
+ # model = MllamaForConditionalGeneration.from_pretrained(
36
+ # base_model_path,
37
+ # torch_dtype=torch.bfloat16,
38
+ # device_map="cuda",
39
+ # )
40
+
41
+ from transformers import AutoModelForCausalLM, AutoProcessor, LlamaTokenizer
42
+ import torch
43
+
44
+ model_path = "taesiri/BugsBunny-LLama-3.2-11B-Vision-Instruct-Medium-FullModel"
45
+
46
+ # Load the processor (handles both text and vision inputs)
47
+ processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
48
+
49
+ # Load the model
50
+ model = AutoModelForCausalLM.from_pretrained(
51
+ model_path, torch_dtype=torch.bfloat16, device_map="cuda", trust_remote_code=True
52
+ )
53
+
54
+ # If you specifically need the tokenizer
55
+ tokenizer = LlamaTokenizer.from_pretrained(model_path)
56
+
57
+ model.tie_weights()
58
 
59
  # model = PeftModel.from_pretrained(model, lora_weights_path)
60