Mohansai2004 commited on
Commit
1fcf94f
·
1 Parent(s): acd0c9f

changed the model

Browse files
Files changed (1) hide show
  1. 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
- MODEL_NAME = "Salesforce/blip-image-captioning-base"
6
- MAX_LENGTH = 50
7
- device = "cuda" if torch.cuda.is_available() else "cpu"
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