-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (47 loc) · 1.51 KB
/
Copy pathmain.py
File metadata and controls
55 lines (47 loc) · 1.51 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
49
50
51
52
53
54
55
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QGuiApplication
import sys
from gui import ScamDetectorGUI
from scanner import load_model, train_model, init_cache_db
import os
import logging
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler("app.log"),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
def ensure_directories():
directories = ['models', 'logs', 'cache']
for directory in directories:
Path(directory).mkdir(parents=True, exist_ok=True)
def main():
try:
ensure_directories()
init_cache_db()
gui_app = QGuiApplication([])
app = QApplication(sys.argv)
model_path = 'models/scam_detector_model.pkl'
if not os.path.exists(model_path):
if not os.path.exists('scam_dataset.csv'):
logger.error("Dataset file 'scam_dataset.csv' not found.")
return
logger.info("Training new model...")
train_model()
model = load_model()
if model:
window = ScamDetectorGUI(model)
window.setWindowTitle("v7lthronyx ScamDetection نسخه ی اول بتا")
window.show()
sys.exit(app.exec())
else:
logger.error("Failed to load the ML model.")
except Exception as e:
logger.error(f"Application error: {e}")
raise
if __name__ == "__main__":
main()