Spaces:
Sleeping
Sleeping
Remove duplicate inputs & fix CSV upload path
Browse files
app.py
CHANGED
@@ -56,24 +56,27 @@ This app predicts the HOMO-LUMO energy gap for molecules using a trained Graph N
|
|
56 |
- The app will display predictions and molecule images (up to 10 shown at once).
|
57 |
""")
|
58 |
|
59 |
-
# Text Input
|
60 |
-
smiles_input = st.text_area("Enter SMILES string(s)", placeholder="C1=CC=CC=C1, CC(=O)Oc1ccccc1C(=O)O")
|
61 |
|
62 |
-
# File Upload
|
63 |
-
uploaded_file = st.file_uploader("...or upload a CSV file", type=["csv"])
|
64 |
|
65 |
-
smiles_list = []
|
66 |
|
67 |
with st.form("input_form"):
|
68 |
-
smiles_input = st.text_area(
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# Process only after the user presses the button
|
73 |
if run_button:
|
74 |
# CSV path
|
75 |
if uploaded_file is not None:
|
76 |
try:
|
|
|
77 |
data = uploaded_file.getvalue() # read bytes
|
78 |
df = pd.read_csv(StringIO(data.decode("utf-8")), comment="#")
|
79 |
|
@@ -83,7 +86,8 @@ if run_button:
|
|
83 |
elif "smiles" in [c.lower() for c in df.columns]:
|
84 |
smiles_col = df[[c for c in df.columns if c.lower() == "smiles"][0]]
|
85 |
else:
|
86 |
-
st.error("CSV must have a single column or a column named 'SMILES'"
|
|
|
87 |
smiles_col = None
|
88 |
|
89 |
if smiles_col is not None:
|
|
|
56 |
- The app will display predictions and molecule images (up to 10 shown at once).
|
57 |
""")
|
58 |
|
|
|
|
|
59 |
|
|
|
|
|
60 |
|
|
|
61 |
|
62 |
with st.form("input_form"):
|
63 |
+
smiles_input = st.text_area(
|
64 |
+
"Enter SMILES string(s)",
|
65 |
+
placeholder="C1=CC=CC=C1, CC(=O)Oc1ccccc1C(=O)O",
|
66 |
+
height=120
|
67 |
+
)
|
68 |
+
uploaded_file = st.file_uploader(
|
69 |
+
"…or upload a CSV file",
|
70 |
+
type=["csv"]
|
71 |
+
)
|
72 |
+
run_button = st.form_submit_button("Submit")
|
73 |
|
74 |
# Process only after the user presses the button
|
75 |
if run_button:
|
76 |
# CSV path
|
77 |
if uploaded_file is not None:
|
78 |
try:
|
79 |
+
uploaded_file.seek(0)
|
80 |
data = uploaded_file.getvalue() # read bytes
|
81 |
df = pd.read_csv(StringIO(data.decode("utf-8")), comment="#")
|
82 |
|
|
|
86 |
elif "smiles" in [c.lower() for c in df.columns]:
|
87 |
smiles_col = df[[c for c in df.columns if c.lower() == "smiles"][0]]
|
88 |
else:
|
89 |
+
st.error("CSV must have a single column or a column named 'SMILES'"
|
90 |
+
f"Found columns: {', '.join(df.columns)}")
|
91 |
smiles_col = None
|
92 |
|
93 |
if smiles_col is not None:
|