IinjyI commited on
Commit
b893078
1 Parent(s): 4d4c3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -16,9 +16,9 @@ import networkx as nx
16
  nltk.download('punkt')
17
  nltk.download('stopwords')
18
 
19
- def greet(name):
20
- return "Hello " + name + "!!"
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=summarize, inputs="text", outputs="text")
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