Utk113Raj commited on
Commit
7461634
·
verified ·
1 Parent(s): 2fff0ab

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -5
handler.py CHANGED
@@ -2,11 +2,11 @@ from gliner import GLiNER
2
 
3
  class EndpointHandler:
4
  def __init__(self, path=""):
5
- # Use the provided path for loading the model
6
- self.model = GLiNER.from_pretrained(
7
- path,
8
- device_map="cuda"
9
- )
10
 
11
  def __call__(self, data):
12
  # If data is wrapped in 'inputs' (as Hugging Face does), unwrap it
 
2
 
3
  class EndpointHandler:
4
  def __init__(self, path=""):
5
+ # Load without device_map, then move to GPU
6
+ self.model = GLiNER.from_pretrained(path) # Remove device_map="cuda"
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
+ self.model = self.model.to(device)
9
+ self.model.eval() # Lock for inference
10
 
11
  def __call__(self, data):
12
  # If data is wrapped in 'inputs' (as Hugging Face does), unwrap it