-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference.py
More file actions
48 lines (37 loc) · 1.15 KB
/
Copy pathinference.py
File metadata and controls
48 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import joblib
from predict import Predictor
from config import Config
def main():
# Load tokenizer
tokenizer = joblib.load(
Config.TOKENIZER_PATH
)
# Initialize predictor
predictor = Predictor(
model_path=Config.MODEL_PATH,
tokenizer=tokenizer
)
# Example reviews
test_reviews = [
"کیفیت غذا عالی بود و خیلی خوشمزه بود",
"غذا سرد رسید و اصلا کیفیت خوبی نداشت",
"ارسال خیلی سریع بود و از سفارش راضی هستم",
"بدترین تجربهای بود که داشتم، دوباره سفارش نمیدهم",
"غذا معمولی بود، نه خوب نه بد"
]
# Predict
results = predictor.predict_batch(
test_reviews
)
# Display results
print("\nPrediction Results\n")
print("-" * 50)
for result in results:
print(f"Text: {result['text']}")
print(f"Prediction: {result['label']}")
print(
f"Confidence: {result['confidence']:.2%}"
)
print("-" * 50)
if __name__ == "__main__":
main()