Spaces:
Sleeping
Sleeping
matanninio
commited on
Commit
·
fbc2291
1
Parent(s):
06f1eeb
moved creation and collection of tasks and models into memmal_demo
Browse files- app.py +2 -54
- mammal_demo/__init__.py +58 -0
app.py
CHANGED
@@ -1,14 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
ModelRegistry,
|
5 |
-
TaskRegistry,
|
6 |
-
)
|
7 |
-
from mammal_demo.dti_task import DtiTask
|
8 |
-
from mammal_demo.ppi_task import PpiTask
|
9 |
-
from mammal_demo.ps_task import PsTask
|
10 |
-
from mammal_demo.tcr_task import TcrTask
|
11 |
-
|
12 |
MAIN_MARKDOWN_TEXT = """
|
13 |
|
14 |
The **[ibm/biomed.omics.bl.sm.ma-ted-458m](https://huggingface.co/models?sort=trending&search=ibm%2Fbiomed.omics.bl)** model family is a biomedical foundation model and its finetuned variants trained on over 2 billion biological samples across multiple modalities, including proteins, small molecules, and single-cell gene data.
|
@@ -20,51 +12,7 @@ The syntax allows for dynamic combinations of tokens and scalars, enabling class
|
|
20 |
This page demonstraits a variety of drug discovery and biomedical tasks for the model family. Select the task to access the specific demos.
|
21 |
"""
|
22 |
|
23 |
-
|
24 |
-
all_tasks = TaskRegistry()
|
25 |
-
all_models = ModelRegistry()
|
26 |
-
|
27 |
-
# first create the required tasks
|
28 |
-
# Note that the tasks need access to the models, as the model to use depends on the state of the widget
|
29 |
-
# we pass the all_models dict and update it when we actualy have the models.
|
30 |
-
|
31 |
-
ppi_task = all_tasks.register_task(PpiTask(model_dict=all_models))
|
32 |
-
tdi_task = all_tasks.register_task(DtiTask(model_dict=all_models))
|
33 |
-
ps_task = all_tasks.register_task(PsTask(model_dict=all_models))
|
34 |
-
tcr_task = all_tasks.register_task(TcrTask(model_dict=all_models))
|
35 |
-
|
36 |
-
# create the model holders. hold the model and the tokenizer, lazy download
|
37 |
-
# note that the list of relevent tasks needs to be stated.
|
38 |
-
all_models.register_model(
|
39 |
-
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.dti_bindingdb_pkd",
|
40 |
-
task_list=[tdi_task],
|
41 |
-
)
|
42 |
-
all_models.register_model(
|
43 |
-
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.dti_bindingdb_pkd_peer",
|
44 |
-
task_list=[tdi_task],
|
45 |
-
)
|
46 |
-
|
47 |
-
all_models.register_model(
|
48 |
-
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.tcr_epitope_bind",
|
49 |
-
task_list=[tcr_task],
|
50 |
-
)
|
51 |
-
all_models.register_model(
|
52 |
-
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.protein_solubility",
|
53 |
-
task_list=[ps_task],
|
54 |
-
)
|
55 |
-
all_models.register_model(
|
56 |
-
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m",
|
57 |
-
task_list=[ppi_task],
|
58 |
-
)
|
59 |
-
all_models.register_model(
|
60 |
-
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_clintox_tox"
|
61 |
-
)
|
62 |
-
all_models.register_model(
|
63 |
-
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_clintox_fda"
|
64 |
-
)
|
65 |
-
all_models.register_model(
|
66 |
-
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_bbbp"
|
67 |
-
)
|
68 |
|
69 |
|
70 |
def create_application():
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
import mammal_demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
MAIN_MARKDOWN_TEXT = """
|
5 |
|
6 |
The **[ibm/biomed.omics.bl.sm.ma-ted-458m](https://huggingface.co/models?sort=trending&search=ibm%2Fbiomed.omics.bl)** model family is a biomedical foundation model and its finetuned variants trained on over 2 billion biological samples across multiple modalities, including proteins, small molecules, and single-cell gene data.
|
|
|
12 |
This page demonstraits a variety of drug discovery and biomedical tasks for the model family. Select the task to access the specific demos.
|
13 |
"""
|
14 |
|
15 |
+
all_tasks, all_models = mammal_demo.tasks_and_models()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
|
18 |
def create_application():
|
mammal_demo/__init__.py
CHANGED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from mammal_demo.demo_framework import (
|
3 |
+
ModelRegistry,
|
4 |
+
TaskRegistry,
|
5 |
+
)
|
6 |
+
from mammal_demo.dti_task import DtiTask
|
7 |
+
from mammal_demo.ppi_task import PpiTask
|
8 |
+
from mammal_demo.ps_task import PsTask
|
9 |
+
from mammal_demo.tcr_task import TcrTask
|
10 |
+
|
11 |
+
|
12 |
+
def tasks_and_models():
|
13 |
+
all_tasks = TaskRegistry()
|
14 |
+
all_models = ModelRegistry()
|
15 |
+
|
16 |
+
# first create the required tasks
|
17 |
+
# Note that the tasks need access to the models, as the model to use depends on the state of the widget
|
18 |
+
# we pass the all_models dict and update it when we actualy have the models.
|
19 |
+
|
20 |
+
ppi_task = all_tasks.register_task(PpiTask(model_dict=all_models))
|
21 |
+
tdi_task = all_tasks.register_task(DtiTask(model_dict=all_models))
|
22 |
+
ps_task = all_tasks.register_task(PsTask(model_dict=all_models))
|
23 |
+
tcr_task = all_tasks.register_task(TcrTask(model_dict=all_models))
|
24 |
+
|
25 |
+
# create the model holders. hold the model and the tokenizer, lazy download
|
26 |
+
# note that the list of relevent tasks needs to be stated.
|
27 |
+
all_models.register_model(
|
28 |
+
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.dti_bindingdb_pkd",
|
29 |
+
task_list=[tdi_task],
|
30 |
+
)
|
31 |
+
all_models.register_model(
|
32 |
+
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.dti_bindingdb_pkd_peer",
|
33 |
+
task_list=[tdi_task],
|
34 |
+
)
|
35 |
+
|
36 |
+
all_models.register_model(
|
37 |
+
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.tcr_epitope_bind",
|
38 |
+
task_list=[tcr_task],
|
39 |
+
)
|
40 |
+
all_models.register_model(
|
41 |
+
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m.protein_solubility",
|
42 |
+
task_list=[ps_task],
|
43 |
+
)
|
44 |
+
all_models.register_model(
|
45 |
+
model_path="ibm/biomed.omics.bl.sm.ma-ted-458m",
|
46 |
+
task_list=[ppi_task],
|
47 |
+
)
|
48 |
+
all_models.register_model(
|
49 |
+
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_clintox_tox"
|
50 |
+
)
|
51 |
+
all_models.register_model(
|
52 |
+
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_clintox_fda"
|
53 |
+
)
|
54 |
+
all_models.register_model(
|
55 |
+
"ibm/biomed.omics.bl.sm.ma-ted-458m.moleculenet_bbbp"
|
56 |
+
)
|
57 |
+
|
58 |
+
return all_tasks,all_models
|