nateraw commited on
Commit
9234fab
1 Parent(s): 66abf74

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -1,18 +1,29 @@
1
  import gradio as gr
2
 
3
 
4
- def show_template(name, description, author, url, image_url, more_info=None):
 
 
 
 
 
 
 
5
  with gr.Box():
6
  with gr.Row():
7
  with gr.Column(scale=1):
8
  gr.HTML(f"""<img src="{image_url}" alt="{name}-thumbnail" height=256 width=256>""")
9
  with gr.Column(scale=4):
10
- gr.Markdown(f"""
 
11
  ## {name}
12
  [![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})
13
 
14
  #### {description}
15
- """)
 
 
 
16
  if more_info:
17
  with gr.Row():
18
  with gr.Accordion("👀 More Details", open=False):
@@ -38,7 +49,7 @@ with gr.Blocks(css="style.css") as demo:
38
  show_template(
39
  name="JupyterLab",
40
  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.",
41
- author="nateraw",
42
  url="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true",
43
  image_url="https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/1767px-Jupyter_logo.svg.png",
44
  more_info="""
@@ -46,12 +57,12 @@ with gr.Blocks(css="style.css") as demo:
46
  - You can add dependencies to your JupyterLab instance by editing the `requirements.txt` file.
47
  - You can add linux packages to your JupyterLab instance by editing the `packages.txt` file.
48
  - You can add custom startup commands to your JupyterLab instance by editing the `on_startup.sh` file. These run with the root user.
49
- """
50
  )
51
  show_template(
52
  name="VSCode",
53
  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.",
54
- author="nateraw",
55
  url="https://huggingface.co/spaces/DockerTemplates/vscode?duplicate=true",
56
  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",
57
  more_info="""
 
1
  import gradio as gr
2
 
3
 
4
+ def name_to_hf_markdown(name):
5
+ return f"[{name}](https://huggingface.co/{name})"
6
+
7
+
8
+ def show_template(name, description, authors, url, image_url, more_info=None):
9
+ if isinstance(authors, str):
10
+ authors = [authors]
11
+ authors_md = ", ".join([name_to_hf_markdown(author) for author in authors])
12
  with gr.Box():
13
  with gr.Row():
14
  with gr.Column(scale=1):
15
  gr.HTML(f"""<img src="{image_url}" alt="{name}-thumbnail" height=256 width=256>""")
16
  with gr.Column(scale=4):
17
+ gr.Markdown(
18
+ f"""
19
  ## {name}
20
  [![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})
21
 
22
  #### {description}
23
+
24
+ **Author(s):** {authors_md}
25
+ """
26
+ )
27
  if more_info:
28
  with gr.Row():
29
  with gr.Accordion("👀 More Details", open=False):
 
49
  show_template(
50
  name="JupyterLab",
51
  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.",
52
+ authors=["camenduru", "nateraw"],
53
  url="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true",
54
  image_url="https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/1767px-Jupyter_logo.svg.png",
55
  more_info="""
 
57
  - You can add dependencies to your JupyterLab instance by editing the `requirements.txt` file.
58
  - You can add linux packages to your JupyterLab instance by editing the `packages.txt` file.
59
  - You can add custom startup commands to your JupyterLab instance by editing the `on_startup.sh` file. These run with the root user.
60
+ """,
61
  )
62
  show_template(
63
  name="VSCode",
64
  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.",
65
+ authors=["camenduru", "nateraw"],
66
  url="https://huggingface.co/spaces/DockerTemplates/vscode?duplicate=true",
67
  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",
68
  more_info="""