Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 4.15.0
|
| 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: blocks_js_load
|
| 4 |
+
emoji: 🔥
|
| 5 |
+
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 4.15.0
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
+
hf_oauth: true
|
| 12 |
---
|
|
|
|
|
|
run.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_js_load"]}, {"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", "\n", "def welcome(name):\n", " return f\"Welcome to Gradio, {name}!\"\n", "\n", "js = \"\"\"\n", "function createGradioAnimation() {\n", " var container = document.createElement('div');\n", " container.id = 'gradio-animation';\n", " container.style.fontSize = '2em';\n", " container.style.fontWeight = 'bold';\n", " container.style.textAlign = 'center';\n", " container.style.marginBottom = '20px';\n", "\n", " var text = 'Welcome to Gradio!';\n", " for (var i = 0; i < text.length; i++) {\n", " (function(i){\n", " setTimeout(function(){\n", " var letter = document.createElement('span');\n", " letter.style.opacity = '0';\n", " letter.style.transition = 'opacity 0.5s';\n", " letter.innerText = text[i];\n", "\n", " container.appendChild(letter);\n", "\n", " setTimeout(function() {\n", " letter.style.opacity = '1';\n", " }, 50);\n", " }, i * 250);\n", " })(i);\n", " }\n", "\n", " var gradioContainer = document.querySelector('.gradio-container');\n", " gradioContainer.insertBefore(container, gradioContainer.firstChild);\n", "\n", " return 'Animation created';\n", "}\n", "\"\"\"\n", "with gr.Blocks(js=js) as demo:\n", " inp = gr.Textbox(placeholder=\"What is your name?\")\n", " out = gr.Textbox()\n", " inp.change(welcome, inp, out)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def welcome(name):
|
| 4 |
+
return f"Welcome to Gradio, {name}!"
|
| 5 |
+
|
| 6 |
+
js = """
|
| 7 |
+
function createGradioAnimation() {
|
| 8 |
+
var container = document.createElement('div');
|
| 9 |
+
container.id = 'gradio-animation';
|
| 10 |
+
container.style.fontSize = '2em';
|
| 11 |
+
container.style.fontWeight = 'bold';
|
| 12 |
+
container.style.textAlign = 'center';
|
| 13 |
+
container.style.marginBottom = '20px';
|
| 14 |
+
|
| 15 |
+
var text = 'Welcome to Gradio!';
|
| 16 |
+
for (var i = 0; i < text.length; i++) {
|
| 17 |
+
(function(i){
|
| 18 |
+
setTimeout(function(){
|
| 19 |
+
var letter = document.createElement('span');
|
| 20 |
+
letter.style.opacity = '0';
|
| 21 |
+
letter.style.transition = 'opacity 0.5s';
|
| 22 |
+
letter.innerText = text[i];
|
| 23 |
+
|
| 24 |
+
container.appendChild(letter);
|
| 25 |
+
|
| 26 |
+
setTimeout(function() {
|
| 27 |
+
letter.style.opacity = '1';
|
| 28 |
+
}, 50);
|
| 29 |
+
}, i * 250);
|
| 30 |
+
})(i);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
var gradioContainer = document.querySelector('.gradio-container');
|
| 34 |
+
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
| 35 |
+
|
| 36 |
+
return 'Animation created';
|
| 37 |
+
}
|
| 38 |
+
"""
|
| 39 |
+
with gr.Blocks(js=js) as demo:
|
| 40 |
+
inp = gr.Textbox(placeholder="What is your name?")
|
| 41 |
+
out = gr.Textbox()
|
| 42 |
+
inp.change(welcome, inp, out)
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
demo.launch()
|