Spaces:
Configuration error
Configuration error
hbofficial-1005
commited on
Commit
·
68f05a6
1
Parent(s):
f8a2fb4
Updated Gradio App
Browse files- .github/workflows/ci-cd.yml +1 -1
- app.py +1 -3
- models/ner_model/test.txt +0 -0
- train.py +8 -3
.github/workflows/ci-cd.yml
CHANGED
@@ -85,7 +85,7 @@ jobs:
|
|
85 |
git merge --no-ff origin/develop
|
86 |
git push origin main
|
87 |
|
88 |
-
|
89 |
needs: merge-to-main
|
90 |
runs-on: ubuntu-latest
|
91 |
steps:
|
|
|
85 |
git merge --no-ff origin/develop
|
86 |
git push origin main
|
87 |
|
88 |
+
finalize-deployment:
|
89 |
needs: merge-to-main
|
90 |
runs-on: ubuntu-latest
|
91 |
steps:
|
app.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
|
3 |
|
4 |
-
|
5 |
-
model_path = "./ner_model"
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
7 |
model = AutoModelForTokenClassification.from_pretrained(model_path)
|
8 |
|
9 |
-
# Create NER pipeline
|
10 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
|
11 |
|
12 |
def ner_prediction(text):
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
|
3 |
|
4 |
+
model_path = "./models/ner_model"
|
|
|
5 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
6 |
model = AutoModelForTokenClassification.from_pretrained(model_path)
|
7 |
|
|
|
8 |
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
|
9 |
|
10 |
def ner_prediction(text):
|
models/ner_model/test.txt
ADDED
File without changes
|
train.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch
|
2 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, TrainingArguments, Trainer
|
3 |
from datasets import load_dataset, load_metric
|
@@ -21,7 +22,7 @@ model = AutoModelForTokenClassification.from_pretrained(model_checkpoint, num_la
|
|
21 |
|
22 |
# Training arguments
|
23 |
training_args = TrainingArguments(
|
24 |
-
output_dir="./ner_model",
|
25 |
evaluation_strategy="epoch",
|
26 |
save_strategy="epoch",
|
27 |
learning_rate=2e-5,
|
@@ -51,6 +52,10 @@ trainer = Trainer(
|
|
51 |
# Train model
|
52 |
trainer.train()
|
53 |
|
|
|
|
|
|
|
|
|
54 |
# Save model
|
55 |
-
trainer.save_model(
|
56 |
-
tokenizer.save_pretrained(
|
|
|
1 |
+
import os
|
2 |
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, TrainingArguments, Trainer
|
4 |
from datasets import load_dataset, load_metric
|
|
|
22 |
|
23 |
# Training arguments
|
24 |
training_args = TrainingArguments(
|
25 |
+
output_dir="./models/ner_model",
|
26 |
evaluation_strategy="epoch",
|
27 |
save_strategy="epoch",
|
28 |
learning_rate=2e-5,
|
|
|
52 |
# Train model
|
53 |
trainer.train()
|
54 |
|
55 |
+
# Ensure directory exists before saving
|
56 |
+
output_dir = "./models/ner_model"
|
57 |
+
os.makedirs(output_dir, exist_ok=True)
|
58 |
+
|
59 |
# Save model
|
60 |
+
trainer.save_model(output_dir)
|
61 |
+
tokenizer.save_pretrained(output_dir)
|