dsolowiej's picture
Update app.py
76baa48 verified
import gradio as gr
from transformers import pipeline
# Tłumacz PL ➡️ EN
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-pl-en")
# Klasyfikator fake newsów
model_id = "Pulk17/Fake-News-Detection"
classifier = pipeline("text-classification", model=model_id)
label_map = {
"LABEL_0": "FAKE",
"LABEL_1": "REAL"
}
def analyze(text_pl):
# Tłumaczymy tekst na angielski
translated = translator(text_pl)[0]['translation_text']
# Przesyłamy przetłumaczony tekst do modelu
result = classifier(translated)
raw_label = result[0]['label']
label = label_map.get(raw_label, raw_label)
score = round(result[0]['score'], 2)
return f"Polski tekst: {text_pl}\n\nTranslated: {translated}\n\nClassification: {label}\nConfidence: {score}"
gr.Interface(
fn=analyze,
inputs="text",
outputs="text",
title="Fake News Detector (Polish & English)",
description="Wprowadź tekst po polsku — zostanie przetłumaczony i oceniony jako FAKE lub REAL."
).launch()