imamnurby commited on
Commit
f815796
1 Parent(s): 67fda87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -7,16 +7,19 @@ import gradio as gr
7
  model = EncoderDecoderModel.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
8
  tokenizer = RobertaTokenizer.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
9
 
10
- def generate_preds(gen_mode, desc):
11
- desc = desc.lower()
 
 
12
  if gen_mode=="Channel":
13
- desc = "GENERATE TRIGGER AND ACTION CHANNEL ONLY <pf> " + desc
14
  elif gen_mode=="Function":
15
- desc = "GENERATE BOTH CHANNEL AND FUNCTION FOR TRIGGER AND ACTION <pf> " + desc
16
 
 
 
17
 
18
-
19
- input_ids = tokenizer.encode(desc, return_tensors='pt')
20
 
21
  # activate beam search and early_stopping
22
  preds = model.generate(
@@ -53,6 +56,7 @@ def generate_preds(gen_mode, desc):
53
  }
54
  return pd.DataFrame(df)
55
 
 
56
  demo = gr.Blocks()
57
  with demo:
58
  gr.Markdown("<h1><center>RecipeGen: Automated TAPs Generation Tool</center></h1>")
@@ -76,7 +80,7 @@ with demo:
76
  with gr.Row():
77
  generate = gr.Button("Generate")
78
  gr.Markdown("<h1><center>Results</center></h1>")
79
- results = gr.Dataframe(headers=["Trigger", "Trigger Description", "Action", "Action Description"], row_count=100)
80
 
81
  with gr.TabItem("Field"):
82
  with gr.Column():
@@ -88,5 +92,5 @@ with demo:
88
  gr.Markdown("<h1><center>Results</center></h1>")
89
  results_field = gr.Dataframe(headers=["Trigger", "Trigger Description", "Trigger Fields", "Action", "Action Description", "Action Fields"])
90
 
91
- generate.click(generate_preds, inputs=[gen_mode, desc], outputs=[results])
92
  demo.launch()
 
7
  model = EncoderDecoderModel.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
8
  tokenizer = RobertaTokenizer.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
9
 
10
+ from transformers import RobertaTokenizer, EncoderDecoderModel
11
+ import pandas as pd
12
+ def generate_taps(gen_mode, desc):
13
+ input_desc = desc.lower()
14
  if gen_mode=="Channel":
15
+ input_desc = "GENERATE TRIGGER AND ACTION CHANNEL ONLY <pf> " + input_desc
16
  elif gen_mode=="Function":
17
+ input_desc = "GENERATE BOTH CHANNEL AND FUNCTION FOR TRIGGER AND ACTION <pf> " + input_desc
18
 
19
+ model = EncoderDecoderModel.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
20
+ tokenizer = RobertaTokenizer.from_pretrained("imamnurby/rob2rand_chen_w_prefix_c_fc")
21
 
22
+ input_ids = tokenizer.encode(input_desc, return_tensors='pt')
 
23
 
24
  # activate beam search and early_stopping
25
  preds = model.generate(
 
56
  }
57
  return pd.DataFrame(df)
58
 
59
+
60
  demo = gr.Blocks()
61
  with demo:
62
  gr.Markdown("<h1><center>RecipeGen: Automated TAPs Generation Tool</center></h1>")
 
80
  with gr.Row():
81
  generate = gr.Button("Generate")
82
  gr.Markdown("<h1><center>Results</center></h1>")
83
+ results = gr.Dataframe(headers=["Trigger", "Trigger Description", "Action", "Action Description"])
84
 
85
  with gr.TabItem("Field"):
86
  with gr.Column():
 
92
  gr.Markdown("<h1><center>Results</center></h1>")
93
  results_field = gr.Dataframe(headers=["Trigger", "Trigger Description", "Trigger Fields", "Action", "Action Description", "Action Fields"])
94
 
95
+ generate.click(generate_taps, inputs=[gen_mode, desc], outputs=[results])
96
  demo.launch()