EkhiAzur commited on
Commit
95946b5
·
1 Parent(s): 66f1058

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -17,7 +17,6 @@ classifier = pipeline("text-classification", tokenizer=tokenizer, model=model, m
17
  padding=True, truncation=True, batch_size=1)
18
 
19
  def prozesatu(Testua, request: gr.Request):
20
- return str(request.headers["accept-language"])
21
  prediction = prozesatu.classifier(Testua)[0]
22
  if prediction["label"]=="GAI":
23
  return {"Gai":prediction["score"], "Ez gai": 1-prediction["score"]}
@@ -27,12 +26,20 @@ def prozesatu(Testua, request: gr.Request):
27
 
28
  prozesatu.classifier = classifier
29
 
30
- demo = gr.Interface(
31
- fn=prozesatu,
32
- inputs=gr.Textbox(label="Testua", placeholder="Idatzi hemen testua..."),
33
- outputs="label",
34
- #interpretation="default",
35
- #examples=[["Gaur egungo teknologiak bikainak dira..."]]
36
- ).launch()
37
-
38
- #gr.Interface(fn=prozesatu, inputs="text", outputs="text").launch()
 
 
 
 
 
 
 
 
 
17
  padding=True, truncation=True, batch_size=1)
18
 
19
  def prozesatu(Testua, request: gr.Request):
 
20
  prediction = prozesatu.classifier(Testua)[0]
21
  if prediction["label"]=="GAI":
22
  return {"Gai":prediction["score"], "Ez gai": 1-prediction["score"]}
 
26
 
27
  prozesatu.classifier = classifier
28
 
29
+ def ezabatu(Testua):
30
+ return ""
31
+
32
+ with gr.Blocks() as demo:
33
+ with gr.Row():
34
+ with gr.Column():
35
+ input = gr.Textbox(label="Testua")
36
+ with gr.Row():
37
+ bidali_btn = gr.Button("Bidali")
38
+ ezabatu_btn = gr.Button("Ezabatu")
39
+
40
+ label = gr.Label(num_top_classes=2, label="C1 maila")
41
+
42
+
43
+ bidali_btn.click(fn=prozesatu, inputs=input, outputs=label)
44
+ ezabatu_btn.click(fn=ezabatu, inputs=input, outputs=input)
45
+ demo.launch()