Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
|
|
|
|
1 |
import torch
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
from optimum.bettertransformer import BetterTransformer
|
4 |
-
import gradio as gr
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained(
|
7 |
"google/madlad400-3b-mt",
|
@@ -15,6 +17,7 @@ model_hf = AutoModelForSeq2SeqLM.from_pretrained(
|
|
15 |
|
16 |
model = BetterTransformer.transform(model_hf, keep_original=True)
|
17 |
|
|
|
18 |
def translate(text):
|
19 |
"""
|
20 |
Translates the input text from English to Hawaiian.
|
|
|
1 |
+
import spaces
|
2 |
+
import gradio as gr
|
3 |
import torch
|
4 |
+
|
5 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
6 |
from optimum.bettertransformer import BetterTransformer
|
|
|
7 |
|
8 |
tokenizer = AutoTokenizer.from_pretrained(
|
9 |
"google/madlad400-3b-mt",
|
|
|
17 |
|
18 |
model = BetterTransformer.transform(model_hf, keep_original=True)
|
19 |
|
20 |
+
@spaces.GPU
|
21 |
def translate(text):
|
22 |
"""
|
23 |
Translates the input text from English to Hawaiian.
|