nikravan commited on
Commit
8757e5a
1 Parent(s): e6b7585

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -2,7 +2,7 @@ import torch
2
  from PIL import Image
3
  import gradio as gr
4
  import spaces
5
- from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
6
  import os
7
  from threading import Thread
8
 
@@ -33,12 +33,17 @@ h1 {
33
  }
34
  """
35
 
 
 
 
 
36
  model = AutoModelForCausalLM.from_pretrained(
37
  MODEL_ID,
38
  torch_dtype=torch.bfloat16,
39
  low_cpu_mem_usage=True,
40
  trust_remote_code=True,
41
  return_dict=True,
 
42
  )
43
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
44
  model.eval()
 
2
  from PIL import Image
3
  import gradio as gr
4
  import spaces
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer,BitsAndBytesConfig
6
  import os
7
  from threading import Thread
8
 
 
33
  }
34
  """
35
 
36
+ quantization_config = BitsAndBytesConfig(
37
+ load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16
38
+ )
39
+
40
  model = AutoModelForCausalLM.from_pretrained(
41
  MODEL_ID,
42
  torch_dtype=torch.bfloat16,
43
  low_cpu_mem_usage=True,
44
  trust_remote_code=True,
45
  return_dict=True,
46
+ quantization_config=quantization_config
47
  )
48
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
49
  model.eval()