Spaces:
Paused
Paused
Commit ·
1fcf94f
1
Parent(s): acd0c9f
changed the model
Browse files- app/caption_model.py +3 -9
app/caption_model.py
CHANGED
|
@@ -1,15 +1,9 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
from PIL import Image
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# Load model and processor only once at startup
|
| 10 |
-
processor = BlipProcessor.from_pretrained(MODEL_NAME)
|
| 11 |
-
model = BlipForConditionalGeneration.from_pretrained(MODEL_NAME).to(device)
|
| 12 |
-
model.eval()
|
| 13 |
|
| 14 |
def caption_image(image: Image.Image):
|
| 15 |
# Validate input
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
from PIL import Image
|
|
|
|
| 3 |
|
| 4 |
+
# Load object detection model
|
| 5 |
+
MODEL_NAME = "facebook/detr-resnet-50"
|
| 6 |
+
detector = pipeline("object-detection", model=MODEL_NAME)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def caption_image(image: Image.Image):
|
| 9 |
# Validate input
|