loubnabnl HF staff commited on
Commit
b6ee2c4
1 Parent(s): 348b17a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -11,13 +11,16 @@ example = [
11
 
12
  # model to be changed to the finetuned one
13
  tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot-small-multi")
14
- model = AutoModelForSequenceClassification.from_pretrained("codeparrot/codeparrot-small-multi")
15
 
16
 
17
  def complexity_estimation(gen_prompt, topk):
18
  pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
19
- label = pipe(gen_prompt, do_sample=True, top_k=topk)[0]['label']
20
- return label
 
 
 
21
 
22
 
23
  iface = gr.Interface(
@@ -32,7 +35,10 @@ iface = gr.Interface(
32
  label="Number of results to return",
33
  ),
34
  ],
35
- outputs=gr.Textbox(label="Predicted complexity", lines=10),
 
 
 
36
  examples=example,
37
  layout="vertical",
38
  theme="peach",
 
11
 
12
  # model to be changed to the finetuned one
13
  tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot-small-multi")
14
+ model = AutoModelForSequenceClassification.from_pretrained("codeparrot/codeparrot-small-multi", num_labels=7)
15
 
16
 
17
  def complexity_estimation(gen_prompt, topk):
18
  pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
19
+ output = pipe(gen_prompt)[0]
20
+ # add label conversion to class
21
+ label = output['label']
22
+ score = output['score']
23
+ return label, score
24
 
25
 
26
  iface = gr.Interface(
 
35
  label="Number of results to return",
36
  ),
37
  ],
38
+ outputs=[
39
+ gr.Textbox(label="Predicted complexity", lines=1) ,
40
+ gr.Textbox(label="Corresponding probability", lines=1) ,
41
+ ],
42
  examples=example,
43
  layout="vertical",
44
  theme="peach",