hughtayloe commited on
Commit
6a72b4d
1 Parent(s): 1029894

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -3
handler.py CHANGED
@@ -1,12 +1,17 @@
1
  from typing import Dict, List, Any
2
- from transformers import pipeline
3
  from PIL import Image
4
  import requests
 
5
 
6
  class EndpointHandler():
7
  def __init__(self, path=""):
8
- print("init")
9
- self.pipeline = pipeline("image-to-text", model=path)
 
 
 
 
10
 
11
  def __call__(self, data: Dict[str, Any]):
12
  totalarr = []
 
1
  from typing import Dict, List, Any
2
+ from transformers import pipeline, BitsAndBytesConfig
3
  from PIL import Image
4
  import requests
5
+ import torch
6
 
7
  class EndpointHandler():
8
  def __init__(self, path=""):
9
+ quantization_config = BitsAndBytesConfig(
10
+ load_in_4bit=True,
11
+ bnb_4bit_compute_dtype=torch.float16
12
+ )
13
+ pipe = pipeline("image-to-text", path="", model_kwargs={"quantization_config": quantization_config})
14
+
15
 
16
  def __call__(self, data: Dict[str, Any]):
17
  totalarr = []