Commit ·
4ad5631
1
Parent(s): db1d42e
Fixed variable error.
Browse files- handler.py +3 -3
handler.py
CHANGED
|
@@ -24,7 +24,7 @@ class EndpointHandler():
|
|
| 24 |
self.processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
| 25 |
self.model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16, device_map="auto")
|
| 26 |
print(" $$$$ model loaded $$$$")
|
| 27 |
-
print(self.model.eval())
|
| 28 |
|
| 29 |
|
| 30 |
|
|
@@ -67,9 +67,9 @@ class EndpointHandler():
|
|
| 67 |
inputs = self.processor(raw_image, prompt, return_tensors="pt").to("cuda", torch.float16)
|
| 68 |
|
| 69 |
print("@@@@@@ generated_text @@@@@@@")
|
| 70 |
-
print(generated_text)
|
| 71 |
out = self.model.generate(**inputs)
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
print("captions", captions)
|
| 75 |
|
|
|
|
| 24 |
self.processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
| 25 |
self.model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16, device_map="auto")
|
| 26 |
print(" $$$$ model loaded $$$$")
|
| 27 |
+
# print(self.model.eval())
|
| 28 |
|
| 29 |
|
| 30 |
|
|
|
|
| 67 |
inputs = self.processor(raw_image, prompt, return_tensors="pt").to("cuda", torch.float16)
|
| 68 |
|
| 69 |
print("@@@@@@ generated_text @@@@@@@")
|
|
|
|
| 70 |
out = self.model.generate(**inputs)
|
| 71 |
+
print("!!!!!!")
|
| 72 |
+
captions = self.processor.decode(out[0], skip_special_tokens=True)
|
| 73 |
|
| 74 |
print("captions", captions)
|
| 75 |
|