Spaces:
Running
Running
Deploy TinyModel1Space from GitHub Actions
Browse files- README.md +2 -0
- app.py +5 -3
- requirements.txt +5 -3
README.md
CHANGED
|
@@ -12,3 +12,5 @@ pinned: false
|
|
| 12 |
# TinyModel1Space
|
| 13 |
|
| 14 |
Interactive demo for `HyperlinksSpace/TinyModel1`.
|
|
|
|
|
|
|
|
|
| 12 |
# TinyModel1Space
|
| 13 |
|
| 14 |
Interactive demo for `HyperlinksSpace/TinyModel1`.
|
| 15 |
+
|
| 16 |
+
**Optional:** add a [repository secret](https://huggingface.co/docs/hub/spaces-overview#managing-secrets) named `HF_TOKEN` (read access is enough) so Hub downloads use your token and avoid rate limits.
|
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
MODEL_ID = "HyperlinksSpace/TinyModel1"
|
| 6 |
-
SPACE_URL = "https://
|
| 7 |
_clf = None
|
| 8 |
|
| 9 |
|
|
@@ -63,15 +63,17 @@ EXAMPLES = [
|
|
| 63 |
with gr.Blocks(title="TinyModel1Space") as demo:
|
| 64 |
gr.Markdown("# TinyModel1Space")
|
| 65 |
gr.Markdown("Model: `HyperlinksSpace/TinyModel1`")
|
| 66 |
-
gr.Markdown("Public URL: [https://
|
| 67 |
inp = gr.Textbox(lines=4, label="Input text", placeholder="Paste a news sentence here...")
|
| 68 |
out = gr.Label(num_top_classes=4, label="Predicted class probabilities")
|
| 69 |
status = gr.Textbox(label="Status", interactive=False)
|
| 70 |
run_btn = gr.Button("Run Inference", variant="primary")
|
| 71 |
run_btn.click(fn=predict, inputs=inp, outputs=[out, status])
|
| 72 |
inp.submit(fn=predict, inputs=inp, outputs=[out, status])
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
| 76 |
print(f"Space URL: {SPACE_URL}")
|
|
|
|
| 77 |
demo.launch(ssr_mode=False)
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
MODEL_ID = "HyperlinksSpace/TinyModel1"
|
| 6 |
+
SPACE_URL = "https://huggingface.co/spaces/HyperlinksSpace/TinyModel1Space"
|
| 7 |
_clf = None
|
| 8 |
|
| 9 |
|
|
|
|
| 63 |
with gr.Blocks(title="TinyModel1Space") as demo:
|
| 64 |
gr.Markdown("# TinyModel1Space")
|
| 65 |
gr.Markdown("Model: `HyperlinksSpace/TinyModel1`")
|
| 66 |
+
gr.Markdown("Public URL: [https://huggingface.co/spaces/HyperlinksSpace/TinyModel1Space](https://huggingface.co/spaces/HyperlinksSpace/TinyModel1Space)")
|
| 67 |
inp = gr.Textbox(lines=4, label="Input text", placeholder="Paste a news sentence here...")
|
| 68 |
out = gr.Label(num_top_classes=4, label="Predicted class probabilities")
|
| 69 |
status = gr.Textbox(label="Status", interactive=False)
|
| 70 |
run_btn = gr.Button("Run Inference", variant="primary")
|
| 71 |
run_btn.click(fn=predict, inputs=inp, outputs=[out, status])
|
| 72 |
inp.submit(fn=predict, inputs=inp, outputs=[out, status])
|
| 73 |
+
# Do not pre-run examples at startup (loads model N times; can hang, hit Hub rate limits, or break the Space).
|
| 74 |
+
gr.Examples(examples=EXAMPLES, inputs=inp, cache_examples=False)
|
| 75 |
|
| 76 |
if __name__ == "__main__":
|
| 77 |
print(f"Space URL: {SPACE_URL}")
|
| 78 |
+
demo.queue(default_concurrency_limit=4)
|
| 79 |
demo.launch(ssr_mode=False)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
-
gradio
|
| 2 |
-
transformers
|
| 3 |
-
torch
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==5.49.1
|
| 2 |
+
transformers>=4.40.0,<5
|
| 3 |
+
torch>=2.2.0
|
| 4 |
+
accelerate>=0.26.0
|
| 5 |
+
safetensors>=0.4.0
|