Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.37.2
|
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: timer_main
|
4 |
+
emoji: 🔥
|
5 |
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 4.37.2
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
+
hf_oauth: true
|
12 |
---
|
|
|
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@2943d6d68847314885dc6c5c0247083116017ca0#subdirectory=client/python
|
2 |
+
https://gradio-builds.s3.amazonaws.com/2943d6d68847314885dc6c5c0247083116017ca0/gradio-4.37.2-py3-none-any.whl
|
run.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: timer"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "with gr.Blocks() as demo:\n", " timer = gr.Timer(1)\n", " timestamp = gr.Number(label=\"Time\")\n", " timer.tick(lambda: round(time.time()), outputs=timestamp)\n", " gr.Number(lambda: round(time.time()), label=\"Time 2\", every=1)\n", "\n", " with gr.Row():\n", " timestamp_3 = gr.Number()\n", " start_btn = gr.Button(\"Start\")\n", " stop_btn = gr.Button(\"Stop\")\n", "\n", " time_3 = start_btn.click(lambda: round(time.time()), None, timestamp_3, every=1)\n", " stop_btn.click(fn=None, cancels=time_3)\n", "\n", " with gr.Row():\n", " min = gr.Number(1, label=\"Min\")\n", " max = gr.Number(10, label=\"Max\")\n", " timer2 = gr.Timer(1)\n", " number = gr.Number(lambda a, b: random.randint(a, b), inputs=[min, max], every=timer2, label=\"Random Number\")\n", " with gr.Row():\n", " gr.Button(\"Start\").click(lambda: gr.Timer(active=True), None, timer2)\n", " gr.Button(\"Stop\").click(lambda: gr.Timer(active=False), None, timer2)\n", " gr.Button(\"Go Fast\").click(lambda: 0.2, None, timer2)\n", " gr.Button(\"Go Slow\").click(lambda: 2, None, timer2)\n", " \n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
import time
|
4 |
+
|
5 |
+
with gr.Blocks() as demo:
|
6 |
+
timer = gr.Timer(1)
|
7 |
+
timestamp = gr.Number(label="Time")
|
8 |
+
timer.tick(lambda: round(time.time()), outputs=timestamp)
|
9 |
+
gr.Number(lambda: round(time.time()), label="Time 2", every=1)
|
10 |
+
|
11 |
+
with gr.Row():
|
12 |
+
timestamp_3 = gr.Number()
|
13 |
+
start_btn = gr.Button("Start")
|
14 |
+
stop_btn = gr.Button("Stop")
|
15 |
+
|
16 |
+
time_3 = start_btn.click(lambda: round(time.time()), None, timestamp_3, every=1)
|
17 |
+
stop_btn.click(fn=None, cancels=time_3)
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
min = gr.Number(1, label="Min")
|
21 |
+
max = gr.Number(10, label="Max")
|
22 |
+
timer2 = gr.Timer(1)
|
23 |
+
number = gr.Number(lambda a, b: random.randint(a, b), inputs=[min, max], every=timer2, label="Random Number")
|
24 |
+
with gr.Row():
|
25 |
+
gr.Button("Start").click(lambda: gr.Timer(active=True), None, timer2)
|
26 |
+
gr.Button("Stop").click(lambda: gr.Timer(active=False), None, timer2)
|
27 |
+
gr.Button("Go Fast").click(lambda: 0.2, None, timer2)
|
28 |
+
gr.Button("Go Slow").click(lambda: 2, None, timer2)
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
demo.launch()
|