Nguyen17 commited on
Commit
652c199
·
verified ·
1 Parent(s): 88daf83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -9,11 +9,8 @@ model = GPT2LMHeadModel.from_pretrained('NlpHUST/gpt2-vietnamese')
9
 
10
 
11
  def run(text, intensity):
12
- res="NlpHUST model \n"
13
- if (intensity>=10):
14
- max_length=intensity
15
- else:
16
- max_length=10
17
 
18
  input_ids = tokenizer.encode(text, return_tensors='pt')
19
  sample_outputs = model.generate(input_ids,pad_token_id=tokenizer.eos_token_id,
@@ -27,18 +24,22 @@ def run(text, intensity):
27
  num_return_sequences=2)
28
 
29
  for i, sample_output in enumerate(sample_outputs):
30
- res +="Mẫu số {}\n\n{}".format(i+1, tokenizer.decode(sample_output.tolist()))
31
- res +='\n'
32
  return res
33
 
34
- demo = gr.Interface(
35
- fn=run,
36
- inputs=["text", "slider"],
37
- outputs=["text"],
38
- )
39
 
40
- demo.launch()
 
 
 
41
 
 
42
 
43
 
44
 
 
9
 
10
 
11
  def run(text, intensity):
12
+ res="Tham khảo NlpHUST model \n \n \n"
13
+ max_length=intensity
 
 
 
14
 
15
  input_ids = tokenizer.encode(text, return_tensors='pt')
16
  sample_outputs = model.generate(input_ids,pad_token_id=tokenizer.eos_token_id,
 
24
  num_return_sequences=2)
25
 
26
  for i, sample_output in enumerate(sample_outputs):
27
+ res +="Mẫu số {}\n \n{}".format(i+1, tokenizer.decode(sample_output.tolist()))
28
+ res +='\n \n \n \n'
29
  return res
30
 
31
+ # demo = gr.Interface(
32
+ # fn=run,
33
+ # inputs=["text", "slider"],
34
+ # outputs=["text"],
35
+ # )
36
 
37
+ demo = gr.Interface(fn=run,
38
+ inputs=[gr.Textbox(label="Nhập vào nội dung input",value="Con đường xưa em đi"),gr.Slider(label="Độ dài output muốn tạo ra", value=20, minimum=10, maximum=100, step=2)],
39
+ outputs=gr.Textbox(label="Output"), # <-- Number of output components: 1
40
+ )
41
 
42
+ demo.launch()
43
 
44
 
45