dreyyyy commited on
Commit
549bee4
·
1 Parent(s): ceab426

second commit

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -1,7 +1,26 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
+ # Load your Hugging Face model and tokenizer
5
+ model_name = "dreyyyy/EN-ES" # Replace with your model ID
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
 
9
+ # Define the prediction function
10
+ def translate_text(input_text):
11
+ inputs = tokenizer(input_text, return_tensors="pt")
12
+ outputs = model.generate(**inputs)
13
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+
15
+ # Create the Gradio interface
16
+ iface = gr.Interface(
17
+ fn=translate_text,
18
+ inputs="text",
19
+ outputs="text",
20
+ title="Text Translation",
21
+ description="Translate input text using a Hugging Face model."
22
+ )
23
+
24
+ # Launch the Gradio app
25
+ if __name__ == "__main__":
26
+ iface.launch()