This repository contains a step-by-step guide to building and deploying a classifier using IBM CV Studio and Convolutional Neural Networks (CNN) with PyTorch.
If you have already applied your IBM Cloud feature code in another course/lab to create an IBM Cloud account, please skip this item, as the code can only be used once.
Important
While signing up for an IBM Cloud account, or at a later stage, you may be prompted to enter a credit card. Please note that access to paid services or a credit card is NOT required to complete any mandatory labs/projects/assignments here. Those who have a Feature Code can enable trial access to IBM Cloud for a limited duration. Therefore, we strongly recommend that you DO NOT enter a credit card to complete the required course components.
Note
You can get a Feature Code for your academic institute (if it's included) from Cloud for Education or from the course Introduction to Computer Vision and Image Processing.
Warning
If you still choose to enter your Credit Card to use IBM Cloud services, you will be liable to pay any resulting charges billed to your credit card.
When building Computer Vision applications, we deal with a lot of images, videos, and other assets that require storage. Image processing also requires significant computing power. The ultimate goal of every computer vision project is to have it deployed as part of an application, and every application requires infrastructure to run.
To help you with your learning, IBM is providing storage, compute, and application infrastructure on the cloud. To use these resources, you need to have an IBM Cloud account. This account is free of charge and does not require any commitment. If you already have an account on IBM Cloud, go ahead to the next section; otherwise, follow the steps below to create an IBM Cloud account and associate CV Studio with this account.
You will need an IBM Cloud account to do this lab. If you have not created one already, click on this link and follow the instructions to create an IBM Cloud account.
- Go to CV Studio
- Click on
My Projectsin the top right corner. - Click
Sign into IBM Cloudat the top right corner.
Congratulations! Your learning environment is all set with access to storage, compute, and application infrastructure. Please remember your IBM Cloud ID and password. You will need them to log in if prompted.
To train your classifier, you will need to download the dataset containing the "Stop" sign images found here and the "not Stop" sign images found here. They are zipped in a folder.
- Click on Launch App.
- Sign in with your created credentials if prompted.
- Select the template for this project.
Unzipthe files, then drag and drop the folders into theUploadsection in CV Studio.- Make sure to wait between each folder to ensure that it has loaded properly.
- Confirm that images have been loaded.
- In the
annotatesection, you will see that the images are pre-labeled with the folder name.
Proceed to the next task once you have gathered and uploaded your images and verified that your images are pre-labeled in the Annotation tab of CV Studio.
Create your own Train run:
- Click on
Train Modelon the side panel. - Create a
New training run, enter aName, chooseJupyter notebookas a "Training tool", and selectConvolutional Neural Networks (CNN) with PyTorch.
Tip
You can run the notebook by clicking Open Notebook in the TRAIN column. It will open a Skill Network Labs and run the train-classification-cnn-pytorch.ipynb after uploading it.
- Click on
Use ModelandNew Application.
- When you click
New Application, enter an app name, chooseModels in this project, use the saved train model, and choose theTest-1-click Deploy your Model to Cloud (Code Engine)and create the application.
- Once you are done, it will start deploying and tell you when it is ready.
Tip
By clicking URL you will redirect to the webpage that you can classify your own images on browser.
- Once it is ready, you will see the green READY button:
- Click on
Open Notebookto open the Jupyter notebook from the Train model phase.
Note
Make sure that the result of the training model is visible under Details of Run.
- Add the below-mentioned code by adding a cell to the end of the model training notebook. Note: It's already added to the
train-classification-cnn-pytorch.ipynb.
imageNames = ['stop_1.jpeg','stop_2.jpeg','not_stop_1.jpeg']
for imageName in imageNames:
image = Image.open(imageName)
transform = composed = transforms.Compose([transforms.Resize((224, 224)), transforms.ToTensor()])
x = transform(image)
z = model(x.unsqueeze_(0))
_, yhat = torch.max(z.data, 1)
# print(yhat)
prediction = "Stop"
if yhat == 1:
prediction = "Not Stop"
imshow_(transform(image), imageName + ": Prediction = " + prediction)- Now, download the test images.
- You will find test images here. Note: if you are using Firefox, please right-click the link and select Save
Link As.
- Then, upload the images to the Skill Network Labs.
- After uploading the images, Run the code for testing your classifier.
Take a screenshot of the following image after the prediction. You can find how to take a screenshot for Mac here and Windows here
Your prediction will show at the top.
You have successfully trained, deployed, and tested your classifier using IBM CV Studio and CNN.
- Introduction to Computer Vision and Image Processing by IBM on Cousera







