{"id":18785288,"url":"https://github.com/andreped/inf1600-ai-workshop","last_synced_at":"2025-04-13T12:33:48.173Z","repository":{"id":206821383,"uuid":"717711318","full_name":"andreped/INF1600-ai-workshop","owner":"andreped","description":"🔥 Workshop in AI Deployment (INF-1600, UiT)","archived":false,"fork":false,"pushed_at":"2023-11-14T16:07:52.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T05:36:27.216Z","etag":null,"topics":["artificial-intelligence","demonstration","github","github-actions","gradio","huggingface","huggingface-spaces","image-classification","transformers","vision-transformers","vit","web-application"],"latest_commit_sha":null,"homepage":"https://huggingface.co/spaces/andreped/ViT-ImageClassifier","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreped.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-12T10:48:10.000Z","updated_at":"2024-01-14T13:00:26.000Z","dependencies_parsed_at":"2024-11-07T20:47:00.549Z","dependency_job_id":"ea61da27-8f36-47d5-aea4-a30fc68ad88e","html_url":"https://github.com/andreped/INF1600-ai-workshop","commit_stats":null,"previous_names":["andreped/inf1600-ai-workshop"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2FINF1600-ai-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2FINF1600-ai-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2FINF1600-ai-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreped%2FINF1600-ai-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreped","download_url":"https://codeload.github.com/andreped/INF1600-ai-workshop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248714736,"owners_count":21149958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","demonstration","github","github-actions","gradio","huggingface","huggingface-spaces","image-classification","transformers","vision-transformers","vit","web-application"],"created_at":"2024-11-07T20:46:10.455Z","updated_at":"2025-04-13T12:33:47.618Z","avatar_url":"https://github.com/andreped.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: 'ViT: Image Classifier'\ncolorFrom: indigo\ncolorTo: indigo\nsdk: gradio\napp_port: 7860\nemoji: 🔥\npinned: false\nlicense: mit\napp_file: app.py\n---\n\n\u003cimg width=\"1082\" alt=\"example_3\" src=\"https://github.com/andreped/INF1600-ai-workshop/assets/29090665/0a1817e6-3561-4b85-b90c-c7f7989d72a3\"\u003e\n\n# INF-1600 AI Deployment workshop\n\n[![license](https://img.shields.io/github/license/DAVFoundation/captain-n3m0.svg?style=flat-square)](https://github.com/raidionics/AeroPath/blob/main/LICENSE.md)\n\u003ca target=\"_blank\" href=\"https://huggingface.co/spaces/andreped/ViT-ImageClassifier\"\u003e\u003cimg src=\"https://img.shields.io/badge/🤗%20HF%20ViT-ImageClassifier-yellow.svg\"\u003e\u003c/a\u003e\n\u003ca target=\"_blank\" href=\"https://huggingface.co/spaces/andreped/vit-explainer\"\u003e\u003cimg src=\"https://img.shields.io/badge/🤗%20HF%20ViT-Explainer-yellow.svg\"\u003e\u003c/a\u003e\n\nThis workshop was developed for the _\"Intro to Artificial Intelligence\"_ course at UiT: The Arctic University of Norway in collaboration with Sopra Steria.\n\nIn this workshop, you will get hands on experience with:\n* Cloning and pushing code from/to [GitHub](https://github.com).\n* Loading and running a pretrained image classification model from [Transformers](https://pypi.org/project/transformers/).\n* Developing a simple web application to enable users to test a pretrained model using [Gradio](https://pypi.org/project/gradio/).\n* Making a public web app anyone can access using [Hugging Face Spaces](https://huggingface.co/spaces).\n* Automizing tasks using [GitHub Actions](https://github.com/features/actions).\n* Explainable AI of Vision Transformers using [transformers-interpret](https://github.com/cdpierse/transformers-interpret).\n\nAnd of course, all of this completely **_FOR FREE_**!\n\nSome truely amazing saliency maps were submitted from the students. The submitted images are made available in [Releases](https://github.com/andreped/INF1600-ai-workshop/releases/tag/Student-Examples).\n\n## Workshop Organizers\n\n* [André Pedersen](https://github.com/andreped), Apps, Sopra Steria\n* [Tor-Arne Schmidt Nordmo](https://uit.no/ansatte/person?p_document_id=581687), IFI, UiT: The Arctic University of Norway\n\n## Demo\n\n\u003cimg width=\"1314\" alt=\"Screenshot 2023-11-12 at 22 22 52\" src=\"https://github.com/andreped/INF1600-ai-workshop/assets/29090665/828c390c-f179-48a6-85dc-19d207a0c42c\"\u003e\n\n## Getting Started\n\n1. Make your first GitHub account by going [here](https://github.com/) and signing up (see top right of website).\n\n2. 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`).\n\n3. Now you are ready to clone your own fork to a laptop by opening a terminal and running (remember to replace `\u003cusername\u003e` with your own GitHub user name):\n```\ngit clone https://github.com/\u003cusername\u003e/INF1600-ai-workshop.git\n```\nMove into the new directory:\n```\ncd INF-1600-ai-workshop\n```\n\n\n4. After cloning, go inside the repository, and from the terminal run these lines to create a virtual environment and activate it:\n```\npython3 -m venv venv/\nsource venv/bin/activate\n```\n\nOn Windows, to activate the virtual environment, run `./venv/Scripts/activate` instead of the `source` command.\n\n5. Install dependencies to the virtual environment by:\n```\npip install -r requirements.txt\n```\n\n6. To test if everything is working, try to run the following command to launch the web server:\n```\npython app.py\n```\n\n7. 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.\n\n8. 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.\n\n9. Try accessing this address from your mobile phone.\n\n10. This should not work, to access the app from a different device, you need to serve it.\nTry setting `share=True` in the `interface.launch()` call in the `app.py` script.\nWhen running `app.py` now, you should be given a different web address. Try using that one instead on your mobile device.\n\nBut 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**...\n\n11. Click [here](https://huggingface.co/join) to go to the Hugging Face sign up page and make an account.\n\n12. After making an account and logging in, click the `+ New` button on the left of the website and choose `Space` from the dropdown.\n\n13. 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`.\n\nWe 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!\n\n14. From the Hugging Face website [here](https://huggingface.co), click on your user badge (top right), and from the dropdown click `Settings`.\nOn the left hand side of `Settings` site, click `Access Tokens`, and then click `New Token`.\nSet the name `HF_TOKEN`, set permissions to `write`, and click `Generate a token`.\n\n15. Then you need to make the same token available in your GitHub fork. Go to your fork, go the the repo `Settings \u003e Secrets and variables \u003e Actions` and click the green `New repository secret`. Set `HF_TOKEN` as `name` and copy the TOKEN you created previously on Hugging Face by going to `Hugging Face \u003e Settings \u003e Access Tokens \u003e Select token \u003e Click show`.\n\n15. 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\nHugging Face user and space name.\n\n16. Setup communication with GitHub and Hugging Face by running the follow in the terminal (replace `andreped/ViT-ImageClassifier` like in step 16):\n```\ngit remote add space https://huggingface.co/spaces/andreped/ViT-ImageClassifier\n```\n\n17. Then push the code to HuggingFace by running to enable syncronization (only needed to do once):\n```\ngit push --force space main\n```\n\nThe 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.\nGo to `Settings \u003e Access Tokens \u003e Select token \u003e Click show`.\n\n18. Then push the code to GitHub by:\n```\ngit add .\ngit commit -m \"Some changes\"\ngit push\n```\n\n19. Now go to your GitHub fork (e.g., `https://github.com/\u003cusername\u003e/INF1600-ai-workshop/`) and verify that the code is there.\n\n20. Then click the `Actions` tab to see running workflows. Verify that the workflow ran successfully by clicking the current run and checking workflow status.\n\n21. 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).\n\n## Bonus task for speedy bois and gals\n\nBased on this app, we have extended it to enable interpretation of the AI model. This technique is called Explainable AI (XAI).\n\nIf you want, you can try to reproduce the steps above with [this other repo](https://github.com/andreped/vit-explainer).\n\nYou can click the badge to access the deployed app on Hugging Face: \u003ca target=\"_blank\" href=\"https://huggingface.co/spaces/andreped/vit-explainer\"\u003e\u003cimg src=\"https://img.shields.io/badge/🤗%20Hugging%20Face-Spaces-yellow.svg\"\u003e\u003c/a\u003e\n\n\u003cimg width=\"1283\" alt=\"282330601-1fe47bb5-625d-4717-9348-53930d5129dc\" src=\"https://github.com/andreped/INF1600-ai-workshop/assets/29090665/45fde51d-b956-4e70-b9c4-e2e61ced66de\"\u003e\n\n## License\n\nThe code in this repository is released under [MIT license](https://github.com/andreped/INF1600-ai-workshop).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreped%2Finf1600-ai-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreped%2Finf1600-ai-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreped%2Finf1600-ai-workshop/lists"}