Spaces:
Sleeping
Sleeping
finish main
Browse files- CHO.pkl +0 -0
- app.py +21 -3
- requirements.txt +5 -0
CHO.pkl
ADDED
Binary file (869 kB). View file
|
|
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from rdkit import Chem
|
4 |
+
from rdkit.Chem import AllChem
|
5 |
+
import joblib
|
6 |
|
7 |
+
model = joblib.load('CHO.pkl')
|
|
|
8 |
|
9 |
+
def predict(smiles):
|
10 |
+
if smiles.strip() == "":
|
11 |
+
raise gr.Error("SMILES input error")
|
12 |
+
|
13 |
+
mol = Chem.MolFromSmiles(smiles)
|
14 |
+
if mol == None:
|
15 |
+
raise gr.Error("SMILES input error")
|
16 |
+
mol_ECFP4 = list(AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=1024).ToBitString())
|
17 |
+
preprocess_data = pd.DataFrame([mol_ECFP4])
|
18 |
+
result = model.predict(preprocess_data)
|
19 |
+
postprocess_data = '{:.2e}'.format(pow(10, result[0]))
|
20 |
+
return postprocess_data
|
21 |
+
|
22 |
+
iface = gr.Interface(fn=predict, inputs=gr.Textbox(lines=2, label="Chemical substance SMILES"),
|
23 |
+
outputs=gr.Textbox(lines=1, label="Cytotoxicity of disinfection byproducts in CHO cells",info="Unit of measurement: molar concentration"),
|
24 |
+
examples=[["O=C(O)CBr"],["O=CC(Br)(Br)Br"],["IC(Br)Br"]],allow_flagging="never")
|
25 |
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.36.1
|
2 |
+
joblib==1.3.1
|
3 |
+
pandas==2.0.3
|
4 |
+
rdkit==2023.3.2
|
5 |
+
sklearn==0.0.post5
|