Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the model and tokenizer from Hugging Face Hub
5
+ model_name = "MichelleKanuri/swahili-ner" # Replace with your model repo name
6
+ nlp = pipeline("ner", model=model_name, tokenizer=model_name)
7
+
8
+ # Function for predictions
9
+ def predict_entities(text):
10
+ return nlp(text)
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(fn=predict_entities, inputs="text", outputs="json",
14
+ live=True, title="Swahili NER",
15
+ description="Named Entity Recognition for Kiswahili text using BERT.")
16
+
17
+ # Launch the Gradio interface
18
+ iface.launch()