Download scripts/demo/gradio_app.py from mukunds/loopformer: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/mukunds/loopformer/resolve/main/scripts/demo/gradio_app.py
- Command line
-
hf download hf://mukunds/loopformer/scripts/demo/gradio_app.py
-
curl -L -o gradio_app.py https://huggingface.co/mukunds/loopformer/resolve/main/scripts/demo/gradio_app.py
1.11 kB
| """The same small queued streaming API for Hugging Face and local serving.""" | |
| from typing import Callable | |
| import gradio as gr | |
| def create_app(predict: Callable, *, model_url: str | None = None) -> gr.Blocks: | |
| with gr.Blocks(title="LoopFormer 路 live inference", analytics_enabled=False) as app: | |
| gr.Markdown("# LoopFormer\nFollow a graph one recurrent loop at a time. " | |
| "This endpoint streams real model predictions; it does not substitute reference answers.") | |
| links = "[Open the interactive playground](https://mukundshankar-dev.github.io/projects/loopformer/demo/)" | |
| if model_url: | |
| links += f" 路 [Download the model]({model_url})" | |
| gr.Markdown(links) | |
| request_input = gr.JSON(label="Graph request: mapping, start, steps") | |
| result = gr.JSON(label="Streamed trace") | |
| run = gr.Button("Run model", variant="primary") | |
| run.click(predict, inputs=request_input, outputs=result, api_name="predict", | |
| concurrency_limit=1, stream_every=0.05) | |
| return app.queue(max_size=16, default_concurrency_limit=1) | |