zaidmehdi commited on
Commit
ec4a7b0
1 Parent(s): e9c4282

fix imports and models paths

Browse files
Files changed (1) hide show
  1. src/main.py +10 -3
src/main.py CHANGED
@@ -1,14 +1,21 @@
 
1
  import pickle
2
 
3
  from flask import Flask, request, jsonify
4
  from transformers import AutoModel, AutoTokenizer
5
 
6
- from utils import extract_hidden_state
7
 
8
  app = Flask(__name__)
9
 
10
- with open("../models/logistic_regression.pkl", "rb") as f:
11
- model = pickle.load(f)
 
 
 
 
 
 
12
 
13
  model_name = "moussaKam/AraBART"
14
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
1
+ import os
2
  import pickle
3
 
4
  from flask import Flask, request, jsonify
5
  from transformers import AutoModel, AutoTokenizer
6
 
7
+ from src.utils import extract_hidden_state
8
 
9
  app = Flask(__name__)
10
 
11
+ models_dir = os.path.join(os.path.dirname(__file__), '..', 'models')
12
+ model_file = os.path.join(models_dir, 'logistic_regression.pkl')
13
+
14
+ if os.path.exists(model_file):
15
+ with open(model_file, "rb") as f:
16
+ model = pickle.load(f)
17
+ else:
18
+ print(f"Error: {model_file} not found.")
19
 
20
  model_name = "moussaKam/AraBART"
21
  tokenizer = AutoTokenizer.from_pretrained(model_name)