You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: nbs/blog/posts/2022-11-07-spaces/index.qmd
+25-8Lines changed: 25 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ skip_showdoc: true
12
12
](blog_cover.jpeg)
13
13
14
14
15
-
[Hugging Face Spaces](https://huggingface.co/spaces/launch) provides an easy ways to deploy a web app with python. [Gradio](https://gradio.app/) is one of my favorite tools for building these web apps. For example, the cover-image for this blog post was generated with a [Gradio App](https://huggingface.co/spaces/stabilityai/stable-diffusion)![^1] Gradio also allows you to prototype your web apps in notebooks, which allow you to iterate fast. Unfortunately, Hugging Face Spaces requires you to package your web application code as a python script named `app.py`.
15
+
[Hugging Face Spaces](https://huggingface.co/spaces/launch) provides an easy ways to deploy a web app with python. [Gradio](https://gradio.app/) is one of my favorite tools for building these web apps. For example, the cover-image for this blog post was generated with a [Gradio App](https://huggingface.co/spaces/stabilityai/stable-diffusion)![^1] Gradio also allows you to prototype your web apps in notebooks which allows you to iterate fast. Unfortunately, Hugging Face Spaces requires you to package your web application code as a python script named `app.py`.
16
16
17
17
However, **thanks to [nbdev](https://nbdev.fast.ai), you can deploy a Gradio app to Spaces from a notebook without having to refactor your code into a script!** When you finish this tutorial, you will have an app that looks like this:
18
18
@@ -41,7 +41,21 @@ After you are done creating the space, clone the repo locally. In this example,
41
41
42
42
## 2. Create A Notebook
43
43
44
-
To follow along, create a notebook called `app.ipynb` in the root of your newly cloned repo. Alternatively, a minimal version of this notebook can also be [found here](https://gist.github.com/hamelsmu/35be07d242f3f19063c3a3839127dc67).
44
+
Before getting started you will want to install the dependencies for this tutorial:
Create a notebook called `app.ipynb` in the root of your newly cloned repo. Alternatively, download [the notebook](https://gist.github.com/hamelsmu/35be07d242f3f19063c3a3839127dc67) and follow along.
51
+
52
+
:::{.callout-tip}
53
+
54
+
### Download the notebook and follow along
55
+
56
+
This blog post is a verbose version of the "notebook" you can use to create a Gradio app. However, it can be useful to see just the code without any of the prose. A [concise version of this notebook is here](https://gist.github.com/hamelsmu/35be07d242f3f19063c3a3839127dc67). I recommend taking a look at this notebook during or after you read this blog post.
57
+
58
+
:::
45
59
46
60
## 3. Make an app with Gradio
47
61
@@ -78,12 +92,11 @@ For example, I can check the size of [tglcourse/CelebA-faces-cropped-128](https:
78
92
```python
79
93
size("tglcourse/CelebA-faces-cropped-128")
80
94
```
81
-
82
-
83
-
95
+
:::{.cell-output}
84
96
85
97
'5.49 GB'
86
98
99
+
:::
87
100
88
101
89
102
You can construct a simple UI with the `gradio.interface` and then call the `launch` method of that interface to display a preview in a notebook. This is a great way to test your app to see if it works:
0 commit comments