zionia commited on
Commit
c2c8625
·
verified ·
1 Parent(s): bd89085

update app.py to include lab information

Browse files
Files changed (1) hide show
  1. app.py +70 -19
app.py CHANGED
@@ -47,26 +47,77 @@ def file_prediction(file):
47
 
48
  return results
49
 
50
- gradio_ui = gr.Interface(
51
- fn=prediction,
52
- title="Setswana News Classification",
53
- description=f"Enter Setswana news article to see the category of the news.\n For this classification, the {MODEL_URL} model was used.",
54
- inputs=gr.Textbox(lines=10, label="Paste some Setswana news here"),
55
- outputs=gr.Label(num_top_classes=5, label="News categories probabilities"),
56
- theme="default",
57
- article="<p style='text-align: center'>For our other AI works: <a href='https://www.kodiks.com/ai_solutions.html' target='_blank'>https://www.kodiks.com/ai_solutions.html</a> | <a href='https://twitter.com/KodiksBilisim' target='_blank'>Contact us</a></p>",
58
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
- gradio_file_ui = gr.Interface(
61
- fn=file_prediction,
62
- title="Upload File for Setswana News Classification",
63
- description=f"Upload a text or CSV file with Setswana news articles. The first column in the CSV should contain the news text.",
64
- inputs=gr.File(label="Upload text or CSV file"),
65
- outputs=gr.Dataframe(headers=["News Text", "Category Predictions"], label="Predictions from file"),
66
- theme="default"
67
- )
68
 
69
- gradio_combined_ui = gr.TabbedInterface([gradio_ui, gradio_file_ui], ["Text Input", "File Upload"])
 
 
 
 
 
70
 
71
- gradio_combined_ui.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
 
 
47
 
48
  return results
49
 
50
+ with gr.Blocks() as demo:
51
+ with gr.Row():
52
+ with gr.Column(scale=1):
53
+ pass
54
+ with gr.Column(scale=4, min_width=1000):
55
+ gr.Image("logo_transparent_small.png", elem_id="logo", show_label=False, width=500)
56
+ gr.Markdown("""
57
+ <h1 style='text-align: center;'>Setswana News Classification</h1>
58
+ <p style='text-align: center;'>This space provides a classification service for news in Setswana.</p>
59
+ """)
60
+ with gr.Column(scale=1):
61
+ pass
62
+
63
+ with gr.Tabs():
64
+ with gr.Tab("Text Input"):
65
+ gr.Markdown(f"""
66
+ Enter Setswana news article to see the category of the news. <br>
67
+ For this classification, the <a href='{MODEL_URL}' target='_blank'>PuoBERTa-News</a> model was used.
68
+ """)
69
+ inp_text = gr.Textbox(lines=10, label="Paste some Setswana news here")
70
+ output_label = gr.Label(num_top_classes=5, label="News categories probabilities")
71
+ translate_button = gr.Button("Classify")
72
+ translate_button.click(prediction, inputs=inp_text, outputs=output_label)
73
 
74
+ with gr.Tab("File Upload"):
75
+ gr.Markdown("""
76
+ Upload a text or CSV file with Setswana news articles. The first column in the CSV should contain the news text.
77
+ """)
78
+ file_input = gr.File(label="Upload text or CSV file")
79
+ file_output = gr.Dataframe(headers=["News Text", "Category Predictions"], label="Predictions from file")
80
+ file_button = gr.Button("Classify File")
81
+ file_button.click(file_prediction, inputs=file_input, outputs=file_output)
82
 
83
+ gr.Markdown("""
84
+ <div style='text-align: center;'>
85
+ <a href='https://github.com/dsfsi/PuoBERTa-News' target='_blank'>GitHub</a> |
86
+ <a href='https://docs.google.com/forms/d/e/1FAIpQLSf7S36dyAUPx2egmXbFpnTBuzoRulhL5Elu-N1eoMhaO7v10w/viewform' target='_blank'>Feedback Form</a>
87
+ </div>
88
+ """)
89
 
90
+ with gr.Accordion("More Information", open=False):
91
+
92
+ gr.Markdown("""
93
+ <h4 style="text-align: center;">Authors</h4>
94
+ <div style='text-align: center;'>
95
+ Vukosi Marivate, Moseli Mots'Oehli, Valencia Wagner, Richard Lastrucci, Isheanesu Dzingirai
96
+ </div>
97
+ """)
98
+
99
+ gr.Markdown("""
100
+ <h4 style="text-align: center;">Citation</h4>
101
+ <pre style="text-align: left; white-space: pre-wrap;">
102
+ @inproceedings{marivate2023puoberta,
103
+ title = {PuoBERTa: Training and evaluation of a curated language model for Setswana},
104
+ author = {Vukosi Marivate and Moseli Mots'Oehli and Valencia Wagner and Richard Lastrucci and Isheanesu Dzingirai},
105
+ year = {2023},
106
+ booktitle= {Artificial Intelligence Research. SACAIR 2023. Communications in Computer and Information Science},
107
+ url= {https://link.springer.com/chapter/10.1007/978-3-031-49002-6_17},
108
+ keywords = {NLP},
109
+ preprint_url = {https://arxiv.org/abs/2310.09141},
110
+ dataset_url = {https://github.com/dsfsi/PuoBERTa},
111
+ software_url = {https://huggingface.co/dsfsi/PuoBERTa}
112
+ }
113
+ </pre>
114
+ """)
115
+
116
+ gr.Markdown("""
117
+ <h4 style="text-align: center;">DOI</h4>
118
+ <div style='text-align: center;'>
119
+ DOI: <a href="https://doi.org/10.1007/978-3-031-49002-6_17" target="_blank">10.1007/978-3-031-49002-6_17</a>
120
+ </div>
121
+ """)
122
 
123
+ demo.launch()