wg25r
commited on
Commit
·
a2d5af5
1
Parent(s):
37b5b33
from library
Browse files- __pycache__/lib.cpython-311.pyc +0 -0
- app.py +24 -2
- lib.py +6 -0
__pycache__/lib.cpython-311.pyc
ADDED
Binary file (1.41 kB). View file
|
|
app.py
CHANGED
@@ -5,6 +5,21 @@ import pubchempy as pcp
|
|
5 |
from rdkit import Chem
|
6 |
from rdkit.Chem import Draw
|
7 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
st.title("3D2SMILES")
|
10 |
st.markdown("""
|
@@ -26,9 +41,16 @@ uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg",
|
|
26 |
lib = st.columns(2)
|
27 |
lib[0].markdown("Do not have an image? You can select a molecule from the library below.")
|
28 |
from_library = lib[1].button("Select from Library")
|
|
|
|
|
29 |
|
30 |
col1, col2 = st.columns(2)
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
button = col2.button("Submit")
|
33 |
if button:
|
34 |
if uploaded_file:
|
@@ -42,7 +64,7 @@ if button:
|
|
42 |
for i, (smiles, col) in enumerate(zip(options, cols)):
|
43 |
cid = pcp.get_compounds(smiles, 'smiles')
|
44 |
name = cid[0].synonyms[0]
|
45 |
-
col.markdown(
|
46 |
m = Chem.MolFromSmiles(smiles)
|
47 |
img = Draw.MolToImage(m)
|
48 |
col.image(img, use_container_width=False)
|
|
|
5 |
from rdkit import Chem
|
6 |
from rdkit.Chem import Draw
|
7 |
import time
|
8 |
+
import os
|
9 |
+
import random
|
10 |
+
|
11 |
+
@st.dialog("Select From Library")
|
12 |
+
def lib_modal():
|
13 |
+
files = os.listdir("lib")
|
14 |
+
files = random.choices(files, k=50)
|
15 |
+
cols = st.columns(2)
|
16 |
+
for i, file in enumerate(files):
|
17 |
+
with cols[i % 2]:
|
18 |
+
st.image("lib/{}".format(file), use_container_width=True)
|
19 |
+
if st.button("Select", key=i):
|
20 |
+
st.session_state.uploaded_file = file
|
21 |
+
st.rerun()
|
22 |
+
st.markdown("---")
|
23 |
|
24 |
st.title("3D2SMILES")
|
25 |
st.markdown("""
|
|
|
41 |
lib = st.columns(2)
|
42 |
lib[0].markdown("Do not have an image? You can select a molecule from the library below.")
|
43 |
from_library = lib[1].button("Select from Library")
|
44 |
+
if from_library:
|
45 |
+
lib_modal()
|
46 |
|
47 |
col1, col2 = st.columns(2)
|
48 |
+
if not "uploaded_file" in st.session_state:
|
49 |
+
col1.checkbox("Contribute To Public Library", value=True, help="If checked, images will be included in the PUBLIC library, and the image will be reviewed by our team and used for model training. When checked, do not upload any sensitive or personal data.")
|
50 |
+
else:
|
51 |
+
col1.checkbox("Contribute To Public Library", value=False, disabled=True, help="When using the library, this option is disabled. If you want to contribute to the library, please upload an image.")
|
52 |
+
|
53 |
+
|
54 |
button = col2.button("Submit")
|
55 |
if button:
|
56 |
if uploaded_file:
|
|
|
64 |
for i, (smiles, col) in enumerate(zip(options, cols)):
|
65 |
cid = pcp.get_compounds(smiles, 'smiles')
|
66 |
name = cid[0].synonyms[0]
|
67 |
+
col.markdown(name)
|
68 |
m = Chem.MolFromSmiles(smiles)
|
69 |
img = Draw.MolToImage(m)
|
70 |
col.image(img, use_container_width=False)
|
lib.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
|
5 |
+
|
6 |
+
|