PowerShell Instructions
If you are configuring your own server, continue with the steps below to run the PowerShell script.
Setup
First, make sure you have set up your SQL Server by following these instructions. Then proceed with the steps below to run the solution template using the automated PowerShell file.
Execute PowerShell Script
Running this PowerShell script will create the data tables and stored procedures for the the operationalization of this solution in R in the ImageSimilarity
database. It will also execute these procedures to create full database with results of the steps – dataset creation, modeling, and scoring as described here.
-
Log onto the machine that contains the SQL Server you wish to use.
-
Download ImageSimilaritySetup.ps1 to your computer.
-
Open a command or PowerShell window as Administrator.
-
CD to the directory where you downloaded the above .ps1 file and execute the command:
.\ImageSimilaritySetup.ps1
-
Answer the prompts.
This will make the following modification to your SQL Server:
- Creates the SLQRUserGroup for running R and Python code.
- Reconfigures SQL Server to allow running of external scripts.
- Updates SQL Server version of Python to match the standalone ML Server Python version.
- Enables firewall access for FILESTREAM
- Enables FILESTREAM at the SQL instance level as described here.
- Copies the Resnet model needed for this solution into the correct directory.
- Clones the solution code and data into the c:\Solutions\ImageSimilarity directory.
- Installs the image_similarity Python package.
- Creates the solution database
ImageSimilarity
- Calls LoadImageData.ps1 to:
- Copy images to the configured filestream directory.
- Run the solution workflow to populate all database tables.
Review Data
Once the PowerShell script has completed successfully, log into the SQL Server Management Studio to view all the datasets that have been created in the ImageSimilarity_Py
databases.
Hit Refresh
if necessary.
Click here to view the details all tables created in this solution.
Trying the Model
You’ve now finsihed the process of featurizing images using pre-trained DNN model, preparing the training/testing/evaluation image set, training a multi-class classifier and saving the model into SQL table as described here.
This PowerShell script also created the stored procedures to perform these tasks as well as a procedure that can be used to return top K similar candidates for new query images.
You can explore this solution in more detail by examining the folders and running Python or stored procedures to re-create the model, or skip to trying out the model in the included Test Model.ipynb Jupyter notebook.