Spaces:
Sleeping
Sleeping
Mhammad Ibrahim
commited on
Commit
·
7e000d1
1
Parent(s):
7aa02fc
Explicitly load model with from_tf=True
Browse files- app.py +5 -3
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -7,10 +7,12 @@
|
|
| 7 |
# demo.launch()
|
| 8 |
|
| 9 |
import gradio as gr
|
| 10 |
-
from transformers import pipeline
|
| 11 |
|
| 12 |
-
# Load model from Hugging Face Hub
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def predict(text):
|
| 16 |
results = classifier(text)
|
|
|
|
| 7 |
# demo.launch()
|
| 8 |
|
| 9 |
import gradio as gr
|
| 10 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
| 11 |
|
| 12 |
+
# Load model and tokenizer from Hugging Face Hub
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained("Mhammad2023/bert-finetuned-ner")
|
| 14 |
+
model = AutoModelForTokenClassification.from_pretrained("Mhammad2023/bert-finetuned-ner", from_tf=True)
|
| 15 |
+
classifier = pipeline("token-classification", model=model, tokenizer=tokenizer)
|
| 16 |
|
| 17 |
def predict(text):
|
| 18 |
results = classifier(text)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio>=4.0.0
|
| 2 |
transformers>=4.21.0
|
| 3 |
torch>=1.12.0
|
| 4 |
-
tokenizers>=0.13.0
|
|
|
|
|
|
| 1 |
gradio>=4.0.0
|
| 2 |
transformers>=4.21.0
|
| 3 |
torch>=1.12.0
|
| 4 |
+
tokenizers>=0.13.0
|
| 5 |
+
tensorflow>=2.8.0
|