Spaces:
Runtime error
Runtime error
Javi
commited on
Commit
·
d0950d8
1
Parent(s):
5359e07
UX and content improvements
Browse files- streamlit_app.py +20 -9
streamlit_app.py
CHANGED
@@ -112,14 +112,12 @@ class Sections:
|
|
112 |
col2.image("https://openaiassets.blob.core.windows.net/$web/clip/draft/20210104b/overview-b.svg")
|
113 |
with st.beta_expander("What can CLIP do?"):
|
114 |
st.markdown("#### Prompt ranking")
|
115 |
-
st.markdown("Given different prompts and an image
|
116 |
-
" with what the image represents")
|
117 |
st.markdown("#### Image ranking")
|
118 |
-
st.markdown("Given different images and a prompt
|
119 |
-
" with what the prompt expresses")
|
120 |
st.markdown("#### Image classification")
|
121 |
-
st.markdown("Similar to prompt ranking, given a set of classes
|
122 |
-
"Think of [Hotdog/ Not hotdog](https://www.youtube.com/watch?v=pqTntG1RXSY&ab_channel=tvpromos) without any training.
|
123 |
st.markdown(" ")
|
124 |
st.markdown(" ")
|
125 |
|
@@ -176,10 +174,11 @@ class Sections:
|
|
176 |
|
177 |
@staticmethod
|
178 |
def prompts_input(state: SessionState, input_label: str, prompt_prefix: str = ''):
|
179 |
-
|
180 |
value=state.default_text_input if state.default_text_input is not None else "")
|
181 |
-
|
182 |
-
|
|
|
183 |
|
184 |
@staticmethod
|
185 |
def single_image_input_preview(state: SessionState):
|
@@ -270,6 +269,18 @@ class Sections:
|
|
270 |
col1.image(image, use_column_width=True)
|
271 |
percentage_prob = int(probability * 100)
|
272 |
col2.markdown(f"### ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
|
274 |
|
275 |
Sections.header()
|
|
|
112 |
col2.image("https://openaiassets.blob.core.windows.net/$web/clip/draft/20210104b/overview-b.svg")
|
113 |
with st.beta_expander("What can CLIP do?"):
|
114 |
st.markdown("#### Prompt ranking")
|
115 |
+
st.markdown("Given different prompts and an image CLIP will rank the different prompts based on how well they describe the image")
|
|
|
116 |
st.markdown("#### Image ranking")
|
117 |
+
st.markdown("Given different images and a prompt CLIP will rank the different images based on how well they fit the description")
|
|
|
118 |
st.markdown("#### Image classification")
|
119 |
+
st.markdown("Similar to prompt ranking, given a set of classes CLIP can classify an image between them. "
|
120 |
+
"Think of [Hotdog/ Not hotdog](https://www.youtube.com/watch?v=pqTntG1RXSY&ab_channel=tvpromos) without any training.")
|
121 |
st.markdown(" ")
|
122 |
st.markdown(" ")
|
123 |
|
|
|
174 |
|
175 |
@staticmethod
|
176 |
def prompts_input(state: SessionState, input_label: str, prompt_prefix: str = ''):
|
177 |
+
raw_text_input = st.text_input(input_label,
|
178 |
value=state.default_text_input if state.default_text_input is not None else "")
|
179 |
+
state.is_default_text_input = raw_text_input == state.default_text_input
|
180 |
+
if raw_text_input:
|
181 |
+
state.prompts = [prompt_prefix + class_name for class_name in raw_text_input.split(";") if len(class_name) > 1]
|
182 |
|
183 |
@staticmethod
|
184 |
def single_image_input_preview(state: SessionState):
|
|
|
269 |
col1.image(image, use_column_width=True)
|
270 |
percentage_prob = int(probability * 100)
|
271 |
col2.markdown(f"### ")
|
272 |
+
is_default_image = isinstance(state.images[0], str)
|
273 |
+
is_default_prediction = is_default_image and state.is_default_text_input
|
274 |
+
if is_default_prediction:
|
275 |
+
st.markdown("<br>:information_source: Try writing your own prompts and using your own pictures!",
|
276 |
+
unsafe_allow_html=True)
|
277 |
+
elif is_default_image:
|
278 |
+
st.markdown("<br>:information_source: You can also use your own pictures!",
|
279 |
+
unsafe_allow_html=True)
|
280 |
+
elif state.is_default_text_input:
|
281 |
+
st.markdown("<br>:information_source: Try writing your own prompts!"
|
282 |
+
" It can be whatever you can think of",
|
283 |
+
unsafe_allow_html=True)
|
284 |
|
285 |
|
286 |
Sections.header()
|