Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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(
|
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 |
|