sourabhbargi11 commited on
Commit
b654e77
·
verified ·
1 Parent(s): cf6cf6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -4,7 +4,6 @@ from transformers import ViTImageProcessor, VisionEncoderDecoderModel,RobertaTo
4
  import PIL
5
  import streamlit as st
6
  from PIL import Image
7
- import trasformer
8
 
9
 
10
  def set_page_config():
@@ -33,13 +32,9 @@ def image_preprocess(image):
33
 
34
  def generate_caption(image_processor, model, tokenizer,device, image):
35
  inputs = image_processor(image, return_tensors='pt')
36
- print(inputs)
37
- model.eval()
38
- # Generate caption
39
- with torch.no_grad():
40
- output = model.generate(pixel_values=inputs)
41
- # Decode the generated caption
42
- caption = tokenizer.decode(output[0], skip_special_tokens=True)
43
  return caption
44
 
45
 
 
4
  import PIL
5
  import streamlit as st
6
  from PIL import Image
 
7
 
8
 
9
  def set_page_config():
 
32
 
33
  def generate_caption(image_processor, model, tokenizer,device, image):
34
  inputs = image_processor(image, return_tensors='pt')
35
+ output = model.generate(**inputs)
36
+
37
+ caption = tokenizer.decode(output[0], skip_special_tokens=True)
 
 
 
 
38
  return caption
39
 
40