Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
iface = gr.Interface(
|
|
@@ -32,7 +35,10 @@ iface = gr.Interface(
|
|
| 32 |
label="Number of results to return",
|
| 33 |
),
|
| 34 |
],
|
| 35 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
| 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",
|