viv commited on
Commit
0b31a54
·
verified ·
1 Parent(s): fa0bd4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -1,18 +1,13 @@
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):
 
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/pytorch_model.bin' # Path to the .bin file
7
  tokenizer = AutoTokenizer.from_pretrained("nlpaueb/bert-base-greek-uncased-v1")
8
 
9
+ # Directly load the model from the .bin file
10
+ model = AutoModelForSequenceClassification.from_pretrained(model_path, from_tf=False, config='viv/AIKIA/config.json')
 
 
 
 
11
 
12
  # Preprocessing function for Greek text
13
  def preprocessing_greek(text):