a b/DEMO/web_ui_gradio.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 2,
6
   "metadata": {},
7
   "outputs": [
8
    {
9
     "name": "stdout",
10
     "output_type": "stream",
11
     "text": [
12
      "Dataset already downloaded in the local system...\n",
13
      "Running locally at: http://127.0.0.1:7860/\n",
14
      "Running on External URL: https://37678.gradio.app\n"
15
     ]
16
    },
17
    {
18
     "data": {
19
      "text/html": [
20
       "\n",
21
       "        <iframe\n",
22
       "            width=\"1000\"\n",
23
       "            height=\"500\"\n",
24
       "            src=\"http://127.0.0.1:7860/\"\n",
25
       "            frameborder=\"0\"\n",
26
       "            allowfullscreen\n",
27
       "        ></iframe>\n",
28
       "        "
29
      ],
30
      "text/plain": [
31
       "<IPython.lib.display.IFrame at 0x7fba2f2a2e90>"
32
      ]
33
     },
34
     "metadata": {},
35
     "output_type": "display_data"
36
    },
37
    {
38
     "data": {
39
      "text/plain": [
40
       "(<gradio.networking.serve_files_in_background.<locals>.HTTPServer at 0x7fba2cc15250>,\n",
41
       " 'http://127.0.0.1:7860/',\n",
42
       " 'https://37678.gradio.app')"
43
      ]
44
     },
45
     "execution_count": 2,
46
     "metadata": {},
47
     "output_type": "execute_result"
48
    }
49
   ],
50
   "source": [
51
    "import os\n",
52
    "os.chdir('../')\n",
53
    "from DeepPurpose import utils\n",
54
    "from DeepPurpose import DTI as models\n",
55
    "import gradio\n",
56
    "\n",
57
    "model = models.model_pretrained(model = 'MPNN_CNN_BindingDB')\n",
58
    "\n",
59
    "def DTI_pred(drug, target):\n",
60
    "    X_pred = utils.data_process(X_drug = [drug], X_target = [target], y = [0],\n",
61
    "                                drug_encoding = 'MPNN', target_encoding = 'CNN', \n",
62
    "                                split_method='no_split')\n",
63
    "    y_pred = model.predict(X_pred)\n",
64
    "    return str(y_pred[0])\n",
65
    "\n",
66
    "gradio.Interface(DTI_pred, \n",
67
    "                 [gradio.inputs.Textbox(lines = 5, label = \"Drug SMILES\"),\n",
68
    "                  gradio.inputs.Textbox(lines = 5, label = \"Target Amino Acid Sequence\")], \n",
69
    "                 gradio.outputs.Textbox(label = \"Predicted Affinity\")).launch(share=True)"
70
   ]
71
  },
72
  {
73
   "cell_type": "code",
74
   "execution_count": null,
75
   "metadata": {},
76
   "outputs": [],
77
   "source": []
78
  }
79
 ],
80
 "metadata": {
81
  "kernelspec": {
82
   "display_name": "Python [conda env:DeepPurpose]",
83
   "language": "python",
84
   "name": "conda-env-DeepPurpose-py"
85
  }
86
 },
87
 "nbformat": 4,
88
 "nbformat_minor": 4
89
}