Spaces:
Sleeping
Sleeping
Commit
·
ea6c7bf
1
Parent(s):
72f931a
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,9 +26,8 @@ def greet(co):
|
|
| 26 |
code_text = re.sub('\/\/.*', '', code_text)
|
| 27 |
code_text = re.sub('(\\\\n)+', '\\n', code_text)
|
| 28 |
|
| 29 |
-
|
| 30 |
# 1. CFA-CodeBERTa-small.pt -> CodeBERTa-small-v1 finetunig model
|
| 31 |
-
path =
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained("huggingface/CodeBERTa-small-v1")
|
| 33 |
input_ids = tokenizer.encode(
|
| 34 |
code_text, max_length=512, truncation=True, padding='max_length')
|
|
@@ -40,7 +39,7 @@ def greet(co):
|
|
| 40 |
# model(input_ids)[0].argmax().detach().cpu().numpy().item()
|
| 41 |
|
| 42 |
# 2. CFA-codebert-c.pt -> codebert-c finetuning model
|
| 43 |
-
path =
|
| 44 |
tokenizer = AutoTokenizer.from_pretrained(path)
|
| 45 |
input_ids = tokenizer(code_text, padding=True, max_length=512,
|
| 46 |
truncation=True, return_token_type_ids=True)['input_ids']
|
|
@@ -51,7 +50,7 @@ def greet(co):
|
|
| 51 |
pred_2 = model(input_ids)[0].detach().cpu().numpy()[0]
|
| 52 |
|
| 53 |
# 3. CFA-codebert-c-v2.pt -> undersampling + codebert-c finetuning model
|
| 54 |
-
path =
|
| 55 |
tokenizer = RobertaTokenizer.from_pretrained(path)
|
| 56 |
input_ids = tokenizer(code_text, padding=True, max_length=512,
|
| 57 |
truncation=True, return_token_type_ids=True)['input_ids']
|
|
@@ -62,7 +61,7 @@ def greet(co):
|
|
| 62 |
pred_3 = model(input_ids)[0].detach().cpu().numpy()
|
| 63 |
|
| 64 |
# 4. codeT5 finetuning model
|
| 65 |
-
path =
|
| 66 |
model_params = {
|
| 67 |
# model_type: t5-base/t5-large
|
| 68 |
"MODEL": path,
|
|
@@ -223,4 +222,3 @@ with gr.Blocks() as demo1:
|
|
| 223 |
|
| 224 |
if __name__ == "__main__":
|
| 225 |
demo1.launch()
|
| 226 |
-
|
|
|
|
| 26 |
code_text = re.sub('\/\/.*', '', code_text)
|
| 27 |
code_text = re.sub('(\\\\n)+', '\\n', code_text)
|
| 28 |
|
|
|
|
| 29 |
# 1. CFA-CodeBERTa-small.pt -> CodeBERTa-small-v1 finetunig model
|
| 30 |
+
path = 'models/CFA-CodeBERTa-small.pt'
|
| 31 |
tokenizer = AutoTokenizer.from_pretrained("huggingface/CodeBERTa-small-v1")
|
| 32 |
input_ids = tokenizer.encode(
|
| 33 |
code_text, max_length=512, truncation=True, padding='max_length')
|
|
|
|
| 39 |
# model(input_ids)[0].argmax().detach().cpu().numpy().item()
|
| 40 |
|
| 41 |
# 2. CFA-codebert-c.pt -> codebert-c finetuning model
|
| 42 |
+
path = 'models/CFA-codebert-c.pt'
|
| 43 |
tokenizer = AutoTokenizer.from_pretrained(path)
|
| 44 |
input_ids = tokenizer(code_text, padding=True, max_length=512,
|
| 45 |
truncation=True, return_token_type_ids=True)['input_ids']
|
|
|
|
| 50 |
pred_2 = model(input_ids)[0].detach().cpu().numpy()[0]
|
| 51 |
|
| 52 |
# 3. CFA-codebert-c-v2.pt -> undersampling + codebert-c finetuning model
|
| 53 |
+
path = 'models/CFA-codebert-c-v2.pt'
|
| 54 |
tokenizer = RobertaTokenizer.from_pretrained(path)
|
| 55 |
input_ids = tokenizer(code_text, padding=True, max_length=512,
|
| 56 |
truncation=True, return_token_type_ids=True)['input_ids']
|
|
|
|
| 61 |
pred_3 = model(input_ids)[0].detach().cpu().numpy()
|
| 62 |
|
| 63 |
# 4. codeT5 finetuning model
|
| 64 |
+
path = 'models/CFA-codeT5'
|
| 65 |
model_params = {
|
| 66 |
# model_type: t5-base/t5-large
|
| 67 |
"MODEL": path,
|
|
|
|
| 222 |
|
| 223 |
if __name__ == "__main__":
|
| 224 |
demo1.launch()
|
|
|