updated to new inference and better ui
This commit is contained in:
parent
390811bb96
commit
f353498fdf
|
@ -33,6 +33,6 @@ class VeraMindInference:
|
|||
confidence = prediction if is_fake else 1 - prediction
|
||||
|
||||
return {
|
||||
"result": is_fake,
|
||||
"result": "FAKE" if is_fake else "REAL",
|
||||
"confidence": float(confidence)
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
from views.mainScreen import MainFrame
|
||||
from models.data import TextData
|
||||
from Ai.interence import VeraMindInference
|
||||
|
||||
|
||||
class MainFrameController:
|
||||
|
||||
def __init__(self,frame:MainFrame) -> None:
|
||||
self.frame = frame
|
||||
self.model_inference = VeraMindInference('VeraMind-Mini')
|
||||
|
||||
|
||||
def get_textdata(self) -> TextData:
|
||||
|
@ -25,10 +28,9 @@ class MainFrameController:
|
|||
self.frame.output_textbox.configure(state="disabled")
|
||||
|
||||
def prediction(self, text_data:TextData) -> TextData:
|
||||
inference = VeraMindInference('VeraMind-Mini')
|
||||
result = inference.predict(text_data.text)
|
||||
result = self.model_inference.predict(text_data.text)
|
||||
text_data.confidence = result["confidence"]
|
||||
text_data.isfake_news = result["result"]
|
||||
print(f"Prediction: {'Real' if text_data.isfake_news == 1 else 'Fake'}")
|
||||
text_data.result = result["result"]
|
||||
print(f"Prediction: {text_data.result}")
|
||||
print(f"Confidence: {text_data.confidence}")
|
||||
return text_data
|
|
@ -4,7 +4,7 @@ class TextData:
|
|||
def __init__(self, url: str = "") -> None:
|
||||
self.url = url
|
||||
self.text = ""
|
||||
self.isfake_news = False
|
||||
self.result = ""
|
||||
self.confidence = None
|
||||
self._extractor = None
|
||||
|
||||
|
@ -29,6 +29,6 @@ class TextData:
|
|||
def get_output(self):
|
||||
|
||||
if self.confidence != None:
|
||||
output = f"Prediction: {'Real' if self.isfake_news else 'Fake'}" + f" Confidence: {self.confidence:.4f}"
|
||||
output = f"Prediction: {self.result}" + f" Confidence: {self.confidence:.4f}"
|
||||
print(output)
|
||||
return output
|
Loading…
Reference in New Issue