Spaces:
Build error
Build error
Commit
·
4baa3a3
1
Parent(s):
094450f
Update app.py
Browse files
app.py
CHANGED
@@ -112,7 +112,7 @@ def predictor(texts):
|
|
112 |
|
113 |
def lime_explain(code_txt):
|
114 |
class_names = ['Without OpenMP', 'With OpenMP']
|
115 |
-
SAMPLES =
|
116 |
exp = []
|
117 |
|
118 |
if predict(code_txt)[0] == without_omp_str:
|
@@ -124,6 +124,13 @@ def lime_explain(code_txt):
|
|
124 |
return gr.update(visible=True, value=exp.as_pyplot_figure())
|
125 |
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
def activate_c(lang_pred):
|
128 |
langs = lang_pred.split('\n')
|
129 |
langs = {lang[5:lang.find(':')]:float(lang[lang.find(':')+1:]) for lang in langs}
|
@@ -198,6 +205,7 @@ with gr.Blocks() as pragformer_gui:
|
|
198 |
private = gr.Textbox(label="Data-sharing attribute clause- private", visible=False)
|
199 |
reduction = gr.Textbox(label="Data-sharing attribute clause- reduction", visible=False)
|
200 |
|
|
|
201 |
explanation = gr.Plot(visible=False)
|
202 |
|
203 |
|
@@ -209,6 +217,7 @@ with gr.Blocks() as pragformer_gui:
|
|
209 |
submit_btn.click(fn=is_private, inputs=code_in, outputs=private)
|
210 |
submit_btn.click(fn=is_reduction, inputs=code_in, outputs=reduction)
|
211 |
submit_btn.click(fn=lime_explain, inputs=code_in, outputs=explanation)
|
|
|
212 |
sample_btn.click(fn=fill_code, inputs=drop, outputs=[pragma, code_in])
|
213 |
|
214 |
gr.Markdown(
|
|
|
112 |
|
113 |
def lime_explain(code_txt):
|
114 |
class_names = ['Without OpenMP', 'With OpenMP']
|
115 |
+
SAMPLES = 35
|
116 |
exp = []
|
117 |
|
118 |
if predict(code_txt)[0] == without_omp_str:
|
|
|
124 |
return gr.update(visible=True, value=exp.as_pyplot_figure())
|
125 |
|
126 |
|
127 |
+
def lime_title(code_txt):
|
128 |
+
if predict(code_txt)[0] == without_omp_str:
|
129 |
+
return gr.update(visible=False)
|
130 |
+
|
131 |
+
return gr.update(visible=True)
|
132 |
+
|
133 |
+
|
134 |
def activate_c(lang_pred):
|
135 |
langs = lang_pred.split('\n')
|
136 |
langs = {lang[5:lang.find(':')]:float(lang[lang.find(':')+1:]) for lang in langs}
|
|
|
205 |
private = gr.Textbox(label="Data-sharing attribute clause- private", visible=False)
|
206 |
reduction = gr.Textbox(label="Data-sharing attribute clause- reduction", visible=False)
|
207 |
|
208 |
+
explain_title = gr.Markdown("## LIME Explainability", visible=False)
|
209 |
explanation = gr.Plot(visible=False)
|
210 |
|
211 |
|
|
|
217 |
submit_btn.click(fn=is_private, inputs=code_in, outputs=private)
|
218 |
submit_btn.click(fn=is_reduction, inputs=code_in, outputs=reduction)
|
219 |
submit_btn.click(fn=lime_explain, inputs=code_in, outputs=explanation)
|
220 |
+
submit_btn.click(fn=lime_title, inputs=code_in, outputs=explain_title)
|
221 |
sample_btn.click(fn=fill_code, inputs=drop, outputs=[pragma, code_in])
|
222 |
|
223 |
gr.Markdown(
|