Spaces:
Build error
Build error
File size: 1,026 Bytes
33651e5 76baa48 4d4026e 3bca34e 33651e5 0c97acf 76baa48 0c97acf 76baa48 f5122eb 0d0f0c1 76baa48 33651e5 76baa48 3bca34e |
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 |
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()
|