Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
|
|
| 4 |
|
| 5 |
# Load the trained model and tokenizer
|
| 6 |
-
model_path = 'viv/AIKIA' #
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("nlpaueb/bert-base-greek-uncased-v1")
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Preprocessing function for Greek text
|
| 11 |
def preprocessing_greek(text):
|
| 12 |
-
text = text.lower() # Example step
|
| 13 |
return text
|
| 14 |
|
| 15 |
# Prediction function
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 4 |
+
import safetensors_rust
|
| 5 |
|
| 6 |
# Load the trained model and tokenizer
|
| 7 |
+
model_path = 'viv/AIKIA' # Ensure this path is correct, either local or Hugging Face path
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("nlpaueb/bert-base-greek-uncased-v1")
|
| 9 |
+
|
| 10 |
+
# Try loading the model, fallback to `.bin` if `.safetensors` fails
|
| 11 |
+
try:
|
| 12 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
| 13 |
+
except safetensors_rust.SafetensorError:
|
| 14 |
+
print("Safetensors failed, trying to load bin file.")
|
| 15 |
+
model = AutoModelForSequenceClassification.from_pretrained("viv/AIKIA/pytorch_model.bin")
|
| 16 |
|
| 17 |
# Preprocessing function for Greek text
|
| 18 |
def preprocessing_greek(text):
|
| 19 |
+
text = text.lower() # Example step: Convert to lowercase
|
| 20 |
return text
|
| 21 |
|
| 22 |
# Prediction function
|