Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,19 @@ import easyocr
|
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
model_name = "Salesforce/blip2-flan-t5-xl"
|
| 10 |
|
| 11 |
-
processor = Blip2Processor.from_pretrained(
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
torch_dtype=torch.float16 if device == "cuda" else torch.float32
|
| 16 |
-
)
|
| 17 |
-
.to(device)
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
ocr_reader = easyocr.Reader(['en'], gpu=(device == "cuda"))
|
| 21 |
detector = pipeline(
|
| 22 |
"object-detection",
|
|
|
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
model_name = "Salesforce/blip2-flan-t5-xl"
|
| 10 |
|
| 11 |
+
processor = Blip2Processor.from_pretrained(
|
| 12 |
+
model_name,
|
| 13 |
+
use_fast=False,
|
| 14 |
+
trust_remote_code=True
|
|
|
|
|
|
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
+
model = Blip2ForConditionalGeneration.from_pretrained(
|
| 18 |
+
model_name,
|
| 19 |
+
torch_dtype=(torch.float16 if device=="cuda" else torch.float32),
|
| 20 |
+
trust_remote_code=True
|
| 21 |
+
).to(device)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
ocr_reader = easyocr.Reader(['en'], gpu=(device == "cuda"))
|
| 25 |
detector = pipeline(
|
| 26 |
"object-detection",
|