Aekanun commited on
Commit
2500471
·
1 Parent(s): 2a60823
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -70,7 +70,7 @@ else:
70
  # traceback.print_exc() # เพิ่มการแสดง stack trace
71
  # return False
72
 
73
- @spaces.GPU
74
  def load_model():
75
  global model, tokenizer
76
  print("กำลังโหลดโมเดล...")
@@ -81,7 +81,8 @@ def load_model():
81
  print("กำลังโหลด tokenizer...")
82
  base_model, _tokenizer = FastVisionModel.from_pretrained(
83
  "unsloth/Llama-3.2-11B-Vision-Instruct",
84
- use_gradient_checkpointing = "unsloth"
 
85
  )
86
 
87
  tokenizer = _tokenizer # กำหนดค่าให้ตัวแปร global โดยตรง
@@ -96,7 +97,8 @@ def load_model():
96
  print("กำลังโหลดโมเดล fine-tuned...")
97
  model = AutoModelForVision2Seq.from_pretrained(
98
  "Aekanun/Llama-3.2-11B-Vision-Instruct-XRay",
99
- load_in_4bit=True,
 
100
  torch_dtype=torch.float16
101
  ).to('cuda')
102
 
 
70
  # traceback.print_exc() # เพิ่มการแสดง stack trace
71
  # return False
72
 
73
+ ###@spaces.GPU
74
  def load_model():
75
  global model, tokenizer
76
  print("กำลังโหลดโมเดล...")
 
81
  print("กำลังโหลด tokenizer...")
82
  base_model, _tokenizer = FastVisionModel.from_pretrained(
83
  "unsloth/Llama-3.2-11B-Vision-Instruct",
84
+ use_gradient_checkpointing = "unsloth",
85
+ device_map="auto" ### เพิ่มตรงนี้
86
  )
87
 
88
  tokenizer = _tokenizer # กำหนดค่าให้ตัวแปร global โดยตรง
 
97
  print("กำลังโหลดโมเดล fine-tuned...")
98
  model = AutoModelForVision2Seq.from_pretrained(
99
  "Aekanun/Llama-3.2-11B-Vision-Instruct-XRay",
100
+ device_map="auto", ### เพิ่มตรงนี้
101
+ ###load_in_4bit=True,
102
  torch_dtype=torch.float16
103
  ).to('cuda')
104