Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,13 +16,18 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
16 |
classifier = pipeline("text-classification", tokenizer=tokenizer, model=model, max_length=512,
|
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"]}
|
23 |
else:
|
24 |
return {"Gai":1-prediction["score"], "Ez gai": prediction["score"]}
|
25 |
|
|
|
26 |
prozesatu.classifier = classifier
|
27 |
|
28 |
def ezabatu(Testua):
|
@@ -41,4 +46,6 @@ with gr.Blocks() as demo:
|
|
41 |
|
42 |
bidali_btn.click(fn=prozesatu, inputs=input, outputs=label)
|
43 |
ezabatu_btn.click(fn=ezabatu, inputs=input, outputs=input)
|
|
|
|
|
44 |
demo.launch()
|
|
|
16 |
classifier = pipeline("text-classification", tokenizer=tokenizer, model=model, max_length=512,
|
17 |
padding=True, truncation=True, batch_size=1)
|
18 |
|
19 |
+
adibideak = json.load(open("./Adibideak.json", "r"))
|
20 |
+
|
21 |
def prozesatu(Testua, request: gr.Request):
|
22 |
+
if Testua[-3:-1]=="...":
|
23 |
+
Testua = prozesatu.adibideak[Testua]
|
24 |
prediction = prozesatu.classifier(Testua)[0]
|
25 |
if prediction["label"]=="GAI":
|
26 |
return {"Gai":prediction["score"], "Ez gai": 1-prediction["score"]}
|
27 |
else:
|
28 |
return {"Gai":1-prediction["score"], "Ez gai": prediction["score"]}
|
29 |
|
30 |
+
prozesatu.adibideak = adibideak
|
31 |
prozesatu.classifier = classifier
|
32 |
|
33 |
def ezabatu(Testua):
|
|
|
46 |
|
47 |
bidali_btn.click(fn=prozesatu, inputs=input, outputs=label)
|
48 |
ezabatu_btn.click(fn=ezabatu, inputs=input, outputs=input)
|
49 |
+
gr.Examples(['Azken urte hauetan, japonen telebista oso esaguna da...', 'Denok bizi izan genuen iaz ia hiru hilabetez jardun zen...', 'Pandemia egoera eta konfinamendua dela eta, asko izan dira...'], inputs=input, outputs=label, label="Adibideak:", fn=prozesatu, cache_examples=True)
|
50 |
+
|
51 |
demo.launch()
|