Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ print("RESNET MODEL LOADED")
|
|
21 |
def load_image(img):
|
22 |
im = Image.open(img)
|
23 |
return im
|
24 |
-
activities = ["
|
25 |
choice = st.sidebar.selectbox("Select Activty",activities)
|
26 |
model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
27 |
uploaded_photo = c2.file_uploader("Upload Image",type=['jpg','png','jpeg'], on_change=change_photo_state)
|
@@ -42,17 +42,16 @@ def predict_step(our_image):
|
|
42 |
preds = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
|
43 |
preds = [pred.strip() for pred in preds]
|
44 |
return preds
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
st.markdown("Demo applicaton of the following model [credit](https://huggingface.co/nlpconnect/vit-gpt2-image-captioning/)")
|
|
|
21 |
def load_image(img):
|
22 |
im = Image.open(img)
|
23 |
return im
|
24 |
+
activities = ["About"]
|
25 |
choice = st.sidebar.selectbox("Select Activty",activities)
|
26 |
model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
|
27 |
uploaded_photo = c2.file_uploader("Upload Image",type=['jpg','png','jpeg'], on_change=change_photo_state)
|
|
|
42 |
preds = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
|
43 |
preds = [pred.strip() for pred in preds]
|
44 |
return preds
|
45 |
+
#st.subheader("Detection")
|
46 |
+
if st.session_state["photo"]=="done":
|
47 |
+
if uploaded_photo:
|
48 |
+
our_image= load_image(uploaded_photo)
|
49 |
+
elif camera_photo:
|
50 |
+
our_image= load_image(camera_photo)
|
51 |
+
elif uploaded_photo==None and camera_photo==None:
|
52 |
+
our_image= load_image('image.jpg')
|
53 |
+
st.success(predict_step(our_image))
|
54 |
+
if choice == 'About':
|
55 |
+
st.subheader("About Image Captioning App")
|
56 |
+
st.markdown("Built with Streamlit by [Soumen Sarker](https://soumen-sarker-personal-website.streamlit.app/)")
|
57 |
+
st.markdown("Demo applicaton of the following model [credit](https://huggingface.co/nlpconnect/vit-gpt2-image-captioning/)")
|
|