File size: 1,046 Bytes
b65c654
28402cd
b65c654
60ae244
b65c654
 
28402cd
 
 
b65c654
 
28402cd
 
 
 
 
 
 
 
 
b65c654
60ae244
b65c654
 
60ae244
01d5a22
b65c654
60ae244
b65c654
 
 
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
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Identifiant de ton modèle
model_id = "Bader44/Bader44-Scientific-Translator"

# Chargement manuel (plus stable)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)

def translate(text):
    # Préparation du texte
    inputs = tokenizer(text, return_tensors="pt", padding=True)
    
    # Génération de la traduction
    outputs = model.generate(**inputs, max_length=512)
    
    # Décodage du résultat
    translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return translated_text

# Interface Gradio
demo = gr.Interface(
    fn=translate, 
    inputs=gr.Textbox(label="English Technical Text", placeholder="Paste your text here...", lines=5),
    outputs=gr.Textbox(label="Bader44 Arabic Translation", lines=5),
    title="🚀 Bader44 Scientific Translator",
    description="IA spécialisée dans les rapports scientifiques et économiques de l'UNCTAD."
)

demo.launch()