Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -144,22 +144,22 @@ if st.button('predict'):
|
|
144 |
output.append(None)
|
145 |
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
144 |
output.append(None)
|
145 |
|
146 |
|
147 |
+
if CFG.num_beams > 1:
|
148 |
+
output_df = pd.DataFrame(np.array(output).reshape(1, -1), columns=['input'] + [f'{i}th' for i in range(CFG.num_beams)] + ['valid compound'] + [f'{i}th score' for i in range(CFG.num_beams)] + ['valid compound score'])
|
149 |
+
else:
|
150 |
+
output_df = pd.DataFrame(np.array([input_compound]+output).reshape(1, -1), columns=['input', '0th', 'valid compound'])
|
151 |
+
st.table(output_df)
|
152 |
+
|
153 |
+
@st.cache
|
154 |
+
def convert_df(df):
|
155 |
+
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
156 |
+
return df.to_csv(index=False)
|
157 |
+
|
158 |
+
csv = convert_df(output_df)
|
159 |
+
|
160 |
+
st.download_button(
|
161 |
+
label="Download data as CSV",
|
162 |
+
data=csv,
|
163 |
+
file_name='output.csv',
|
164 |
+
mime='text/csv',
|
165 |
+
)
|