minseokKoo commited on
Commit
e535275
โ€ข
1 Parent(s): 73fd40e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -20,14 +20,7 @@ def greet(co):
20
  if not code:
21
  break
22
  code_text.append(code)
23
- '''
24
- iter_num = int(
25
- input('false alarm์„ ๋ถ„๋ฅ˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ž…๋ ฅํ•  ์ฝ”๋“œ์˜ ๊ฐฏ์ˆ˜๋Š” ๋ช‡๊ฐœ์ธ๊ฐ€์š”? (์ˆซ์ž๋งŒ ์ž…๋ ฅํ•˜์„ธ์š”.) : '))
26
- code_text = []
27
- for _ in range(iter_num):
28
- code = input('์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” : ')
29
- code_text.append(code)
30
- '''
31
  code_text = ' '.join(code_text)
32
  code_text = re.sub('\/\*[\S\s]*\*\/', '', code_text)
33
  code_text = re.sub('\/\/.*', '', code_text)
@@ -53,6 +46,7 @@ def greet(co):
53
  input_ids = torch.tensor([input_ids])
54
  model = AutoModelForSequenceClassification.from_pretrained(
55
  path, num_labels=2)
 
56
  pred_2 = model(input_ids)[0].detach().cpu().numpy()[0]
57
 
58
  # 3. CFA-codebert-c-v2.pt -> undersampling + codebert-c finetuning model
@@ -63,6 +57,7 @@ def greet(co):
63
  input_ids = torch.tensor([input_ids])
64
  model = RobertaForSequenceClassification.from_pretrained(
65
  path, num_labels=2)
 
66
  pred_3 = model(input_ids)[0].detach().cpu().numpy()
67
 
68
  # 4. codeT5 finetuning model
@@ -217,12 +212,12 @@ with gr.Blocks() as demo1:
217
  """
218
  )
219
  with gr.Row():
220
- with gr.Column():
221
  inputs_1 = gr.Textbox(placeholder="์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค.", label='Text')
222
  with gr.Row():
223
  btn = gr.Button("์ œ์ถœํ•˜๊ธฐ")
224
  with gr.Column():
225
- outputs_1 = gr.Label(num_top_classes=2, label = 'Result')
226
  btn.click(fn = greet, inputs = inputs_1, outputs= outputs_1)
227
 
228
  if __name__ == "__main__":
 
20
  if not code:
21
  break
22
  code_text.append(code)
23
+
 
 
 
 
 
 
 
24
  code_text = ' '.join(code_text)
25
  code_text = re.sub('\/\*[\S\s]*\*\/', '', code_text)
26
  code_text = re.sub('\/\/.*', '', code_text)
 
46
  input_ids = torch.tensor([input_ids])
47
  model = AutoModelForSequenceClassification.from_pretrained(
48
  path, num_labels=2)
49
+ model.to('cpu')
50
  pred_2 = model(input_ids)[0].detach().cpu().numpy()[0]
51
 
52
  # 3. CFA-codebert-c-v2.pt -> undersampling + codebert-c finetuning model
 
57
  input_ids = torch.tensor([input_ids])
58
  model = RobertaForSequenceClassification.from_pretrained(
59
  path, num_labels=2)
60
+ model.to('cpu')
61
  pred_3 = model(input_ids)[0].detach().cpu().numpy()
62
 
63
  # 4. codeT5 finetuning model
 
212
  """
213
  )
214
  with gr.Row():
215
+ with gr.Columns():
216
  inputs_1 = gr.Textbox(placeholder="์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค.", label='Text')
217
  with gr.Row():
218
  btn = gr.Button("์ œ์ถœํ•˜๊ธฐ")
219
  with gr.Column():
220
+ outputs_1 = gr.Number(label = 'Result')
221
  btn.click(fn = greet, inputs = inputs_1, outputs= outputs_1)
222
 
223
  if __name__ == "__main__":