Spaces:
Runtime error
Runtime error
Create example.py
Browse files- example.py +17 -0
example.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gradio_client import Client
|
| 2 |
+
from time import time
|
| 3 |
+
|
| 4 |
+
client = Client("AccelerationConsortium/branin")
|
| 5 |
+
result = client.predict(
|
| 6 |
+
3, # float in 'x1' Number component
|
| 7 |
+
3, # float in 'x2' Number component
|
| 8 |
+
api_name="/predict",
|
| 9 |
+
)
|
| 10 |
+
print(result)
|
| 11 |
+
|
| 12 |
+
t0 = time()
|
| 13 |
+
results = [client.predict(_, _, api_name="/predict") for _ in range(10)]
|
| 14 |
+
|
| 15 |
+
print(results)
|
| 16 |
+
|
| 17 |
+
print(f"Elapsed time: {time() - t0:.2f} seconds")
|