amir22010 commited on
Commit
8a48d2c
·
1 Parent(s): c8a34b4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -62
app.py CHANGED
@@ -91,68 +91,67 @@ if __name__ == "__main__":
91
  demo = gr.Blocks()
92
  with demo:
93
  with gr.Row():
94
- if triplet_extractor:
95
- with gr.Column():
96
- gr.Markdown(
97
- "# <p align='center'>Hospital Review Aspect Sentiment Generation</p>"
98
- )
99
- with gr.Row():
100
- with gr.Column():
101
- asde_input_sentence = gr.Textbox(
102
- placeholder="Leave this box blank and choose a dataset will give you a random example...",
103
- label="Example:",
104
- )
105
- gr.Markdown(
106
- "You can find code and dataset at [MTech Thesis Project](https://github.com/Amir22010)"
107
- )
108
- asde_dataset_ids = gr.Radio(
109
- choices=[
110
- "HospitalReviews"
111
- ],
112
- value="HospitalReviews",
113
- label="Datasets",
114
- )
115
-
116
- asde_model_ids = gr.Radio(
117
- choices=[
118
- "PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
119
- # "PyABSA_Hospital_Multilingual_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
120
- # "PyABSA_Hospital_KeyBert_allenai/tk-instruct-base-def-pos_FinedTuned_Model"
121
- ],
122
- value="PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
123
- label="Fine-tuned Models on Hospital Review custom data",
124
- )
125
-
126
- asde_inference_button = gr.Button("Let's go!")
127
-
128
- asde_output_text = gr.TextArea(label="Example:")
129
-
130
- asde_model_output_generated_sentence = gr.Textbox(
131
- placeholder="Text Generated...",
132
- label="Model Prediction Text Generated:",
133
- )
134
- asde_output_pred_df = gr.DataFrame(
135
- label="Predicted Aspect & Sentiment:"
136
- )
137
- asde_output_true_df = gr.DataFrame(
138
- label="Original Aspect & Sentiment:"
139
- )
140
-
141
- asde_inference_button.click(
142
- fn=run_demo,
143
- inputs=[
144
- asde_input_sentence,
145
- asde_dataset_ids,
146
- asde_model_ids,
147
- gr.Text("ASDE", visible=False),
148
- ],
149
- outputs=[
150
- asde_output_pred_df,
151
- asde_output_true_df,
152
- asde_output_text,
153
- asde_model_output_generated_sentence
154
- ],
155
- )
156
  gr.Markdown(
157
  """### GitHub Repo: [MTech Thesis Project](https://github.com/Amir22010)
158
  ### Author: [Amir Khan](https://github.com/Amir22010)
 
91
  demo = gr.Blocks()
92
  with demo:
93
  with gr.Row():
94
+ with gr.Column():
95
+ gr.Markdown(
96
+ "# <p align='center'>Hospital Review Aspect Sentiment Generation</p>"
97
+ )
98
+ with gr.Row():
99
+ with gr.Column():
100
+ asde_input_sentence = gr.Textbox(
101
+ placeholder="Leave this box blank and choose a dataset will give you a random example...",
102
+ label="Example:",
103
+ )
104
+ gr.Markdown(
105
+ "You can find code and dataset at [MTech Thesis Project](https://github.com/Amir22010)"
106
+ )
107
+ asde_dataset_ids = gr.Radio(
108
+ choices=[
109
+ "HospitalReviews"
110
+ ],
111
+ value="HospitalReviews",
112
+ label="Datasets",
113
+ )
114
+
115
+ asde_model_ids = gr.Radio(
116
+ choices=[
117
+ "PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
118
+ # "PyABSA_Hospital_Multilingual_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
119
+ # "PyABSA_Hospital_KeyBert_allenai/tk-instruct-base-def-pos_FinedTuned_Model"
120
+ ],
121
+ value="PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model",
122
+ label="Fine-tuned Models on Hospital Review custom data",
123
+ )
124
+
125
+ asde_inference_button = gr.Button("Let's go!")
126
+
127
+ asde_output_text = gr.TextArea(label="Example:")
128
+
129
+ asde_model_output_generated_sentence = gr.Textbox(
130
+ placeholder="Text Generated...",
131
+ label="Model Prediction Text Generated:",
132
+ )
133
+ asde_output_pred_df = gr.DataFrame(
134
+ label="Predicted Aspect & Sentiment:"
135
+ )
136
+ asde_output_true_df = gr.DataFrame(
137
+ label="Original Aspect & Sentiment:"
138
+ )
139
+
140
+ asde_inference_button.click(
141
+ fn=run_demo,
142
+ inputs=[
143
+ asde_input_sentence,
144
+ asde_dataset_ids,
145
+ asde_model_ids,
146
+ gr.Text("ASDE", visible=False),
147
+ ],
148
+ outputs=[
149
+ asde_output_pred_df,
150
+ asde_output_true_df,
151
+ asde_output_text,
152
+ asde_model_output_generated_sentence
153
+ ],
154
+ )
 
155
  gr.Markdown(
156
  """### GitHub Repo: [MTech Thesis Project](https://github.com/Amir22010)
157
  ### Author: [Amir Khan](https://github.com/Amir22010)