feat: add pages
Browse files
app.py
CHANGED
|
@@ -1,16 +1,28 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from lib.utils.model import get_model, get_similarities
|
| 3 |
-
from PIL import Image
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
st.header('Inputs')
|
| 10 |
caption = st.text_input('Description Input')
|
| 11 |
|
| 12 |
images = st.file_uploader('Upload images', accept_multiple_files=True)
|
| 13 |
if images is not None:
|
|
|
|
| 14 |
st.image(images) # type: ignore
|
| 15 |
|
| 16 |
st.header('Options')
|
|
@@ -32,12 +44,27 @@ if button:
|
|
| 32 |
|
| 33 |
indices = similarities.argsort(descending=True).cpu().tolist()[:ranks]
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
for i, idx in enumerate(indices):
|
| 36 |
c1, c2, c3 = st.columns(3)
|
| 37 |
with c1:
|
| 38 |
-
st.text(f'
|
| 39 |
with c2:
|
| 40 |
st.image(images[idx])
|
| 41 |
with c3:
|
| 42 |
-
st.text(f'
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from st_pages import Page, show_pages, add_page_title, Section
|
| 3 |
from lib.utils.model import get_model, get_similarities
|
|
|
|
| 4 |
|
| 5 |
+
add_page_title()
|
| 6 |
+
|
| 7 |
+
show_pages(
|
| 8 |
+
[
|
| 9 |
+
Page('app.py', 'IRRA Text-To-Image-Retrival'),
|
| 10 |
+
Section('Implementation Details'),
|
| 11 |
+
Page('pages/losses.py', 'Loss functions'),
|
| 12 |
+
]
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
st.markdown('''
|
| 16 |
+
A text-to-image retrieval model implemented from [arXiv: Cross-Modal Implicit Relation Reasoning and Aligning for Text-to-Image Person Retrieval](https://arxiv.org/abs/2303.12501).
|
| 17 |
+
The uploaded images should be `384x128` with only one person in the shot.
|
| 18 |
+
''')
|
| 19 |
|
| 20 |
st.header('Inputs')
|
| 21 |
caption = st.text_input('Description Input')
|
| 22 |
|
| 23 |
images = st.file_uploader('Upload images', accept_multiple_files=True)
|
| 24 |
if images is not None:
|
| 25 |
+
|
| 26 |
st.image(images) # type: ignore
|
| 27 |
|
| 28 |
st.header('Options')
|
|
|
|
| 44 |
|
| 45 |
indices = similarities.argsort(descending=True).cpu().tolist()[:ranks]
|
| 46 |
|
| 47 |
+
c1, c2, c3 = st.columns(3)
|
| 48 |
+
with c1:
|
| 49 |
+
st.subheader('Rank')
|
| 50 |
+
with c2:
|
| 51 |
+
st.subheader('Image')
|
| 52 |
+
with c3:
|
| 53 |
+
st.subheader('Cosine Similarity', help='Due to the nature of the SDM loss, the higher the similarity, the more similar the match is')
|
| 54 |
+
|
| 55 |
for i, idx in enumerate(indices):
|
| 56 |
c1, c2, c3 = st.columns(3)
|
| 57 |
with c1:
|
| 58 |
+
st.text(f'{i + 1}')
|
| 59 |
with c2:
|
| 60 |
st.image(images[idx])
|
| 61 |
with c3:
|
| 62 |
+
st.text(f'{similarities[idx].cpu():.2f}')
|
| 63 |
+
|
| 64 |
+
with st.sidebar:
|
| 65 |
+
st.title('IRRA Text-To-Image Retrival')
|
| 66 |
+
|
| 67 |
+
st.subheader('Useful Links')
|
| 68 |
+
st.markdown('[arXiv: Cross-Modal Implicit Relation Reasoning and Aligning for Text-to-Image Person Retrieval](https://arxiv.org/abs/2303.12501)')
|
| 69 |
+
st.markdown('[IRRA implementation (Pytorch Lightning + Transformers)](https://github.com/grostaco/modern-IRRA)')
|
| 70 |
+
st.markdown('[IRRA implementation (PyTorch)](https://github.com/anosorae/IRRA/tree/main)')
|