hyejoo commited on
Commit
5b04342
โ€ข
1 Parent(s): 47c4e7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
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="Hugging Face Transformers + Gradio Demo",
30
- description="Enter a text and get the model's response."
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 ์•ฑ ์‹œ์ž‘