Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ import torchvision.transforms as T
|
|
| 4 |
from torchvision.models import detection
|
| 5 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration
|
| 6 |
|
| 7 |
-
# — DEVICE SETUP —
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
# — 1) Object Detector (Faster R‑CNN, COCO labels) —
|
|
@@ -15,8 +14,8 @@ COCO_LABELS = [
|
|
| 15 |
]
|
| 16 |
|
| 17 |
# — 2) Caption Model (lighter for speed) —
|
| 18 |
-
processor = Blip2Processor.from_pretrained("Salesforce/blip2-flan-t5-
|
| 19 |
-
model
|
| 20 |
|
| 21 |
# — 3) Pre‑processing pipeline —
|
| 22 |
transform = T.Compose([
|
|
|
|
| 4 |
from torchvision.models import detection
|
| 5 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration
|
| 6 |
|
|
|
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
# — 1) Object Detector (Faster R‑CNN, COCO labels) —
|
|
|
|
| 14 |
]
|
| 15 |
|
| 16 |
# — 2) Caption Model (lighter for speed) —
|
| 17 |
+
processor = Blip2Processor.from_pretrained( "Salesforce/blip2-flan-t5-xl", torch_dtype=torch.float16 )
|
| 18 |
+
model = Blip2ForConditionalGeneration.from_pretrained( "Salesforce/blip2-flan-t5-xl", torch_dtype=torch.float16 ).to(device)
|
| 19 |
|
| 20 |
# — 3) Pre‑processing pipeline —
|
| 21 |
transform = T.Compose([
|