Update app.py
Browse files
app.py
CHANGED
@@ -9,16 +9,19 @@ model = AutoModelForSeq2SeqLM.from_pretrained("yeye776/t5-OndeviceAI-HomeIoT")
|
|
9 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
10 |
def generate_answer(input_text):
|
11 |
# ์
๋ ฅ ํ
์คํธ๋ฅผ ๋ชจ๋ธ ํ ํฌ๋์ด์ ๋ก ํ ํฐํ
|
12 |
-
input_ids = tokenizer(input_text, max_length=700, return_tensors="pt").input_ids
|
13 |
# input_ids = tokenizer(input_text, max_length=700, return_tensors="pt").input_ids
|
14 |
|
15 |
# ๋ชจ๋ธ ์ถ๋ก
|
16 |
-
output_ids = model.generate(input_ids, top_k=10, max_length=1024)
|
17 |
# output_ids = model.generate(input_ids, num_beams=10, top_k=10, max_length=1024)
|
18 |
|
19 |
# ๋ชจ๋ธ ์ถ๋ ฅ์ ํ
์คํธ๋ก ๋์ฝ๋ฉ
|
20 |
-
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
21 |
-
|
|
|
|
|
|
|
22 |
return output_text
|
23 |
|
24 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
@@ -26,8 +29,8 @@ iface = gr.Interface(
|
|
26 |
fn=generate_answer,
|
27 |
inputs="text",
|
28 |
outputs="text",
|
29 |
-
title="
|
30 |
-
description="
|
31 |
)
|
32 |
|
33 |
# Gradio ์ฑ ์์
|
|
|
9 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
10 |
def generate_answer(input_text):
|
11 |
# ์
๋ ฅ ํ
์คํธ๋ฅผ ๋ชจ๋ธ ํ ํฌ๋์ด์ ๋ก ํ ํฐํ
|
12 |
+
# input_ids = tokenizer(input_text, max_length=700, return_tensors="pt").input_ids
|
13 |
# input_ids = tokenizer(input_text, max_length=700, return_tensors="pt").input_ids
|
14 |
|
15 |
# ๋ชจ๋ธ ์ถ๋ก
|
16 |
+
# output_ids = model.generate(input_ids, top_k=10, max_length=1024)
|
17 |
# output_ids = model.generate(input_ids, num_beams=10, top_k=10, max_length=1024)
|
18 |
|
19 |
# ๋ชจ๋ธ ์ถ๋ ฅ์ ํ
์คํธ๋ก ๋์ฝ๋ฉ
|
20 |
+
# output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
21 |
+
output_text = "ActionID:1060, Value:์์, Home:์๋ฐฉ, NickName:์กฐ๋ช
1"
|
22 |
+
output_text['์ฅ์๋ช
'] = output_text['Home']
|
23 |
+
output_text['์ฅ์น๋ช
'] = output_text['NickName']
|
24 |
+
print(output_text)
|
25 |
return output_text
|
26 |
|
27 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
|
|
29 |
fn=generate_answer,
|
30 |
inputs="text",
|
31 |
outputs="text",
|
32 |
+
title="OnDevice & AI Home IoT",
|
33 |
+
description="Hugging Face Transformers + Gradio Demo"
|
34 |
)
|
35 |
|
36 |
# Gradio ์ฑ ์์
|