Spaces:
Sleeping
Sleeping
Commit
·
84eed4d
1
Parent(s):
dd3e42b
oooo
Browse files- app.py +22 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import requests
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment"
|
| 7 |
+
|
| 8 |
+
bt = os.environ['HACKAITHONBEARERTOKEN']
|
| 9 |
+
headers = {"Authorization": bt }
|
| 10 |
+
|
| 11 |
+
def query(data):
|
| 12 |
+
response = requests.post(API_URL, headers=headers, json=data)
|
| 13 |
+
return "V2"+str(response.json())
|
| 14 |
+
|
| 15 |
+
def greet(howareyoufeeling):
|
| 16 |
+
output = query({"inputs":howareyoufeeling})
|
| 17 |
+
print (str(output))
|
| 18 |
+
return str(output)
|
| 19 |
+
|
| 20 |
+
iface = gr.Interface(
|
| 21 |
+
fn=greet, inputs=["text"], outputs="text", allow_flagging="never")
|
| 22 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
gradio==3.48.0
|
| 3 |
+
requests
|
| 4 |
+
fastai
|