jaimin commited on
Commit
a816143
1 Parent(s): 85ba2f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -13,9 +13,10 @@ processor = BlipProcessor.from_pretrained('jaimin/Imagecap')
13
 
14
  def predict(image,max_length=64, num_beams=4):
15
  image = image.convert('RGB')
16
- image = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
 
17
  #clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
18
- caption_ids = model.generate(image, max_length = max_length)[0]
19
  caption_text = tokenizer.decode(caption_ids)
20
  return processor.decode(caption_ids[0], skip_special_tokens=True)
21
 
 
13
 
14
  def predict(image,max_length=64, num_beams=4):
15
  image = image.convert('RGB')
16
+ #image = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
17
+ inputs = processor(image, return_tensors="pt")
18
  #clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
19
+ caption_ids = model.generate(inputs, max_length = max_length)[0]
20
  caption_text = tokenizer.decode(caption_ids)
21
  return processor.decode(caption_ids[0], skip_special_tokens=True)
22