Spaces:
Runtime error
Runtime error
gchhablani
commited on
Commit
•
bbf274a
1
Parent(s):
1a320a6
Update app layout
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ if state.model is None:
|
|
91 |
with st.spinner("Loading model..."):
|
92 |
state.model = load_model(checkpoints[0])
|
93 |
|
94 |
-
first_index =
|
95 |
# Init Session State
|
96 |
if state.image_file is None:
|
97 |
state.image_file = dummy_data.loc[first_index, "image_file"]
|
@@ -103,7 +103,7 @@ if state.image_file is None:
|
|
103 |
|
104 |
new_col1, new_col2 = st.beta_columns([5,5])
|
105 |
|
106 |
-
if
|
107 |
sample = dummy_data.sample(1).reset_index()
|
108 |
state.image_file = sample.loc[0, "image_file"]
|
109 |
state.caption = sample.loc[0, "caption"].strip("- ")
|
@@ -117,10 +117,11 @@ transformed_image = get_transformed_image(state.image)
|
|
117 |
new_col1.image(state.image, use_column_width="always")
|
118 |
|
119 |
# Display Reference Caption
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
)
|
|
|
124 |
|
125 |
|
126 |
sequence = ['']
|
@@ -130,10 +131,10 @@ if new_col2.button("Generate Caption", help="Generate a caption in the specified
|
|
130 |
# print(sequence)
|
131 |
|
132 |
if sequence!=['']:
|
133 |
-
|
134 |
"**Generated Caption**: "+sequence[0]
|
135 |
)
|
136 |
|
137 |
-
|
138 |
"**English Translation**: "+ translate(sequence[0])
|
139 |
)
|
|
|
91 |
with st.spinner("Loading model..."):
|
92 |
state.model = load_model(checkpoints[0])
|
93 |
|
94 |
+
first_index = 30
|
95 |
# Init Session State
|
96 |
if state.image_file is None:
|
97 |
state.image_file = dummy_data.loc[first_index, "image_file"]
|
|
|
103 |
|
104 |
new_col1, new_col2 = st.beta_columns([5,5])
|
105 |
|
106 |
+
if new_col1.button("Get a random example", help="Get a random example from one of the seeded examples."):
|
107 |
sample = dummy_data.sample(1).reset_index()
|
108 |
state.image_file = sample.loc[0, "image_file"]
|
109 |
state.caption = sample.loc[0, "caption"].strip("- ")
|
|
|
117 |
new_col1.image(state.image, use_column_width="always")
|
118 |
|
119 |
# Display Reference Caption
|
120 |
+
with new_col1.beta_expander("Reference Caption"):
|
121 |
+
st.write("**Reference Caption**: " + state.caption)
|
122 |
+
st.markdown(
|
123 |
+
f"""**English Translation**: {translate(state.caption, 'en')}"""
|
124 |
+
)
|
125 |
|
126 |
|
127 |
sequence = ['']
|
|
|
131 |
# print(sequence)
|
132 |
|
133 |
if sequence!=['']:
|
134 |
+
new_col2.write(
|
135 |
"**Generated Caption**: "+sequence[0]
|
136 |
)
|
137 |
|
138 |
+
new_col2.write(
|
139 |
"**English Translation**: "+ translate(sequence[0])
|
140 |
)
|