Spaces:
Runtime error
Runtime error
gchhablani
commited on
Commit
•
652973c
1
Parent(s):
d74c94a
Change layout
Browse files
app.py
CHANGED
@@ -120,7 +120,7 @@ if state.image_file is None:
|
|
120 |
new_col1, new_col2 = st.beta_columns([5,5])
|
121 |
|
122 |
|
123 |
-
if
|
124 |
sample = dummy_data.sample(1).reset_index()
|
125 |
state.image_file = sample.loc[0, "image_file"]
|
126 |
state.caption = sample.loc[0, "caption"].strip("- ")
|
@@ -135,10 +135,11 @@ transformed_image = get_transformed_image(state.image)
|
|
135 |
# Display Image
|
136 |
new_col1.image(state.image, use_column_width="always")
|
137 |
# Display Reference Caption
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
)
|
|
|
142 |
|
143 |
# Select Language
|
144 |
options = list(code_to_name.keys())
|
@@ -157,10 +158,10 @@ if new_col2.button("Generate Caption", help="Generate a caption in the specified
|
|
157 |
# print(sequence)
|
158 |
|
159 |
if sequence!=['']:
|
160 |
-
|
161 |
"**Generated Caption**: "+sequence[0]
|
162 |
)
|
163 |
|
164 |
-
|
165 |
"**English Translation**: "+ sequence[0] if lang_id=="en" else translate(sequence[0])
|
166 |
)
|
|
|
120 |
new_col1, new_col2 = st.beta_columns([5,5])
|
121 |
|
122 |
|
123 |
+
if new_col1.button("Get a random example", help="Get a random example from one of the seeded examples."):
|
124 |
sample = dummy_data.sample(1).reset_index()
|
125 |
state.image_file = sample.loc[0, "image_file"]
|
126 |
state.caption = sample.loc[0, "caption"].strip("- ")
|
|
|
135 |
# Display Image
|
136 |
new_col1.image(state.image, use_column_width="always")
|
137 |
# Display Reference Caption
|
138 |
+
with new_col1.beta_expander("Reference Caption"):
|
139 |
+
st.write("**Reference Caption**: " + state.caption)
|
140 |
+
st.markdown(
|
141 |
+
f"""**English Translation**: {state.caption if state.lang_id == "en" else translate(state.caption, 'en')}"""
|
142 |
+
)
|
143 |
|
144 |
# Select Language
|
145 |
options = list(code_to_name.keys())
|
|
|
158 |
# print(sequence)
|
159 |
|
160 |
if sequence!=['']:
|
161 |
+
new_col2.write(
|
162 |
"**Generated Caption**: "+sequence[0]
|
163 |
)
|
164 |
|
165 |
+
new_col2.write(
|
166 |
"**English Translation**: "+ sequence[0] if lang_id=="en" else translate(sequence[0])
|
167 |
)
|