Spaces:
Sleeping
Sleeping
Lokesh Jirati
commited on
Commit
·
338c070
1
Parent(s):
814fe95
Add application file
Browse files- app.py +25 -39
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,40 +1,26 @@
|
|
| 1 |
-
# ----------- Triton Model Code Starts Below -------------
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
import triton_python_backend_utils as pb_utils
|
| 5 |
import numpy as np
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
inference_response = pb_utils.InferenceResponse(
|
| 33 |
-
output_tensors=[out_tensor_0, out_tensor_1]
|
| 34 |
-
)
|
| 35 |
-
responses.append(inference_response)
|
| 36 |
-
|
| 37 |
-
return responses
|
| 38 |
-
|
| 39 |
-
def finalize(self):
|
| 40 |
-
print("Cleaning up...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def add_and_subtract(input0, input1):
|
| 5 |
+
input0 = np.array(input0)
|
| 6 |
+
input1 = np.array(input1)
|
| 7 |
+
|
| 8 |
+
out0 = input0 + input1
|
| 9 |
+
out1 = input0 - input1
|
| 10 |
+
return out0.tolist(), out1.tolist()
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=add_and_subtract,
|
| 14 |
+
inputs=[
|
| 15 |
+
gr.Textbox(label="Input 0 (comma-separated numbers)"),
|
| 16 |
+
gr.Textbox(label="Input 1 (comma-separated numbers)")
|
| 17 |
+
],
|
| 18 |
+
outputs=[
|
| 19 |
+
gr.Textbox(label="Output 0 (Sum)"),
|
| 20 |
+
gr.Textbox(label="Output 1 (Difference)")
|
| 21 |
+
],
|
| 22 |
+
title="Add and Subtract Arrays"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
numpy
|