enesmanan commited on
Commit
05cb2a4
·
verified ·
1 Parent(s): fc01824

update font & example

Browse files
Files changed (1) hide show
  1. app.py +62 -14
app.py CHANGED
@@ -47,11 +47,37 @@ class NERDemo:
47
  def create_demo(self) -> gr.Interface:
48
  """Create and configure the Gradio interface"""
49
 
50
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
51
- gr.Markdown("# Multilingual Named Entity Recognition")
52
- gr.Markdown(
53
- "This demo uses XLM-RoBERTa model fine-tuned for NER tasks in multiple languages."
54
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  with gr.Row():
57
  with gr.Column(scale=3):
@@ -71,9 +97,17 @@ class NERDemo:
71
 
72
  with gr.Column(scale=2):
73
  with gr.Group():
74
- gr.Markdown("### Entity Statistics")
 
 
 
 
 
 
 
 
75
  stats_output = gr.Json(label="Detected Entities")
76
- time_output = gr.Markdown()
77
 
78
  highlighted_output = gr.HighlightedText(
79
  label="Detected Entities", show_legend=True
@@ -81,15 +115,28 @@ class NERDemo:
81
 
82
  # Example inputs
83
  examples = [
84
- ["My name is Tim and I live in California", "English"],
85
- ["Ich arbeite bei Google in Berlin", "German"],
 
 
 
 
 
 
86
  [
87
  "Enes Fehmi Manan, İzmir'de yaşıyor ve Fibababanka'da çalışıyor.",
88
  "Turkish",
89
  ],
90
- ["Pierre habite à Paris et travaille chez Microsoft.", "French"],
91
- ["María trabaja en Amazon en Madrid.", "Spanish"],
 
 
 
 
 
 
92
  ]
 
93
  gr.Examples(examples, inputs=[text_input, language])
94
 
95
  # Event handlers
@@ -113,6 +160,7 @@ class NERDemo:
113
  return demo
114
 
115
 
116
- ner_demo = NERDemo()
117
- demo = ner_demo.create_demo()
118
- demo.launch(share=True)
 
 
47
  def create_demo(self) -> gr.Interface:
48
  """Create and configure the Gradio interface"""
49
 
50
+ theme = gr.themes.Base(
51
+ primary_hue="blue",
52
+ secondary_hue="slate",
53
+ font=gr.themes.GoogleFont("Source Sans Pro"),
54
+ neutral_hue="slate",
55
+ ).set(
56
+ body_text_color="*neutral_950",
57
+ block_background_fill="*neutral_50",
58
+ block_border_width="0px",
59
+ button_primary_background_fill="*primary_500",
60
+ button_primary_background_fill_hover="*primary_600",
61
+ button_primary_text_color="white",
62
+ input_background_fill="white",
63
+ block_radius="lg",
64
+ )
65
+
66
+ with gr.Blocks(theme=theme) as demo:
67
+ with gr.Row():
68
+ gr.HTML(
69
+ """
70
+ <div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 1rem; font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arial', sans-serif;">
71
+ <h1 style="color: #374151; font-size: 2.5rem; font-weight: 600; margin-bottom: 0.5rem;">
72
+ Multilingual Named Entity Recognition
73
+ </h1>
74
+ <p style="color: #6B7280; font-size: 1.1rem; line-height: 1.5; margin-top: 0.5rem;">
75
+ This demo uses XLM-RoBERTa model fine-tuned for NER tasks in multiple languages.
76
+ Automatically detects and highlights named entities such as persons, organizations, locations, and more.
77
+ </p>
78
+ </div>
79
+ """
80
+ )
81
 
82
  with gr.Row():
83
  with gr.Column(scale=3):
 
97
 
98
  with gr.Column(scale=2):
99
  with gr.Group():
100
+ gr.HTML(
101
+ """
102
+ <div style="margin-bottom: 1rem;">
103
+ <h3 style="color: #374151; font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem;">
104
+ Entity Statistics
105
+ </h3>
106
+ </div>
107
+ """
108
+ )
109
  stats_output = gr.Json(label="Detected Entities")
110
+ time_output = gr.Markdown(elem_classes="text-sm text-gray-600")
111
 
112
  highlighted_output = gr.HighlightedText(
113
  label="Detected Entities", show_legend=True
 
115
 
116
  # Example inputs
117
  examples = [
118
+ [
119
+ "Emma Watson starred in Harry Potter and studied at Oxford University while working with United Nations.",
120
+ "English",
121
+ ],
122
+ [
123
+ "Die Deutsche Bank hat ihren Hauptsitz in Frankfurt, während BMW in München produziert.",
124
+ "German",
125
+ ],
126
  [
127
  "Enes Fehmi Manan, İzmir'de yaşıyor ve Fibababanka'da çalışıyor.",
128
  "Turkish",
129
  ],
130
+ [
131
+ "Le Louvre à Paris expose la Joconde de Leonardo da Vinci depuis le XIXe siècle.",
132
+ "French",
133
+ ],
134
+ [
135
+ "El Real Madrid jugará contra el Barcelona en el Santiago Bernabéu el próximo mes.",
136
+ "Spanish",
137
+ ],
138
  ]
139
+
140
  gr.Examples(examples, inputs=[text_input, language])
141
 
142
  # Event handlers
 
160
  return demo
161
 
162
 
163
+ if __name__ == "__main__":
164
+ ner_demo = NERDemo()
165
+ demo = ner_demo.create_demo()
166
+ demo.launch(share=True)