Spaces:
Runtime error
Runtime error
Javi
commited on
Commit
Β·
ff733c7
1
Parent(s):
2d2805b
UI & UX improvements
Browse files- streamlit_app.py +27 -8
streamlit_app.py
CHANGED
@@ -52,7 +52,23 @@ def limit_number_prompts(state: SessionState):
|
|
52 |
class Sections:
|
53 |
@staticmethod
|
54 |
def header():
|
55 |
-
st.markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
st.markdown("### Try OpenAI's CLIP model in your browser")
|
57 |
st.markdown(" ")
|
58 |
st.markdown(" ")
|
@@ -77,9 +93,6 @@ class Sections:
|
|
77 |
"Think of [Hotdog/ Not hotdog](https://www.youtube.com/watch?v=pqTntG1RXSY&ab_channel=tvpromos) without any training. ")
|
78 |
st.markdown(" ")
|
79 |
st.markdown(" ")
|
80 |
-
st.sidebar.markdown(" "); st.sidebar.markdown(" ")
|
81 |
-
st.sidebar.markdown("Created by [@JavierFnts](https://twitter.com/JavierFnts)")
|
82 |
-
st.sidebar.markdown("[How was CLIP playground created?](https://twitter.com/JavierFnts)")
|
83 |
|
84 |
@staticmethod
|
85 |
def image_uploader(state: SessionState, accept_multiple_files: bool):
|
@@ -185,7 +198,7 @@ class Sections:
|
|
185 |
@staticmethod
|
186 |
def classification_output(state: SessionState):
|
187 |
# Possible way of customize this https://discuss.streamlit.io/t/st-button-in-a-custom-layout/2187/2
|
188 |
-
if st.button("PREDICT π
|
189 |
with st.spinner("Predicting..."):
|
190 |
if isinstance(state.images[0], str):
|
191 |
clip_response = booste.clip(BOOSTE_API_KEY,
|
@@ -228,9 +241,14 @@ class Sections:
|
|
228 |
col2.markdown(f"### ")
|
229 |
|
230 |
|
231 |
-
task_name: str = st.sidebar.radio("Task", options=["Prompt ranking", "Image ranking", "Image classification"])
|
232 |
-
session_state = get_state()
|
233 |
Sections.header()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
if task_name == "Image classification":
|
235 |
Sections.image_uploader(session_state, accept_multiple_files=False)
|
236 |
if session_state.images is None:
|
@@ -263,6 +281,7 @@ elif task_name == "Image ranking":
|
|
263 |
limit_number_prompts(session_state)
|
264 |
Sections.multiple_images_input_preview(session_state)
|
265 |
Sections.classification_output(session_state)
|
266 |
-
print(session_state.images)
|
267 |
|
|
|
|
|
268 |
session_state.sync()
|
|
|
52 |
class Sections:
|
53 |
@staticmethod
|
54 |
def header():
|
55 |
+
st.markdown('<link rel="stylesheet" '
|
56 |
+
'href="https://fonts.googleapis.com/css?family=Merriweather+Sans">'
|
57 |
+
'<style> '
|
58 |
+
'h1 {font-family: "Merriweather Sans", sans-serif; font-size: 48px; color: #f57c70}'
|
59 |
+
'a {color: #e6746a !important}'
|
60 |
+
'.stButton>button {'
|
61 |
+
' color: white;'
|
62 |
+
' background: #e6746a;'
|
63 |
+
' display:inline-block;'
|
64 |
+
' width: 100%;'
|
65 |
+
' border-width: 0px;'
|
66 |
+
' font-weight: 500;'
|
67 |
+
' padding-top: 10px;'
|
68 |
+
' padding-bottom: 10px;'
|
69 |
+
'}'
|
70 |
+
'</style>', unsafe_allow_html=True)
|
71 |
+
st.markdown("# CLIP Playground")
|
72 |
st.markdown("### Try OpenAI's CLIP model in your browser")
|
73 |
st.markdown(" ")
|
74 |
st.markdown(" ")
|
|
|
93 |
"Think of [Hotdog/ Not hotdog](https://www.youtube.com/watch?v=pqTntG1RXSY&ab_channel=tvpromos) without any training. ")
|
94 |
st.markdown(" ")
|
95 |
st.markdown(" ")
|
|
|
|
|
|
|
96 |
|
97 |
@staticmethod
|
98 |
def image_uploader(state: SessionState, accept_multiple_files: bool):
|
|
|
198 |
@staticmethod
|
199 |
def classification_output(state: SessionState):
|
200 |
# Possible way of customize this https://discuss.streamlit.io/t/st-button-in-a-custom-layout/2187/2
|
201 |
+
if st.button("Predict"): # PREDICT π
|
202 |
with st.spinner("Predicting..."):
|
203 |
if isinstance(state.images[0], str):
|
204 |
clip_response = booste.clip(BOOSTE_API_KEY,
|
|
|
241 |
col2.markdown(f"### ")
|
242 |
|
243 |
|
|
|
|
|
244 |
Sections.header()
|
245 |
+
col1, col2 = st.beta_columns([1, 2])
|
246 |
+
col1.markdown(" "); col1.markdown(" ")
|
247 |
+
col1.markdown("#### Task selection")
|
248 |
+
task_name: str = col2.selectbox("", options=["Prompt ranking", "Image ranking", "Image classification"])
|
249 |
+
st.markdown(" "); st.markdown(" ")
|
250 |
+
|
251 |
+
session_state = get_state()
|
252 |
if task_name == "Image classification":
|
253 |
Sections.image_uploader(session_state, accept_multiple_files=False)
|
254 |
if session_state.images is None:
|
|
|
281 |
limit_number_prompts(session_state)
|
282 |
Sections.multiple_images_input_preview(session_state)
|
283 |
Sections.classification_output(session_state)
|
|
|
284 |
|
285 |
+
st.markdown("Created by [@JavierFnts](https://twitter.com/JavierFnts) |"
|
286 |
+
" [How was CLIP playground created?](https://twitter.com/JavierFnts)")
|
287 |
session_state.sync()
|