Spaces:
Build error
Build error
reconstruct explainer
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
# python image_gradio.py >> ./logs/image_gradio.log 2>&1
|
| 2 |
import time
|
| 3 |
import pickle
|
|
|
|
| 4 |
import os
|
| 5 |
import gradio as gr
|
| 6 |
import spaces
|
|
@@ -543,11 +544,13 @@ class ExplainerCheckbox(Component):
|
|
| 543 |
# opt_output.explainer.model = self.experiment.model
|
| 544 |
# self.experiment.manager._explainers.append(opt_output.explainer)
|
| 545 |
# self.experiment.manager._explainer_ids.append(opt_exp_id)
|
| 546 |
-
|
| 547 |
opt_res = {
|
| 548 |
'id': opt_exp_id,
|
| 549 |
-
|
|
|
|
| 550 |
}
|
|
|
|
| 551 |
self.groups.insert_check(checkbox_group_info, self.explainer_name, opt_exp_id, opt_postprocessor_id)
|
| 552 |
checkbox = gr.update(label="Optimized Parameter (Optimal)", interactive=True)
|
| 553 |
bttn = gr.update(value="Optimized", variant="secondary")
|
|
@@ -555,9 +558,17 @@ class ExplainerCheckbox(Component):
|
|
| 555 |
return [opt_res, checkbox_group_info, checkbox, bttn]
|
| 556 |
|
| 557 |
def update_exp(exp_res):
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
|
| 562 |
self.bttn.click(optimize, inputs=[self.groups.info], outputs=[self.opt_res, self.groups.info, self.opt_check, self.bttn], queue=True, concurrency_limit=1)
|
| 563 |
self.opt_res.change(update_exp, self.opt_res)
|
|
|
|
| 1 |
# python image_gradio.py >> ./logs/image_gradio.log 2>&1
|
| 2 |
import time
|
| 3 |
import pickle
|
| 4 |
+
import dill
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
|
|
|
| 544 |
# opt_output.explainer.model = self.experiment.model
|
| 545 |
# self.experiment.manager._explainers.append(opt_output.explainer)
|
| 546 |
# self.experiment.manager._explainer_ids.append(opt_exp_id)
|
| 547 |
+
|
| 548 |
opt_res = {
|
| 549 |
'id': opt_exp_id,
|
| 550 |
+
'class': opt_output.explainer.__class__,
|
| 551 |
+
'params' : opt_output.study.best_trial.params,
|
| 552 |
}
|
| 553 |
+
|
| 554 |
self.groups.insert_check(checkbox_group_info, self.explainer_name, opt_exp_id, opt_postprocessor_id)
|
| 555 |
checkbox = gr.update(label="Optimized Parameter (Optimal)", interactive=True)
|
| 556 |
bttn = gr.update(value="Optimized", variant="secondary")
|
|
|
|
| 558 |
return [opt_res, checkbox_group_info, checkbox, bttn]
|
| 559 |
|
| 560 |
def update_exp(exp_res):
|
| 561 |
+
kwargs = {}
|
| 562 |
+
for k,v in exp_res['params'].items():
|
| 563 |
+
if "explainer" in k:
|
| 564 |
+
_key = k.split("explainer.")[1]
|
| 565 |
+
kwargs[_key] = v
|
| 566 |
+
|
| 567 |
+
kwargs['model'] = self.experiment.model
|
| 568 |
+
explainer = exp_res['class'](**kwargs)
|
| 569 |
+
_id = exp_res['id']
|
| 570 |
+
self.experiment.manager._explainers.append(explainer)
|
| 571 |
+
self.experiment.manager._explainer_ids.append(_id)
|
| 572 |
|
| 573 |
self.bttn.click(optimize, inputs=[self.groups.info], outputs=[self.opt_res, self.groups.info, self.opt_check, self.bttn], queue=True, concurrency_limit=1)
|
| 574 |
self.opt_res.change(update_exp, self.opt_res)
|