QubitPi commited on
Commit
71e24bf
1 Parent(s): b69f0eb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import gradio as gr
4
+ import requests
5
+
6
+
7
+ def remote_inference(text):
8
+ url = "http://54.241.102.71:5001/invocations"
9
+
10
+ payload = json.dumps({
11
+ "dataframe_split": {
12
+ "columns": ["text"],
13
+ "data": [[text]]
14
+ }
15
+ })
16
+ headers = {
17
+ 'Content-Type': 'application/json'
18
+ }
19
+
20
+ response = requests.request("POST", url, headers=headers, data=payload)
21
+
22
+ return {
23
+ "nodes": response.json()["predictions"][0]["0"],
24
+ "links": response.json()["predictions"][1]["0"]
25
+ }
26
+
27
+
28
+ iface = gr.Interface(fn=remote_inference, inputs="text", outputs="json")
29
+ iface.launch()