Spaces:
Running
Running
Refactored README
Browse files
README.md
CHANGED
|
@@ -27,84 +27,85 @@ In this workshop, you will get hands on experience with:
|
|
| 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
|
| 35 |
|
| 36 |
-
3.
|
| 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 |
```
|
| 42 |
|
| 43 |
-
|
| 44 |
```
|
| 45 |
-
|
| 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 |
-
|
| 52 |
```
|
| 53 |
pip install -r requirements.txt
|
| 54 |
```
|
| 55 |
|
| 56 |
-
|
| 57 |
```
|
| 58 |
python3 app.py
|
| 59 |
```
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
|
| 67 |
-
|
| 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 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
| 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 |
-
|
| 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 |
-
|
| 86 |
Hugging Face user and space name.
|
| 87 |
|
| 88 |
-
|
| 89 |
```
|
| 90 |
git remote add space https://huggingface.co/spaces/andreped/ViT-ImageClassifier
|
| 91 |
```
|
| 92 |
|
| 93 |
-
|
| 94 |
```
|
| 95 |
git push --force space main
|
| 96 |
```
|
| 97 |
|
| 98 |
-
|
| 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 |
-
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
-
|
| 107 |
-
* [Tor-Arne Schmidt Nordmo](https://uit.no/ansatte/person?p_document_id=581687), IFI, UiT: The Arctic University of Norway
|
| 108 |
|
| 109 |
## License
|
| 110 |
|
|
|
|
| 27 |
|
| 28 |
And of course, all of this completely **_FOR FREE_**!
|
| 29 |
|
| 30 |
+
## Workshop Organizers
|
| 31 |
+
|
| 32 |
+
* [André Pedersen](https://github.com/andreped), Apps, Sopra Steria
|
| 33 |
+
* [Tor-Arne Schmidt Nordmo](https://uit.no/ansatte/person?p_document_id=581687), IFI, UiT: The Arctic University of Norway
|
| 34 |
+
|
| 35 |
## Getting Started
|
| 36 |
|
| 37 |
1. Make your first GitHub account by going [here](https://github.com/) and signing up (see top right of website).
|
| 38 |
|
| 39 |
+
2. After logging in, make a copy of the repository by making a fork (click the `fork` button, choose your user as `owner` and click `create fork`).
|
| 40 |
|
| 41 |
+
3. 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):
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
git clone git+https://github.com/<username>/INF1600-ai-workshop.git
|
| 44 |
```
|
| 45 |
|
| 46 |
+
4. After cloning, go inside the repository, and from the terminal run these lines to create a virtual environment and activate it:
|
| 47 |
```
|
| 48 |
+
python3 -m venv venv/
|
| 49 |
source venv/bin/activate
|
| 50 |
```
|
| 51 |
|
| 52 |
On Windows, to activate the virtual environment, run `./venv/Scripts/activate` instead of the `source` command.
|
| 53 |
|
| 54 |
+
5. Install dependencies to the virtual environment by:
|
| 55 |
```
|
| 56 |
pip install -r requirements.txt
|
| 57 |
```
|
| 58 |
|
| 59 |
+
6. To test if everything is working, try to run the following command to launch the web server:
|
| 60 |
```
|
| 61 |
python3 app.py
|
| 62 |
```
|
| 63 |
|
| 64 |
+
7. 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.
|
| 65 |
|
| 66 |
+
8. 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.
|
| 67 |
|
| 68 |
+
9. Try accessing this address from your mobile phone.
|
| 69 |
|
| 70 |
+
10. This should not work, to access the app from a different device, you need to serve it.
|
| 71 |
Try setting `share=True` in the `interface.launch()` call in the `app.py` script.
|
| 72 |
When running `app.py` now, you should be given a different web address. Try using that one instead on your mobile device.
|
| 73 |
|
| 74 |
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**...
|
| 75 |
|
| 76 |
+
11. Click [here](https://huggingface.co/join) to go to the Hugging Face sign up page and make an account.
|
| 77 |
|
| 78 |
+
12. After making an account and logging in, click the `+ New` button on the left of the website and choose `Space` from the dropdown.
|
| 79 |
|
| 80 |
+
13. 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`.
|
| 81 |
|
| 82 |
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!
|
| 83 |
|
| 84 |
+
14. From the Hugging Face website [here](https://huggingface.co), click on your user badge (top right), and from the dropdown clik `Settings`.
|
| 85 |
On the left hand side of `Settings` site, click `Access Tokens`, and then click `New Token`.
|
| 86 |
Set the name `HF_TOKEN`, set permissions to `write`, and click `Generate a token`.
|
| 87 |
|
| 88 |
+
15. On your laptop, open the file located at `.github/workflows/deploy.yml`, and at the last line, replace the `andreped` and `andreped/ViT-ImageClassifier` phrases with your own
|
| 89 |
Hugging Face user and space name.
|
| 90 |
|
| 91 |
+
16. Setup communication with GitHub and Hugging Face by running the follow in the terminal (replace `andreped/ViT-ImageClassifier` like in step 16):
|
| 92 |
```
|
| 93 |
git remote add space https://huggingface.co/spaces/andreped/ViT-ImageClassifier
|
| 94 |
```
|
| 95 |
|
| 96 |
+
17. Then push the code to GitHub by running:
|
| 97 |
```
|
| 98 |
git push --force space main
|
| 99 |
```
|
| 100 |
|
| 101 |
+
The first time, you will be promoted to give your username and password. When giving the password, you need to give the `HF_TOKEN` you defined earlier.
|
| 102 |
+
Go to `Settings > Access Tokens > Select token > Click show`.
|
|
|
|
| 103 |
|
| 104 |
+
18. Now go to your GitHub fork (e.g., `https://github.com/<username>/INF1600-ai-workshop/`) and verify that the code is there.
|
| 105 |
|
| 106 |
+
19. Then click the `Actions` tab to see running workflows. Verify that the workflow ran successfully by clicking the current run and checking workflow status.
|
| 107 |
|
| 108 |
+
20. 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).
|
|
|
|
| 109 |
|
| 110 |
## License
|
| 111 |
|