backup
Browse files
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
|
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 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|