Edward J. Schwartz
commited on
Commit
·
1f9e351
1
Parent(s):
93d9f40
class
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import transformers
|
|
10 |
import numpy
|
11 |
print(numpy.__version__)
|
12 |
|
13 |
-
pipe = transformers.pipeline(model="ejschwartz/oo-method-test-model-bylibrary",
|
14 |
|
15 |
# gr.load("ejschwartz/oo-method-test-model-bylibrary", src="models", examples=[
|
16 |
# '\nL1: 55 ?? push ebp\n 8b ec ?? mov ebp, esp\n 5d ?? pop ebp\n c3 ?? ret\n\n',
|
@@ -80,7 +80,7 @@ with gr.Blocks() as demo:
|
|
80 |
fun_dropdown = gr.Dropdown(label="Select a function", choices=["Woohoo!"], interactive=True)
|
81 |
|
82 |
with gr.Row(visible=True) as result:
|
83 |
-
disassembly = gr.Textbox(label="Disassembly", lines=20
|
84 |
clazz = gr.Label()
|
85 |
|
86 |
def file_change_fn(file):
|
@@ -104,15 +104,16 @@ with gr.Blocks() as demo:
|
|
104 |
|
105 |
disassembly_str = fun_data[int(selected_fun, 16)].decode("utf-8")
|
106 |
model_results = pipe(disassembly_str)
|
107 |
-
|
|
|
108 |
|
109 |
return {disassembly: gr.Textbox.update(value=disassembly_str),
|
110 |
-
|
111 |
#clazz: gr.Label.update(value="Method" if model_results[0]["label"] == "method" else "Function")}
|
112 |
}
|
113 |
|
114 |
file_widget.change(file_change_fn, file_widget, [col, fun_dropdown, all_dis_state])
|
115 |
|
116 |
-
fun_dropdown.change(function_change_fn, [fun_dropdown, all_dis_state], [disassembly])
|
117 |
|
118 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
10 |
import numpy
|
11 |
print(numpy.__version__)
|
12 |
|
13 |
+
pipe = transformers.pipeline(model="ejschwartz/oo-method-test-model-bylibrary", top_k=2)
|
14 |
|
15 |
# gr.load("ejschwartz/oo-method-test-model-bylibrary", src="models", examples=[
|
16 |
# '\nL1: 55 ?? push ebp\n 8b ec ?? mov ebp, esp\n 5d ?? pop ebp\n c3 ?? ret\n\n',
|
|
|
80 |
fun_dropdown = gr.Dropdown(label="Select a function", choices=["Woohoo!"], interactive=True)
|
81 |
|
82 |
with gr.Row(visible=True) as result:
|
83 |
+
disassembly = gr.Textbox(label="Disassembly", lines=20)
|
84 |
clazz = gr.Label()
|
85 |
|
86 |
def file_change_fn(file):
|
|
|
104 |
|
105 |
disassembly_str = fun_data[int(selected_fun, 16)].decode("utf-8")
|
106 |
model_results = pipe(disassembly_str)
|
107 |
+
top_k = {i["label"].split(", ")[0]: i["score"] for i in model_results}
|
108 |
+
#disassembly_str = str(model_results)
|
109 |
|
110 |
return {disassembly: gr.Textbox.update(value=disassembly_str),
|
111 |
+
clazz: gr.Label.update(top_k)
|
112 |
#clazz: gr.Label.update(value="Method" if model_results[0]["label"] == "method" else "Function")}
|
113 |
}
|
114 |
|
115 |
file_widget.change(file_change_fn, file_widget, [col, fun_dropdown, all_dis_state])
|
116 |
|
117 |
+
fun_dropdown.change(function_change_fn, [fun_dropdown, all_dis_state], [disassembly, clazz])
|
118 |
|
119 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|