CoolFace
Apppublic

SpacesExamples/docker-examples

sourceHugging Faceupdated 2y agoView on Hugging Face
35likes
app.py81 linesDownload Raw Back to root
1import gradio as gr2 3 4def name_to_markdown(name, network):5    if(network == "twitter"):6        return f"[{name}](https://twitter.com/{name})"7    else:8        return f"[{name}](https://huggingface.co/{name})"9        10def show_template(name, description, authors, url, image_url, more_info=None):11    if isinstance(authors, str):12        authors = [authors]13    authors_md = ", ".join([name_to_markdown(author, network) for author, network in authors])14    with gr.Group():15        with gr.Row():16            with gr.Column(scale=1):17                gr.HTML(f'''<img src="{image_url}" alt="{name}-thumbnail" height=256 width=256>''')18            with gr.Column(scale=4):19                gr.Markdown(20                    f"""21                ## {name}22                [![Open In Colab](https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&amp;style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&amp;logoWidth=14)]({url})23 24                #### {description}25 26                **Author(s):** {authors_md}27            """28                )29                if more_info:30                    with gr.Row():31                        with gr.Accordion("๐Ÿ‘€ More Details", open=False):32                            gr.Markdown(more_info)33 34 35title_and_description = """36# Spaces Templates37 38<div align="center">39  <a src="https://img.shields.io/github/stars/nateraw/spaces-docker-templates?style=social" href="https://github.com/nateraw/spaces-docker-templates" target="_blank">40    <img src="https://img.shields.io/github/stars/nateraw/spaces-docker-templates?label=Contribute&style=social" alt="GitHub Stars">41  </a>42 43  <h4>๐Ÿš€ A collection of templates for <a href="https://huggingface.co/spaces">Hugging Face Spaces</a></h4>44 45  The templates below are designed to help you get started with Docker Spaces. Duplicate them to get started with your own project. ๐Ÿค—46</div>47"""48 49with gr.Blocks(css="style.css") as demo:50    gr.Markdown(title_and_description)51    show_template(52        name="JupyterLab",53        description="Spin up a JupyterLab instance with just a couple clicks. This template is great for data exploration, model training, and more. Works on CPU and GPU hardware.",54        authors=[("camenduru", "twitter"), ("nateraw", "huggingface")],55        url="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true",56        image_url="https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/1767px-Jupyter_logo.svg.png",57        more_info="""58        ### Configuration59        - You can add dependencies to your JupyterLab instance by editing the `requirements.txt` file.60        - You can add linux packages to your JupyterLab instance by editing the `packages.txt` file.61        - You can add custom startup commands to your JupyterLab instance by editing the `on_startup.sh` file. These run with the root user.62        """,63    )64    show_template(65        name="VSCode",66        description="Spin up a VSCode instance with just a couple clicks. This template is great for data exploration, model training, and more. Works on CPU and GPU hardware.",67        authors=[("camenduru", "twitter"), ("nateraw", "huggingface")],68        url="https://huggingface.co/spaces/DockerTemplates/vscode?duplicate=true",69        image_url="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Visual_Studio_Code_1.35_icon.svg/1200px-Visual_Studio_Code_1.35_icon.svg.png",70        more_info="""71        ### Configuration72        - You can add dependencies to your VSCode instance by editing the `requirements.txt` file.73        - You can add linux packages to your VSCode instance by editing the `packages.txt` file.74        - You can add custom startup commands to your VSCode instance by editing the `on_startup.sh` file. These run with the root user.75        """,76    )77 78 79if __name__ == "__main__":80    demo.launch()81