Spaces:
Running
Running
router function for ML models via REST API
Browse files
app.py
CHANGED
@@ -9,11 +9,26 @@ anvil.server.connect('55MH4EBKM22EP4E6D5T6CVSL-VGO5X4SM6JEXGJVT')
|
|
9 |
register(get_file)
|
10 |
register(get_files)
|
11 |
|
12 |
-
with gr.Blocks() as block:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
block.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# anvil.server.wait_forever()
|
19 |
|
|
|
9 |
register(get_file)
|
10 |
register(get_files)
|
11 |
|
12 |
+
# with gr.Blocks() as block:
|
13 |
+
# textbox = gr.inputs.Textbox(label='Function Register')
|
14 |
+
# button = gr.Button(value="Show Function Calls")
|
15 |
+
# button.click(get_register,inputs=None,outputs=[textbox])
|
16 |
|
17 |
+
# block.launch()
|
18 |
+
import json
|
19 |
+
import ast
|
20 |
+
def my_inference_function(name):
|
21 |
+
# print(ast.literal_eval(name)['name'])
|
22 |
+
return "Input Data: " + name + ", stay tuned for ML models from this API"
|
23 |
+
|
24 |
+
gradio_interface = gr.Interface(
|
25 |
+
fn=my_inference_function,
|
26 |
+
inputs="text",
|
27 |
+
outputs="text",
|
28 |
+
title="REST API with Gradio and Huggingface Spaces",
|
29 |
+
description='''Inputs should be json of test item e.g., as a dictionary;
|
30 |
+
output right now is just returning the input; later label will be returned'''
|
31 |
+
)
|
32 |
+
gradio_interface.launch()
|
33 |
# anvil.server.wait_forever()
|
34 |
|