Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +25 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
4 |
+
|
5 |
+
# Použijeme multijazyčný model MT5
|
6 |
+
model_name = "google/mt5-base"
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
9 |
+
|
10 |
+
# Definícia funkcie na humanizáciu
|
11 |
+
def humanize(text):
|
12 |
+
# Pridáme jednoduchý prompt – MT5 používa implicitné inštrukcie
|
13 |
+
prompt = "Parafrázuj tento text prirodzene a ľudsky: " + text
|
14 |
+
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True)
|
15 |
+
outputs = model.generate(**inputs, max_length=512, num_beams=4)
|
16 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
17 |
+
|
18 |
+
# Gradio rozhranie
|
19 |
+
gr.Interface(
|
20 |
+
fn=humanize,
|
21 |
+
inputs=gr.Textbox(lines=10, label="Vstupný text (česky alebo slovensky)"),
|
22 |
+
outputs=gr.Textbox(label="Prepísaný text"),
|
23 |
+
title="Humanizer CZ/SK (MT5)",
|
24 |
+
description="Prepíše český alebo slovenský text do prirodzenejšej formy pomocou multijazyčného modelu MT5."
|
25 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
gradio
|
3 |
+
transformers
|
4 |
+
torch
|