Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,9 @@ import networkx as nx
|
|
16 |
nltk.download('punkt')
|
17 |
nltk.download('stopwords')
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
# Load cleaned_word_embeddings
|
24 |
with open("cleaned_word_embeddings.pkl", "rb") as f:
|
@@ -99,7 +99,12 @@ def summarize(text):
|
|
99 |
summary += ranked_sentences[j][1] + " "
|
100 |
return summary
|
101 |
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
demo = gr.Interface(fn=
|
104 |
demo.launch(share=True)
|
105 |
|
|
|
16 |
nltk.download('punkt')
|
17 |
nltk.download('stopwords')
|
18 |
|
19 |
+
model_checkpoint = "marefa-nlp/marefa-mt-en-ar"
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
21 |
+
model = TFAutoModelForSeq2SeqLM.from_pretrained("tf_model.h5")
|
22 |
|
23 |
# Load cleaned_word_embeddings
|
24 |
with open("cleaned_word_embeddings.pkl", "rb") as f:
|
|
|
99 |
summary += ranked_sentences[j][1] + " "
|
100 |
return summary
|
101 |
|
102 |
+
def translate(text):
|
103 |
+
summarized = summarize(text)
|
104 |
+
tokenized = tokenizer([summarized], return_tensors='np')
|
105 |
+
arabic = model.generate(**tokenized, max_length=128)
|
106 |
+
return arabic
|
107 |
|
108 |
+
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
109 |
demo.launch(share=True)
|
110 |
|