Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,17 @@ from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassifica
|
|
4 |
import json
|
5 |
import socket
|
6 |
from datetime import datetime
|
|
|
|
|
|
|
7 |
|
8 |
access_token = os.environ['ACCES_TOKEN']
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
model = AutoModelForSequenceClassification.from_pretrained("EkhiAzur/C1_Sailkapen_Demoa", token=access_token)
|
11 |
|
12 |
tokenizer = AutoTokenizer.from_pretrained(
|
@@ -22,7 +30,11 @@ classifier = pipeline("text-classification", tokenizer=tokenizer, model=model, m
|
|
22 |
adibideak = json.load(open("./Adibideak.json", "r"))
|
23 |
|
24 |
def prozesatu(Testua, request: gr.Request):
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
#Ip-a lortzeko kontuak
|
27 |
client_ip = request.client.host
|
28 |
local_ip = socket.gethostbyname(socket.gethostbyname(""))
|
@@ -35,12 +47,14 @@ def prozesatu(Testua, request: gr.Request):
|
|
35 |
now = datetime.now()
|
36 |
|
37 |
#Fitxategian gorde
|
38 |
-
f = open(
|
39 |
print(f'Erabiltzailea: {client_ip}. Eguna eta ordua: {now}.\n')
|
40 |
f.write(f'Erabiltzailea: {client_ip}. Eguna eta ordua: {now}.\n')
|
41 |
|
42 |
f.close()
|
43 |
|
|
|
|
|
44 |
prediction = prozesatu.classifier(Testua)[0]
|
45 |
if prediction["label"]=="GAI":
|
46 |
return {"Gai":prediction["score"], "Ez gai": 1-prediction["score"]}
|
|
|
4 |
import json
|
5 |
import socket
|
6 |
from datetime import datetime
|
7 |
+
import huggingface_hub
|
8 |
+
from huggingface_hub import Repository
|
9 |
+
import os
|
10 |
|
11 |
access_token = os.environ['ACCES_TOKEN']
|
12 |
|
13 |
+
DATASET_REPO_URL = "EkhiAzur/Demoko_informazioa"
|
14 |
+
DATA_FILENAME = "Erabiltzaileak.txt"
|
15 |
+
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
16 |
+
|
17 |
+
|
18 |
model = AutoModelForSequenceClassification.from_pretrained("EkhiAzur/C1_Sailkapen_Demoa", token=access_token)
|
19 |
|
20 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
30 |
adibideak = json.load(open("./Adibideak.json", "r"))
|
31 |
|
32 |
def prozesatu(Testua, request: gr.Request):
|
33 |
+
|
34 |
+
repo = Repository(
|
35 |
+
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=access_token
|
36 |
+
)
|
37 |
+
|
38 |
#Ip-a lortzeko kontuak
|
39 |
client_ip = request.client.host
|
40 |
local_ip = socket.gethostbyname(socket.gethostbyname(""))
|
|
|
47 |
now = datetime.now()
|
48 |
|
49 |
#Fitxategian gorde
|
50 |
+
f = open(DATA_FILE, "a")
|
51 |
print(f'Erabiltzailea: {client_ip}. Eguna eta ordua: {now}.\n')
|
52 |
f.write(f'Erabiltzailea: {client_ip}. Eguna eta ordua: {now}.\n')
|
53 |
|
54 |
f.close()
|
55 |
|
56 |
+
commit_url = repo.push_to_hub()
|
57 |
+
|
58 |
prediction = prozesatu.classifier(Testua)[0]
|
59 |
if prediction["label"]=="GAI":
|
60 |
return {"Gai":prediction["score"], "Ez gai": 1-prediction["score"]}
|