Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,6 @@ examples = [
|
|
18 |
char *v11; // r13
|
19 |
char *v12; // rax
|
20 |
char v13[42]; // [rsp+Eh] [rbp-2Ah] BYREF
|
21 |
-
|
22 |
v5 = (unsigned int)(a1 - 1);
|
23 |
v6 = status;
|
24 |
if ( (unsigned int)v5 <= 3 )
|
@@ -48,10 +47,9 @@ examples = [
|
|
48 |
def predict_summary(code):
|
49 |
global model
|
50 |
global tokenizer
|
51 |
-
input = tokenizer('summarize: '+code,return_tensors='pt',max_length=max_input_length,truncation=True)
|
52 |
-
output = model.generate(**input,max_new_tokens=256)[0]
|
53 |
-
return tokenizer.decode(output,skip_special_tokens=True)
|
54 |
-
|
55 |
|
56 |
# predict identifier (func name)
|
57 |
def predict_identifier(code):
|
@@ -60,20 +58,35 @@ def predict_identifier(code):
|
|
60 |
'''
|
61 |
code should be like: "unsigned __int8 *__cdecl <func>(int *<var_0>,...){ return <func_1>(1);}"
|
62 |
'''
|
63 |
-
input = tokenizer('identifier_predict: '+code,return_tensors='pt',max_length=max_input_length,truncation=True)
|
64 |
output = model.generate(**input)[0]
|
65 |
return tokenizer.decode(output)
|
66 |
|
67 |
-
# Create the Gradio interface
|
68 |
-
|
69 |
fn=predict_identifier,
|
70 |
inputs="text",
|
71 |
outputs="text",
|
72 |
-
title="Predict
|
73 |
-
description="Enter a
|
74 |
examples=examples
|
75 |
)
|
76 |
|
77 |
-
#
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
char *v11; // r13
|
19 |
char *v12; // rax
|
20 |
char v13[42]; // [rsp+Eh] [rbp-2Ah] BYREF
|
|
|
21 |
v5 = (unsigned int)(a1 - 1);
|
22 |
v6 = status;
|
23 |
if ( (unsigned int)v5 <= 3 )
|
|
|
47 |
def predict_summary(code):
|
48 |
global model
|
49 |
global tokenizer
|
50 |
+
input = tokenizer('summarize: '+code, return_tensors='pt', max_length=max_input_length, truncation=True)
|
51 |
+
output = model.generate(**input, max_new_tokens=256)[0]
|
52 |
+
return tokenizer.decode(output, skip_special_tokens=True)
|
|
|
53 |
|
54 |
# predict identifier (func name)
|
55 |
def predict_identifier(code):
|
|
|
58 |
'''
|
59 |
code should be like: "unsigned __int8 *__cdecl <func>(int *<var_0>,...){ return <func_1>(1);}"
|
60 |
'''
|
61 |
+
input = tokenizer('identifier_predict: '+code, return_tensors='pt', max_length=max_input_length, truncation=True)
|
62 |
output = model.generate(**input)[0]
|
63 |
return tokenizer.decode(output)
|
64 |
|
65 |
+
# Create the Gradio interface for predicting identifiers
|
66 |
+
identifier_iface = gr.Interface(
|
67 |
fn=predict_identifier,
|
68 |
inputs="text",
|
69 |
outputs="text",
|
70 |
+
title="Predict Identifiers",
|
71 |
+
description="Enter a code snippet and see the model generate function identifiers.",
|
72 |
examples=examples
|
73 |
)
|
74 |
|
75 |
+
# Create the Gradio interface for predicting summaries
|
76 |
+
summary_iface = gr.Interface(
|
77 |
+
fn=predict_summary,
|
78 |
+
inputs="text",
|
79 |
+
outputs="text",
|
80 |
+
title="Predict Summary",
|
81 |
+
description="Enter a code snippet and see the model generate a summary.",
|
82 |
+
examples=examples
|
83 |
+
)
|
84 |
+
|
85 |
+
# Combine the interfaces into a single tabbed interface
|
86 |
+
combined_iface = gr.TabbedInterface(
|
87 |
+
interface_list=[identifier_iface, summary_iface],
|
88 |
+
tab_names=["Predict Identifiers", "Predict Summary"]
|
89 |
+
)
|
90 |
+
|
91 |
+
# Launch the combined interface
|
92 |
+
combined_iface.launch()
|