phamson02
commited on
Commit
•
1a2089d
1
Parent(s):
ebf036f
update
Browse files- app.py +0 -1
- complete_poem.py +14 -6
app.py
CHANGED
@@ -5,7 +5,6 @@ from generate_poem import generate_poem_interface
|
|
5 |
gr_interface = gr.TabbedInterface(
|
6 |
[complete_poem_interface, generate_poem_interface],
|
7 |
title="Thơ AI",
|
8 |
-
description="Ứng dụng mô hình ngôn ngữ cực lớn để sinh ra các bài thơ Việt Nam",
|
9 |
)
|
10 |
|
11 |
gr_interface.launch()
|
|
|
5 |
gr_interface = gr.TabbedInterface(
|
6 |
[complete_poem_interface, generate_poem_interface],
|
7 |
title="Thơ AI",
|
|
|
8 |
)
|
9 |
|
10 |
gr_interface.launch()
|
complete_poem.py
CHANGED
@@ -4,16 +4,16 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
4 |
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
|
5 |
# Define your models
|
6 |
models = {
|
7 |
-
"
|
8 |
"Libosa2707/vietnamese-poem-luc-bat-gpt2"
|
9 |
),
|
10 |
-
"
|
11 |
"Libosa2707/vietnamese-poem-bay-chu-gpt2"
|
12 |
),
|
13 |
-
"
|
14 |
"Libosa2707/vietnamese-poem-tam-chu-gpt2"
|
15 |
),
|
16 |
-
"
|
17 |
"Libosa2707/vietnamese-poem-nam-chu-gpt2"
|
18 |
),
|
19 |
}
|
@@ -56,9 +56,17 @@ def complete_poem(text, style):
|
|
56 |
complete_poem_interface = gr.Interface(
|
57 |
fn=complete_poem,
|
58 |
inputs=[
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
gr.components.Dropdown(
|
61 |
-
choices=["
|
|
|
|
|
62 |
),
|
63 |
],
|
64 |
outputs="text",
|
|
|
4 |
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
|
5 |
# Define your models
|
6 |
models = {
|
7 |
+
"Lục Bát": AutoModelForCausalLM.from_pretrained(
|
8 |
"Libosa2707/vietnamese-poem-luc-bat-gpt2"
|
9 |
),
|
10 |
+
"Bảy Chữ": AutoModelForCausalLM.from_pretrained(
|
11 |
"Libosa2707/vietnamese-poem-bay-chu-gpt2"
|
12 |
),
|
13 |
+
"Tám Chữ": AutoModelForCausalLM.from_pretrained(
|
14 |
"Libosa2707/vietnamese-poem-tam-chu-gpt2"
|
15 |
),
|
16 |
+
"Năm Chữ": AutoModelForCausalLM.from_pretrained(
|
17 |
"Libosa2707/vietnamese-poem-nam-chu-gpt2"
|
18 |
),
|
19 |
}
|
|
|
56 |
complete_poem_interface = gr.Interface(
|
57 |
fn=complete_poem,
|
58 |
inputs=[
|
59 |
+
# Title and description
|
60 |
+
gr.Interface.Title("Viết tiếp áng thơ hay"),
|
61 |
+
gr.components.Textbox(
|
62 |
+
lines=1,
|
63 |
+
placeholder="Tôi đâu có biết làm thơ",
|
64 |
+
label="Những áng thơ đầu tiên",
|
65 |
+
),
|
66 |
gr.components.Dropdown(
|
67 |
+
choices=["Lục Bát", "Bảy Chữ", "Tám Chữ", "Năm Chữ"],
|
68 |
+
label="Kiểu thơ",
|
69 |
+
default="Lục Bát",
|
70 |
),
|
71 |
],
|
72 |
outputs="text",
|