Upload with huggingface_hub
Browse files- README.md +5 -6
- requirements.txt +1 -0
- run.py +36 -0
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.6
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: calculator_blocks_cached_main
|
4 |
+
emoji: 🔥
|
5 |
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.6
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
|
|
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
https://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
|
run.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
def calculator(num1, operation, num2):
|
5 |
+
if operation == "add":
|
6 |
+
return num1 + num2
|
7 |
+
elif operation == "subtract":
|
8 |
+
return num1 - num2
|
9 |
+
elif operation == "multiply":
|
10 |
+
return num1 * num2
|
11 |
+
elif operation == "divide":
|
12 |
+
return num1 / num2
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column():
|
18 |
+
num_1 = gr.Number()
|
19 |
+
operation = gr.Radio(["add", "subtract", "multiply", "divide"])
|
20 |
+
num_2 = gr.Number()
|
21 |
+
submit_btn = gr.Button(value="Calculate")
|
22 |
+
with gr.Column():
|
23 |
+
result = gr.Number()
|
24 |
+
|
25 |
+
submit_btn.click(calculator, inputs=[num_1, operation, num_2], outputs=[result])
|
26 |
+
examples = gr.Examples(examples=[[5, "add", 3],
|
27 |
+
[4, "divide", 2],
|
28 |
+
[-4, "multiply", 2.5],
|
29 |
+
[0, "subtract", 1.2]],
|
30 |
+
inputs=[num_1, operation, num_2],
|
31 |
+
outputs=[result],
|
32 |
+
fn=calculator,
|
33 |
+
cache_examples=True)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch()
|