Spaces:
Running
Running
Added more steps to the workshop instructions
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ colorFrom: indigo
|
|
| 4 |
colorTo: indigo
|
| 5 |
sdk: gradio
|
| 6 |
app_port: 7860
|
| 7 |
-
emoji:
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
| 10 |
app_file: app.py
|
|
@@ -18,22 +18,24 @@ code INF-1600 at UiT: The Arctic University of Norway.
|
|
| 18 |
|
| 19 |
The workshop was a collaboration with UiT and Sopra Steria.
|
| 20 |
|
| 21 |
-
In this workshop, you will get
|
| 22 |
-
* Cloning and pushing code from/to GitHub
|
| 23 |
-
*
|
| 24 |
-
*
|
| 25 |
-
* Making a web app
|
| 26 |
-
*
|
|
|
|
|
|
|
| 27 |
|
| 28 |
## Getting Started
|
| 29 |
|
| 30 |
-
1. Make your first GitHub account by going [here](https://github.com/) and signing up.
|
| 31 |
|
| 32 |
-
2. After logging in to GitHub, go to the code repository [here](https://github.com/andreped/INF1600-ai-workshop).
|
| 33 |
|
| 34 |
-
3. Make a
|
| 35 |
|
| 36 |
-
4. Now you are ready to clone your own fork to
|
| 37 |
```
|
| 38 |
git clone git+https://github.com/<username>/INF1600-ai-workshop.git
|
| 39 |
```
|
|
@@ -44,27 +46,29 @@ virtualenv -ppython3 venv --clear
|
|
| 44 |
source venv/bin/activate
|
| 45 |
```
|
| 46 |
|
| 47 |
-
|
| 48 |
-
add the missing dependencies to the `requirements.txt` file.
|
| 49 |
|
| 50 |
-
|
| 51 |
```
|
| 52 |
pip install -r requirements.txt
|
| 53 |
```
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
10. Try accessing this address from your mobile phone.
|
| 62 |
|
| 63 |
11. This should not work, to access the app from a different device, you need to serve it.
|
| 64 |
Try setting `share=True` in the `interface.launch()` call in the `app.py` script.
|
| 65 |
-
When running `app.py` now, you should be given a different web address. Try using that one instead.
|
| 66 |
|
| 67 |
-
But of course, hosting the app yourself from your laptop is not ideal. What if there was some alternative way to do this **completely for free**...
|
| 68 |
|
| 69 |
12. Click [here](https://huggingface.co/join) to go to the Hugging Face sign up page and make an account.
|
| 70 |
|
|
@@ -72,9 +76,30 @@ But of course, hosting the app yourself from your laptop is not ideal. What if t
|
|
| 72 |
|
| 73 |
14. In the `Create a new Space` tab, choose a `Space name` for the app, choose a License (preferably `MIT`), among the `Space SDKs` choose `Gradio`, and finally, click `Create Space`.
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
## Workshop Organizers
|
| 80 |
|
|
|
|
| 4 |
colorTo: indigo
|
| 5 |
sdk: gradio
|
| 6 |
app_port: 7860
|
| 7 |
+
emoji: 🔥
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
| 10 |
app_file: app.py
|
|
|
|
| 18 |
|
| 19 |
The workshop was a collaboration with UiT and Sopra Steria.
|
| 20 |
|
| 21 |
+
In this workshop, you will get hands on experience with:
|
| 22 |
+
* Cloning and pushing code from/to [GitHub](https://github.com).
|
| 23 |
+
* Loading and running a pretrained image classification model from [Transformers](https://pypi.org/project/transformers/).
|
| 24 |
+
* Developing a simple web application to enable users to test a pretrained model using [Gradio](https://pypi.org/project/gradio/).
|
| 25 |
+
* Making a public web app anyone can access using [Hugging Face Spaces](https://huggingface.co/spaces).
|
| 26 |
+
* Automizing tasks using [GitHub Actions](https://github.com/features/actions).
|
| 27 |
+
|
| 28 |
+
And of course, all of this completely **_FOR FREE_**!
|
| 29 |
|
| 30 |
## Getting Started
|
| 31 |
|
| 32 |
+
1. Make your first GitHub account by going [here](https://github.com/) and signing up (see top right of website).
|
| 33 |
|
| 34 |
+
2. After logging in to your account on GitHub, go to the code repository [here](https://github.com/andreped/INF1600-ai-workshop).
|
| 35 |
|
| 36 |
+
3. Make a copy of the repository by making a fork (click the `fork` button, choose your user as `owner` and click `create fork`).
|
| 37 |
|
| 38 |
+
4. Now you are ready to clone your own fork to a laptop by opening a terminal and running (remember to replace `<username>` with your own GitHub user name):
|
| 39 |
```
|
| 40 |
git clone git+https://github.com/<username>/INF1600-ai-workshop.git
|
| 41 |
```
|
|
|
|
| 46 |
source venv/bin/activate
|
| 47 |
```
|
| 48 |
|
| 49 |
+
On Windows, to activate the virtual environment, run `./venv/Scripts/activate` instead of the `source` command.
|
|
|
|
| 50 |
|
| 51 |
+
6. Install dependencies to the virtual environment by:
|
| 52 |
```
|
| 53 |
pip install -r requirements.txt
|
| 54 |
```
|
| 55 |
|
| 56 |
+
7. To test if everything is working, try to run the following command to launch the web server:
|
| 57 |
+
```
|
| 58 |
+
python3 app.py
|
| 59 |
+
```
|
| 60 |
|
| 61 |
+
8. You can then access the web app by going to [http://127.0.0.1:7860](http://127.0.0.1:7860) in your favourite web browser.
|
| 62 |
|
| 63 |
+
9. From the prompted website, try clicking one of the image examples and clicking the orange `Submit` button. The model results should show on the right after a few seconds.
|
| 64 |
|
| 65 |
10. Try accessing this address from your mobile phone.
|
| 66 |
|
| 67 |
11. This should not work, to access the app from a different device, you need to serve it.
|
| 68 |
Try setting `share=True` in the `interface.launch()` call in the `app.py` script.
|
| 69 |
+
When running `app.py` now, you should be given a different web address. Try using that one instead on your mobile device.
|
| 70 |
|
| 71 |
+
But of course, hosting the app yourself from your laptop is not ideal. What if there was some alternative way to do this without using your own device **completely for free**...
|
| 72 |
|
| 73 |
12. Click [here](https://huggingface.co/join) to go to the Hugging Face sign up page and make an account.
|
| 74 |
|
|
|
|
| 76 |
|
| 77 |
14. In the `Create a new Space` tab, choose a `Space name` for the app, choose a License (preferably `MIT`), among the `Space SDKs` choose `Gradio`, and finally, click `Create Space`.
|
| 78 |
|
| 79 |
+
We are now given the option to manually add the relevant files, but that is boring... Let's instead try to setup a robot that does that for us!
|
| 80 |
+
|
| 81 |
+
15. From the Hugging Face website [here](https://huggingface.co), click on your user badge (top right), and from the dropdown clik `Settings`.
|
| 82 |
+
On the left hand side of `Settings` site, click `Access Tokens`, and then click `New Token`.
|
| 83 |
+
Set the name `HF_TOKEN`, set permissions to `write`, and click `Generate a token`.
|
| 84 |
+
|
| 85 |
+
16. On your laptop, open the file located at `.github/workflows/deploy.yml`, and at the last line, replace the phrase `andreped/ViT-ImageClassifier` with your own
|
| 86 |
+
Hugging Face user and space name.
|
| 87 |
+
|
| 88 |
+
17. Setup communication with GitHub and Hugging Face by running the follow in the terminal (replace `andreped/ViT-ImageClassifier` like in step 16):
|
| 89 |
+
```
|
| 90 |
+
git remote add space https://huggingface.co/spaces/andreped/ViT-ImageClassifier
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
18. Then push the code to GitHub by running:
|
| 94 |
+
```
|
| 95 |
+
git push --force space main
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
19. Now go to your GitHub fork (e.g., `https://github.com/<username>/INF1600-ai-workshop/`) and verify that the code is there.
|
| 99 |
+
|
| 100 |
+
20. Then click the `Actions` tab to see running workflows. Verify that the workflow ran successfully by clicking the current run and checking workflow status.
|
| 101 |
|
| 102 |
+
21. Finally, we can then head over to our Hugging Face space and check if everything is working. My own app is hosted at [https://huggingface.co/spaces/andreped/ViT-ImageClassifier](https://huggingface.co/spaces/andreped/ViT-ImageClassifier)
|
| 103 |
|
| 104 |
## Workshop Organizers
|
| 105 |
|