Spaces:
Sleeping
Sleeping
Delete deepscreen/gui
Browse files- deepscreen/gui/__init__.py +0 -0
- deepscreen/gui/test.py +0 -114
deepscreen/gui/__init__.py
DELETED
File without changes
|
deepscreen/gui/test.py
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
from pathlib import Path
|
2 |
-
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
-
# Use this in a notebook
|
6 |
-
root = Path.cwd()
|
7 |
-
|
8 |
-
|
9 |
-
drug_encoder_list = [f.stem for f in root.parent.joinpath("configs/model/drug_encoder").iterdir() if f.suffix == ".yaml"]
|
10 |
-
|
11 |
-
drug_featurizer_list = [f.stem for f in root.parent.joinpath("configs/model/drug_featurizer").iterdir() if f.suffix == ".yaml"]
|
12 |
-
|
13 |
-
protein_encoder_list = [f.stem for f in root.parent.joinpath("configs/model/protein_encoder").iterdir() if f.suffix == ".yaml"]
|
14 |
-
|
15 |
-
protein_featurizer_list = [f.stem for f in root.parent.joinpath("configs/model/protein_featurizer").iterdir() if f.suffix == ".yaml"]
|
16 |
-
|
17 |
-
classifier_list = [f.stem for f in root.parent.joinpath("configs/model/classifier").iterdir() if f.suffix == ".yaml"]
|
18 |
-
|
19 |
-
preset_list = [f.stem for f in root.parent.joinpath("configs/model/preset").iterdir() if f.suffix == ".yaml"]
|
20 |
-
|
21 |
-
|
22 |
-
from typing import Optional
|
23 |
-
|
24 |
-
def drug_target_interaction(
|
25 |
-
binary: bool,
|
26 |
-
drug_encoder,
|
27 |
-
drug_featurizer,
|
28 |
-
protein_encoder,
|
29 |
-
protein_featurizer,
|
30 |
-
classifier,
|
31 |
-
preset,) -> Optional[float]:
|
32 |
-
|
33 |
-
|
34 |
-
return 1
|
35 |
-
|
36 |
-
def drug_encoder(
|
37 |
-
binary: bool,
|
38 |
-
drug_encoder,
|
39 |
-
drug_featurizer,
|
40 |
-
protein_encoder,
|
41 |
-
protein_featurizer,
|
42 |
-
classifier,
|
43 |
-
preset,):
|
44 |
-
|
45 |
-
return
|
46 |
-
|
47 |
-
def protein_encoder(
|
48 |
-
binary: bool,
|
49 |
-
drug_encoder,
|
50 |
-
drug_featurizer,
|
51 |
-
protein_encoder,
|
52 |
-
protein_featurizer,
|
53 |
-
classifier,
|
54 |
-
preset,):
|
55 |
-
|
56 |
-
return
|
57 |
-
|
58 |
-
# demo = gr.Interface(
|
59 |
-
# fn=drug_target_interaction,
|
60 |
-
# inputs=[
|
61 |
-
# gr.Radio(["True", "False"]),
|
62 |
-
# gr.Dropdown(drug_encoder_list),
|
63 |
-
# gr.Dropdown(drug_featurizer_list),
|
64 |
-
# gr.Dropdown(protein_encoder_list),
|
65 |
-
# gr.Dropdown(protein_featurizer_list),
|
66 |
-
# gr.Dropdown(classifier_list),
|
67 |
-
# gr.Dropdown(preset_list),
|
68 |
-
# ],
|
69 |
-
# outputs=["number"],
|
70 |
-
# show_error=True,
|
71 |
-
#
|
72 |
-
# )
|
73 |
-
#
|
74 |
-
# demo.launch()
|
75 |
-
|
76 |
-
|
77 |
-
from omegaconf import DictConfig, OmegaConf
|
78 |
-
|
79 |
-
type_to_component_map = {list: gr.Text, int: gr.Number, float: gr.Number}
|
80 |
-
|
81 |
-
|
82 |
-
def get_config_choices(config_path: str):
|
83 |
-
return [f.stem for f in Path("../../configs/", config_path).iterdir() if f.suffix == ".yaml"]
|
84 |
-
|
85 |
-
|
86 |
-
def create_blocks_from_config(cfg: DictConfig):
|
87 |
-
with gr.Blocks() as blocks:
|
88 |
-
for key, value in cfg.items():
|
89 |
-
if type(value) in [int, float]:
|
90 |
-
component = gr.Number(value=value, label=key, interactive=True)
|
91 |
-
if type(value) in [dict, DictConfig]:
|
92 |
-
with gr.Tab(label=key):
|
93 |
-
component = create_blocks_from_config(value)
|
94 |
-
else:
|
95 |
-
component = gr.Text(value=value, label=key, interactive=True)
|
96 |
-
return blocks
|
97 |
-
|
98 |
-
|
99 |
-
def create_interface_from_config(fn: callable, cfg: DictConfig):
|
100 |
-
inputs = []
|
101 |
-
|
102 |
-
for key, value in OmegaConf.to_object(cfg).items():
|
103 |
-
component = type_to_component_map.get(type(value), gr.Text)
|
104 |
-
inputs.append(component(value=value, label=key, interactive=True))
|
105 |
-
|
106 |
-
interface = gr.Interface(fn=fn, inputs=inputs, outputs="label")
|
107 |
-
|
108 |
-
return interface
|
109 |
-
|
110 |
-
|
111 |
-
import hydra
|
112 |
-
|
113 |
-
with hydra.initialize(version_base=None, config_path="../../configs/"):
|
114 |
-
cfg = hydra.compose("train")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|