wg25r
commited on
Commit
·
b2ed8f3
1
Parent(s):
b429092
app.py
CHANGED
@@ -20,24 +20,29 @@ This app generates SMILES strings from images of molecules ball-and-stick models
|
|
20 |
""")
|
21 |
col1, col2 = st.columns(2)
|
22 |
gen_strategy = col1.selectbox("Select a generative strategy", ("Beam Search", "Sampling", "Greedy Search"))
|
23 |
-
|
24 |
-
uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
name = cid[0].synonyms[0]
|
36 |
-
col.markdown("## Option {}: {}".format(i + 1, name))
|
37 |
-
m = Chem.MolFromSmiles(smiles)
|
38 |
-
img = Draw.MolToImage(m)
|
39 |
-
col.image(img, use_container_width=False)
|
40 |
-
pubchem_url = "https://pubchem.ncbi.nlm.nih.gov/compound/{}".format(cid[0].cid)
|
41 |
-
col.markdown("[PubChem Link]({})".format(pubchem_url))
|
42 |
-
st.markdown("---")
|
43 |
-
st.markdown("Taken {} seconds".format(round(time.time() - start_time, 2)))
|
|
|
20 |
""")
|
21 |
col1, col2 = st.columns(2)
|
22 |
gen_strategy = col1.selectbox("Select a generative strategy", ("Beam Search", "Sampling", "Greedy Search"))
|
23 |
+
temp = col2.slider("Temperature", 0.0, 2.0, 1.0)
|
24 |
+
uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg", "webp", "heic"])
|
25 |
+
col1, col2 = st.columns(2)
|
26 |
+
col1.checkbox("Use for Model Training", value=True, help="If checked, the image will be reviewed by our team and used for model training. When checked, do not upload any sensitive or personal data.")
|
27 |
+
button = col2.button("Submit")
|
28 |
+
if button:
|
29 |
+
if uploaded_file:
|
30 |
+
start_time = time.time()
|
31 |
+
image = Image.open(uploaded_file)
|
32 |
+
|
33 |
+
options = ["CC(=O)OC1=CC=CC=C1C(=C)C(=O)O", "CC(=O)", "CC(=O)O", "CC(=O)C", "CC(=O)C1=CC=CC=C1"]
|
34 |
+
grid = [st.columns(2) for _ in range(len(options) // 3 + 1)]
|
35 |
+
cols = [col for row in grid for col in row]
|
36 |
|
37 |
+
for i, (smiles, col) in enumerate(zip(options, cols)):
|
38 |
+
cid = pcp.get_compounds(smiles, 'smiles')
|
39 |
+
name = cid[0].synonyms[0]
|
40 |
+
col.markdown("## Option {}: {}".format(i + 1, name))
|
41 |
+
m = Chem.MolFromSmiles(smiles)
|
42 |
+
img = Draw.MolToImage(m)
|
43 |
+
col.image(img, use_container_width=False)
|
44 |
+
pubchem_url = "https://pubchem.ncbi.nlm.nih.gov/compound/{}".format(cid[0].cid)
|
45 |
+
col.markdown("[PubChem]({})".format(pubchem_url))
|
46 |
|
47 |
+
st.markdown("---")
|
48 |
+
st.markdown("Taken {} seconds".format(round(time.time() - start_time, 2)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|