Spaces:
Running
title: 'ViT: Image Classifier'
colorFrom: indigo
colorTo: indigo
sdk: gradio
app_port: 7860
emoji: 🫁
pinned: false
license: mit
app_file: app.py
INF-1600 AI Deployment workshop
This workshop was developed for the "Intro to Artificial Intelligence" course with code INF-1600 at UiT: The Arctic University of Norway.
The workshop was a collaboration with UiT and Sopra Steria.
In this workshop, you will get a prior on:
- Cloning and pushing code from/to GitHub
- Load and run a pretrained image classification model from Transformers.
- Develop a simple web application to enable users to test the model using Gradio.
- Making a web app accessible on the local network
- Making a public web app anyone can access using Hugging Face Spaces.
Getting Started
Make your first GitHub account by going here and signing up.
After logging in to GitHub, go to the code repository here.
Make a fork of the repository and make your own copy of the code by making a fork.
Now you are ready to clone your own fork to your own laptop by opening a terminal and running (remember to replace
<username>
with your own GitHub user name):
git clone git+https://github.com/<username>/INF1600-ai-workshop.git
- After cloning, go inside the repository, and from the terminal run these lines to create a virtual environment and activate it:
virtualenv -ppython3 venv --clear
source venv/bin/activate
TASK: Analyse the
app.py
script which python packages are required, and add the missing dependencies to therequirements.txt
file.Install dependencies to the virtual environment by:
pip install -r requirements.txt
To test if everything is working, try to run the
app.py
script to launch the web server.You can then access the web app by going to http://127.0.0.1:7860 in your favourite web browser.
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.Try accessing this address from your mobile phone.
This should not work, to access the app from a different device, you need to serve it. Try setting
share=True
in theinterface.launch()
call in theapp.py
script. When runningapp.py
now, you should be given a different web address. Try using that one instead.
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...
Click here to go to the Hugging Face sign up page and make an account.
After making an account and logging in, click the
+ New
button on the left of the website and chooseSpace
from the dropdown.In the
Create a new Space
tab, choose aSpace name
for the app, choose a License (preferablyMIT
), among theSpace SDKs
chooseGradio
, and finally, clickCreate Space
.At the bottom of the page, click the
Create
hyperlink at the(Hunt: Create the app.py file (...))
Name the file
app.py
, copy-paste theapp.py
code
Workshop Organizers
- André Pedersen, Apps, Sopra Steria
- Tor-Arne Schmidt Nordmo, IFI, UiT: The Arctic University of Norway
License
The code in this repository is released under MIT license.