hungchiayu commited on
Commit
9d76bb1
·
1 Parent(s): 2af19ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -21,10 +21,6 @@ from transformers import (
21
  clip = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-base-patch32")
22
  processor = AutoProcessor.from_pretrained("openai/clip-vit-base-patch32")
23
 
24
- default_img = Image.open("gfg.png")
25
- default_img = processor(images=default_img,return_tensors='pt').pixel_values
26
-
27
-
28
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
29
  t5 = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
30
 
@@ -35,13 +31,13 @@ vt5.load_state_dict(torch.load('weights.bin',map_location=torch.device('cpu')))
35
  def generate_caption(image):
36
  # Your model code here
37
  caption = "This is a placeholder caption"
38
- print(image)
39
  caption = vt5.generate_caption(image)
40
  return caption
41
 
42
  st.title("Image Captioning App")
43
  #st.image(image.numpy().reshape(224,224,3), caption='Uploaded Image.', clamp=True,use_column_width=True)
44
- uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png","jpeg"])
45
 
46
  if uploaded_file is not None:
47
  image = Image.open(uploaded_file)
 
21
  clip = CLIPVisionModelWithProjection.from_pretrained("openai/clip-vit-base-patch32")
22
  processor = AutoProcessor.from_pretrained("openai/clip-vit-base-patch32")
23
 
 
 
 
 
24
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
25
  t5 = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
26
 
 
31
  def generate_caption(image):
32
  # Your model code here
33
  caption = "This is a placeholder caption"
34
+
35
  caption = vt5.generate_caption(image)
36
  return caption
37
 
38
  st.title("Image Captioning App")
39
  #st.image(image.numpy().reshape(224,224,3), caption='Uploaded Image.', clamp=True,use_column_width=True)
40
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
41
 
42
  if uploaded_file is not None:
43
  image = Image.open(uploaded_file)