ydshieh commited on
Commit
66d7526
1 Parent(s): 4c1b4ac

update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py CHANGED
@@ -1 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from model import *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import numpy as np
4
+
5
+
6
+ # Designing the interface
7
+ st.title("WIT: Image -> Caption App")
8
+ # For newline
9
+ st.write('\n')
10
+
11
+ image = Image.open('images/image.png')
12
+ show = st.image(image, use_column_width=True)
13
+
14
  from model import *
15
+
16
+ st.sidebar.title("Upload Image")
17
+
18
+ # Disabling warning
19
+ st.set_option('deprecation.showfileUploaderEncoding', False)
20
+ # Choose your own image
21
+ uploaded_file = st.sidebar.file_uploader(" ", type=['png', 'jpg', 'jpeg'])
22
+
23
+ if uploaded_file is not None:
24
+
25
+ image = Image.open(uploaded_file)
26
+ show.image(image, 'Uploaded Image', use_column_width=True)
27
+
28
+
29
+ # For newline
30
+ st.sidebar.write('\n')
31
+
32
+ if st.sidebar.button("Click here to get image caption"):
33
+
34
+ if uploaded_file is None:
35
+
36
+ st.sidebar.write("Please upload an Image to Classify")
37
+
38
+ else:
39
+
40
+ with st.spinner('Generating image caption ...'):
41
+
42
+ caption = 'dummy caption'
43
+ st.success(f'caption: {caption}')
44
+
45
+ st.sidebar.header("ViT-GPT2 predicts:")
46
+ st.sidebar.write(f"caption: {caption}", '\n')