Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,598 Bytes
a791472 dbf5fb1 a791472 8d6d31e a791472 8d6d31e a791472 dbf5fb1 a791472 85c9d88 a791472 85c9d88 a791472 85c9d88 dbf5fb1 7162f12 8d6d31e a791472 4bd209d 7162f12 a791472 7521f79 a791472 7162f12 dbf5fb1 5e55606 7162f12 7521f79 95c3150 7162f12 dbf5fb1 85c9d88 7162f12 dbf5fb1 a791472 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import gradio as gr
from markup import highlight, get_text
from template import get_templates
templates = get_templates()
def change(inp):
"""Based on an `inp`, render and highlight the appropriate code sample.
Args:
inp (`str`):
The input button from the interface.
Returns:
`tuple`: A tuple of the highlighted code diff, and the title for the section.
"""
code, explanation, docs = get_text(inp)
if inp == "Basic":
return (highlight(code), "## Accelerate Code (Base Integration)", explanation, docs)
elif inp == "Calculating Metrics":
return (highlight(code), f"## Accelerate Code ({inp})", explanation, docs)
else:
return (highlight(code), f"## Accelerate Code ({inp})", explanation, docs)
default = change("Basic")
with gr.Blocks() as demo:
inp = gr.Radio(
["Basic", "Calculating Metrics", "Checkpointing", "Experiment Tracking", "Gradient Accumulation"],
label="Select a feature you would like to integrate",
value="Basic"
)
with gr.Row():
with gr.Column():
feature = gr.Markdown("## Accelerate Code")
out = gr.Markdown(default[0])
with gr.Row():
with gr.Column():
gr.Markdown(default[1])
explanation = gr.Markdown(default[2])
with gr.Row():
with gr.Column():
gr.Markdown("## Documentation Links")
docs = gr.Markdown(default[3])
inp.change(
fn=change,
inputs=inp,
outputs=[out, feature, explanation, docs]
)
demo.launch() |