Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
|
|
3 |
|
4 |
-
api_key =
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from os import environ
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
api_key = environ.get("api_key")
|
6 |
|
7 |
+
def app(input, only_relevant_values, relevence_threshold, k ):
|
8 |
+
classifier_pipeline = pipeline(model="gianma/testModel", tokenizer='gianma/testModel', api_key=api_key)
|
9 |
+
|
10 |
+
kwargs = {'padding':True,'truncation':True,'max_length':512}
|
11 |
+
|
12 |
+
if not only_relevant_values:
|
13 |
+
kwargs['top_k'] = k
|
14 |
+
|
15 |
+
res = classifier(input, **kwargs)
|
16 |
+
|
17 |
+
if only_relevant_values:
|
18 |
+
res = {k:v for k,v in res.items() if k >= relevence_threshold}
|
19 |
+
|
20 |
+
return res
|
21 |
+
|
22 |
+
iface = gr.Interface(fn=app,
|
23 |
+
inputs=["text", "checkbox", gr.Slider(0, 1), gr.Slider(1, 21)],
|
24 |
+
outputs="label")
|
25 |
+
|
26 |
+
iface.launch()
|
27 |
+
|
28 |
+
|
29 |
+
#gr.Interface.load("models/gianma/testModel", api_key=api_key).launch()
|