Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,6 @@ from transformers import VisionEncoderDecoderModel, ViTFeatureExtractor, AutoTok
|
|
7 |
print("="*150)
|
8 |
print("MODEL LOADED")
|
9 |
st.title("img_captioning_app")
|
10 |
-
model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
11 |
-
feature_extractor = ViTFeatureExtractor.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
12 |
-
tokenizer = AutoTokenizer.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
13 |
#st.text("Build with Streamlit and OpenCV")
|
14 |
if "photo" not in st.session_state:
|
15 |
st.session_state["photo"]="not done"
|
@@ -28,6 +25,9 @@ activities = ["Caption","About"]
|
|
28 |
choice = st.sidebar.selectbox("Select Activty",activities)
|
29 |
uploaded_photo = c2.file_uploader("Upload Image",type=['jpg','png','jpeg'], on_change=change_photo_state)
|
30 |
camera_photo = c2.camera_input("Take a photo", on_change=change_photo_state)
|
|
|
|
|
|
|
31 |
if choice == 'Caption':
|
32 |
#st.subheader("Detection")
|
33 |
if st.session_state["photo"]=="done":
|
@@ -54,5 +54,5 @@ if choice == 'Caption':
|
|
54 |
st.success(predict_step(our_image))
|
55 |
elif choice == 'About':
|
56 |
st.subheader("About Image Captioning App")
|
57 |
-
st.markdown("Built with Streamlit by [Soumen Sarker](https://soumen-sarker-personal-
|
58 |
st.markdown("Demo applicaton of the following model [credit](https://huggingface.co/nlpconnect/vit-gpt2-image-captioning/)")
|
|
|
7 |
print("="*150)
|
8 |
print("MODEL LOADED")
|
9 |
st.title("img_captioning_app")
|
|
|
|
|
|
|
10 |
#st.text("Build with Streamlit and OpenCV")
|
11 |
if "photo" not in st.session_state:
|
12 |
st.session_state["photo"]="not done"
|
|
|
25 |
choice = st.sidebar.selectbox("Select Activty",activities)
|
26 |
uploaded_photo = c2.file_uploader("Upload Image",type=['jpg','png','jpeg'], on_change=change_photo_state)
|
27 |
camera_photo = c2.camera_input("Take a photo", on_change=change_photo_state)
|
28 |
+
model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
29 |
+
feature_extractor = ViTFeatureExtractor.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
31 |
if choice == 'Caption':
|
32 |
#st.subheader("Detection")
|
33 |
if st.session_state["photo"]=="done":
|
|
|
54 |
st.success(predict_step(our_image))
|
55 |
elif choice == 'About':
|
56 |
st.subheader("About Image Captioning App")
|
57 |
+
st.markdown("Built with Streamlit by [Soumen Sarker](https://soumen-sarker-personal-website.streamlit.app/)")
|
58 |
st.markdown("Demo applicaton of the following model [credit](https://huggingface.co/nlpconnect/vit-gpt2-image-captioning/)")
|