all files
Browse files- app.py +8 -3
- dls_origin-classifier_v1.pkl +3 -0
app.py
CHANGED
@@ -4,12 +4,16 @@ import torch
|
|
4 |
from fastai.text.all import *
|
5 |
|
6 |
|
7 |
-
# Define the path to your model
|
8 |
-
model_path = "
|
|
|
9 |
|
10 |
# Load the learner
|
11 |
learner_inf = load_learner(model_path)
|
12 |
|
|
|
|
|
|
|
13 |
# Create a mapping from class labels to indices
|
14 |
class_label_mapping = {label: idx for idx, label in enumerate(learner_inf.dls.vocab)}
|
15 |
|
@@ -25,9 +29,10 @@ iface = gr.Interface(
|
|
25 |
fn=predict_text,
|
26 |
inputs="text",
|
27 |
outputs="text",
|
28 |
-
title="
|
29 |
description="Enter a text, and it will predict the class label.",
|
30 |
)
|
31 |
|
32 |
# Start the Gradio app
|
33 |
iface.launch()
|
|
|
|
4 |
from fastai.text.all import *
|
5 |
|
6 |
|
7 |
+
# Define the path to your model and dataloaders
|
8 |
+
model_path = "origin-classifier-stage-2.pkl"
|
9 |
+
dls_path = "dls_origin-classifier_v1.pkl"
|
10 |
|
11 |
# Load the learner
|
12 |
learner_inf = load_learner(model_path)
|
13 |
|
14 |
+
# Load the DataLoaders
|
15 |
+
dls = torch.load(dls_path)
|
16 |
+
|
17 |
# Create a mapping from class labels to indices
|
18 |
class_label_mapping = {label: idx for idx, label in enumerate(learner_inf.dls.vocab)}
|
19 |
|
|
|
29 |
fn=predict_text,
|
30 |
inputs="text",
|
31 |
outputs="text",
|
32 |
+
title="Text Classification App",
|
33 |
description="Enter a text, and it will predict the class label.",
|
34 |
)
|
35 |
|
36 |
# Start the Gradio app
|
37 |
iface.launch()
|
38 |
+
|
dls_origin-classifier_v1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9300bfb9eaab679fd1147fac44b9dfce671f700cd2e0c61b1ebfd4c1bb60e2df
|
3 |
+
size 345308264
|