Spaces:
Runtime error
Runtime error
Update inference.py
Browse files- inference.py +1 -0
inference.py
CHANGED
@@ -18,6 +18,7 @@ class PaliGemmaModel:
|
|
18 |
self.model = PaliGemmaForConditionalGeneration.from_pretrained(self.model_id).eval().to(self.device)
|
19 |
self.processor = PaliGemmaProcessor.from_pretrained(self.model_id)
|
20 |
|
|
|
21 |
def infer(self, image: PIL.Image.Image, text: str, max_new_tokens: int) -> str:
|
22 |
inputs = self.processor(text=text, images=image, return_tensors="pt")
|
23 |
inputs = {k: v.to(self.device) for k, v in inputs.items()} # Move inputs to the correct device
|
|
|
18 |
self.model = PaliGemmaForConditionalGeneration.from_pretrained(self.model_id).eval().to(self.device)
|
19 |
self.processor = PaliGemmaProcessor.from_pretrained(self.model_id)
|
20 |
|
21 |
+
@spaces.GPU
|
22 |
def infer(self, image: PIL.Image.Image, text: str, max_new_tokens: int) -> str:
|
23 |
inputs = self.processor(text=text, images=image, return_tensors="pt")
|
24 |
inputs = {k: v.to(self.device) for k, v in inputs.items()} # Move inputs to the correct device
|