Spaces:
Sleeping
Sleeping
Add other pipeline
Browse files
app.py
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
|
|
3 |
|
|
|
|
|
4 |
# Handle calls to DistilBERT no LORA
|
5 |
distilBERTnoLORA_pipe = pipeline(model="Intradiction/text_classification_NoLORA")
|
|
|
6 |
|
7 |
def distilBERTnoLORA_fn(text):
|
8 |
return distilBERTnoLORA_pipe(text)
|
9 |
|
|
|
|
|
|
|
10 |
def chat1(message,history):
|
11 |
history = history or []
|
12 |
message = message.lower()
|
@@ -62,14 +69,14 @@ with gr.Blocks(
|
|
62 |
|
63 |
with gr.Column():
|
64 |
with gr.Row(variant="panel"):
|
65 |
-
out = gr.Textbox(label= "
|
66 |
gr.Markdown("""<div>
|
67 |
<span><center><B>Training Information</B><center></span>
|
68 |
<span><br><br><br><br><br></span>
|
69 |
</div>""")
|
70 |
|
71 |
with gr.Row(variant="panel"):
|
72 |
-
out1 = gr.Textbox(label= "
|
73 |
gr.Markdown("""<div>
|
74 |
<span><center><B>Training Information</B><center></span>
|
75 |
<span><br><br><br><br><br></span>
|
@@ -83,7 +90,7 @@ with gr.Blocks(
|
|
83 |
</div>""")
|
84 |
|
85 |
btn.click(fn=distilBERTnoLORA_fn, inputs=inp, outputs=out)
|
86 |
-
btn.click(fn=
|
87 |
btn.click(fn=chat1, inputs=inp, outputs=out2)
|
88 |
|
89 |
with gr.Tab("Natrual Language Infrencing"):
|
@@ -113,14 +120,14 @@ with gr.Blocks(
|
|
113 |
|
114 |
with gr.Column():
|
115 |
with gr.Row(variant="panel"):
|
116 |
-
out = gr.Textbox(label= "
|
117 |
gr.Markdown("""<div>
|
118 |
<span><center><B>Training Information</B><center></span>
|
119 |
<span><br><br><br><br><br></span>
|
120 |
</div>""")
|
121 |
|
122 |
with gr.Row(variant="panel"):
|
123 |
-
out1 = gr.Textbox(label= "
|
124 |
gr.Markdown("""<div>
|
125 |
<span><center><B>Training Information</B><center></span>
|
126 |
<span><br><br><br><br><br></span>
|
@@ -160,14 +167,14 @@ with gr.Blocks(
|
|
160 |
|
161 |
with gr.Column():
|
162 |
with gr.Row(variant="panel"):
|
163 |
-
out = gr.Textbox(label= "
|
164 |
gr.Markdown("""<div>
|
165 |
<span><center><B>Training Information</B><center></span>
|
166 |
<span><br><br><br><br><br></span>
|
167 |
</div>""")
|
168 |
|
169 |
with gr.Row(variant="panel"):
|
170 |
-
out1 = gr.Textbox(label= "
|
171 |
gr.Markdown("""<div>
|
172 |
<span><center><B>Training Information</B><center></span>
|
173 |
<span><br><br><br><br><br></span>
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoTokenizer
|
3 |
+
from peft import AutoPeftModelForSequenceClassification
|
4 |
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
|
6 |
+
loraModel = AutoPeftModelForSequenceClassification.from_pretrained("Intradiction/text_classification_WithLORA")
|
7 |
# Handle calls to DistilBERT no LORA
|
8 |
distilBERTnoLORA_pipe = pipeline(model="Intradiction/text_classification_NoLORA")
|
9 |
+
distilBERTwithLORA_pipe = pipeline("sentiment-analysis", model=loraModel, tokenizer=tokenizer)
|
10 |
|
11 |
def distilBERTnoLORA_fn(text):
|
12 |
return distilBERTnoLORA_pipe(text)
|
13 |
|
14 |
+
def distilBERTwithLORA_fn(text):
|
15 |
+
return distilBERTwithLORA_pipe(text)
|
16 |
+
|
17 |
def chat1(message,history):
|
18 |
history = history or []
|
19 |
message = message.lower()
|
|
|
69 |
|
70 |
with gr.Column():
|
71 |
with gr.Row(variant="panel"):
|
72 |
+
out = gr.Textbox(label= " DistilBERT no LoRA")
|
73 |
gr.Markdown("""<div>
|
74 |
<span><center><B>Training Information</B><center></span>
|
75 |
<span><br><br><br><br><br></span>
|
76 |
</div>""")
|
77 |
|
78 |
with gr.Row(variant="panel"):
|
79 |
+
out1 = gr.Textbox(label= " DistilBERT with LoRA")
|
80 |
gr.Markdown("""<div>
|
81 |
<span><center><B>Training Information</B><center></span>
|
82 |
<span><br><br><br><br><br></span>
|
|
|
90 |
</div>""")
|
91 |
|
92 |
btn.click(fn=distilBERTnoLORA_fn, inputs=inp, outputs=out)
|
93 |
+
btn.click(fn=distilBERTwithLORA_fn, inputs=inp, outputs=out1)
|
94 |
btn.click(fn=chat1, inputs=inp, outputs=out2)
|
95 |
|
96 |
with gr.Tab("Natrual Language Infrencing"):
|
|
|
120 |
|
121 |
with gr.Column():
|
122 |
with gr.Row(variant="panel"):
|
123 |
+
out = gr.Textbox(label= " DistilBERT no LoRA")
|
124 |
gr.Markdown("""<div>
|
125 |
<span><center><B>Training Information</B><center></span>
|
126 |
<span><br><br><br><br><br></span>
|
127 |
</div>""")
|
128 |
|
129 |
with gr.Row(variant="panel"):
|
130 |
+
out1 = gr.Textbox(label= " DistilBERT with LoRA")
|
131 |
gr.Markdown("""<div>
|
132 |
<span><center><B>Training Information</B><center></span>
|
133 |
<span><br><br><br><br><br></span>
|
|
|
167 |
|
168 |
with gr.Column():
|
169 |
with gr.Row(variant="panel"):
|
170 |
+
out = gr.Textbox(label= " DistilBERT no LoRA")
|
171 |
gr.Markdown("""<div>
|
172 |
<span><center><B>Training Information</B><center></span>
|
173 |
<span><br><br><br><br><br></span>
|
174 |
</div>""")
|
175 |
|
176 |
with gr.Row(variant="panel"):
|
177 |
+
out1 = gr.Textbox(label= " DistilBERT with LoRA")
|
178 |
gr.Markdown("""<div>
|
179 |
<span><center><B>Training Information</B><center></span>
|
180 |
<span><br><br><br><br><br></span>
|