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,13 +31,18 @@ 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 |
# model = PeftModel.from_pretrained(model, lora_weights_path)
|
43 |
|
|
|
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 |
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 |
|