Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
|
2 |
#MBART FINE TUNE
|
3 |
-
import os
|
4 |
-
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
5 |
|
6 |
import gradio as gr
|
7 |
-
import tensorflow as tf
|
8 |
-
import torch
|
9 |
|
10 |
import sentencepiece
|
11 |
-
from transformers import MBartTokenizer,
|
12 |
|
13 |
def run_model(input_text,
|
14 |
min_length,
|
@@ -16,13 +16,13 @@ def run_model(input_text,
|
|
16 |
length_penalty):
|
17 |
|
18 |
#MBART Transformer
|
19 |
-
mbart_model =
|
20 |
mbart_tokenizer = MBartTokenizer.from_pretrained("facebook/mbart-large-50")
|
21 |
|
22 |
#encode input to vector
|
23 |
input_text = str(input_text)
|
24 |
input_text = ' '.join(input_text.split()) # hapus white space
|
25 |
-
input_tokenized = mbart_tokenizer.encode(input_text, return_tensors='
|
26 |
|
27 |
#generate input
|
28 |
summary_ids = mbart_model.generate(input_tokenized,
|
|
|
1 |
|
2 |
#MBART FINE TUNE
|
3 |
+
#import os
|
4 |
+
#os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
5 |
|
6 |
import gradio as gr
|
7 |
+
#import tensorflow as tf
|
8 |
+
#import torch
|
9 |
|
10 |
import sentencepiece
|
11 |
+
from transformers import MBartTokenizer, MBartForConditionalGeneration
|
12 |
|
13 |
def run_model(input_text,
|
14 |
min_length,
|
|
|
16 |
length_penalty):
|
17 |
|
18 |
#MBART Transformer
|
19 |
+
mbart_model = MBartForConditionalGeneration.from_pretrained("facebook/mbart-large-50")#,from_pt=True)
|
20 |
mbart_tokenizer = MBartTokenizer.from_pretrained("facebook/mbart-large-50")
|
21 |
|
22 |
#encode input to vector
|
23 |
input_text = str(input_text)
|
24 |
input_text = ' '.join(input_text.split()) # hapus white space
|
25 |
+
input_tokenized = mbart_tokenizer.encode(input_text, return_tensors='np')
|
26 |
|
27 |
#generate input
|
28 |
summary_ids = mbart_model.generate(input_tokenized,
|