Spaces:
Running
Running
Cristóbal Hernández
commited on
Commit
·
4de0aea
1
Parent(s):
f0bac1b
Add application file
Browse files
app.py
CHANGED
@@ -8,8 +8,8 @@ import os
|
|
8 |
#######################
|
9 |
api_key = os.environ.get("HF_API_KEY_INFERENCE")
|
10 |
API_URL = "https://api-inference.huggingface.co/models/chernandezc/distilbert-base-uncased-finetuned-items-multi-label-21122023-AUGMENTED" #Api endpoint.
|
11 |
-
headers = {"Authorization": f"Bearer {api_key}"} #
|
12 |
-
|
13 |
|
14 |
def query(payload): #Function to use the API.
|
15 |
response = requests.post(API_URL, headers=headers, json=payload)
|
@@ -68,11 +68,16 @@ def classify_output(item):
|
|
68 |
|
69 |
txtbx = gr.Textbox(value = 'I would like to feel better', label = 'Please enter your item:', container = 'True')
|
70 |
txtbxopt = gr.Textbox(label = 'The item you provided was classified as:', container = 'True')
|
|
|
71 |
demo = gr.Interface(fn=classify_output, inputs=txtbx, outputs=txtbxopt,
|
72 |
theme = gr.themes.Soft(primary_hue='orange'),
|
73 |
title = 'EEMM Item Classification Machine V 0.5',
|
74 |
description = 'This machine is a fine tuned version of DistillBERT. It classifies items in 7 EEMM dimensions following (ref). **Please note that the machine goes idle after a period of inactivity. If this occurs, waking it up may take around 20 seconds. Be patient ;)**',
|
75 |
-
article = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
|
|
|
|
|
|
|
|
76 |
demo.launch()
|
77 |
|
78 |
|
|
|
8 |
#######################
|
9 |
api_key = os.environ.get("HF_API_KEY_INFERENCE")
|
10 |
API_URL = "https://api-inference.huggingface.co/models/chernandezc/distilbert-base-uncased-finetuned-items-multi-label-21122023-AUGMENTED" #Api endpoint.
|
11 |
+
headers = {"Authorization": f"Bearer {api_key}"} #Api Key.
|
12 |
+
|
13 |
|
14 |
def query(payload): #Function to use the API.
|
15 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
68 |
|
69 |
txtbx = gr.Textbox(value = 'I would like to feel better', label = 'Please enter your item:', container = 'True')
|
70 |
txtbxopt = gr.Textbox(label = 'The item you provided was classified as:', container = 'True')
|
71 |
+
hf_writer = gr.HuggingFaceDatasetSaver(api_key, 'flagging_EEMM_V05')
|
72 |
demo = gr.Interface(fn=classify_output, inputs=txtbx, outputs=txtbxopt,
|
73 |
theme = gr.themes.Soft(primary_hue='orange'),
|
74 |
title = 'EEMM Item Classification Machine V 0.5',
|
75 |
description = 'This machine is a fine tuned version of DistillBERT. It classifies items in 7 EEMM dimensions following (ref). **Please note that the machine goes idle after a period of inactivity. If this occurs, waking it up may take around 20 seconds. Be patient ;)**',
|
76 |
+
article = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
77 |
+
allow_flagging = 'manual',
|
78 |
+
flagging_options = ['Wrong category','Lacks a category'],
|
79 |
+
flagging_callback= hf_writer
|
80 |
+
)
|
81 |
demo.launch()
|
82 |
|
83 |
|