django_azure_demo/
|_ django_azure_demo/
|_ __init__.py
|_ settings.py
|_ urls.py
|_ wsgi.py
|_ manage.py
|_ db.sqlite3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Train classifier | |
console.log("Training..."); | |
let trainingIteration = await trainer.trainProject(project.id); | |
console.log("Training started..."); | |
while (trainingIteration.status == "Training") { | |
await setTimeoutPromise(1000, null); | |
trainingIteration = await trainer.getIteration(project.id, trainingIteration.id) | |
} | |
console.log("Training status: " + trainingIteration.status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Adding images..."); | |
let fileUploadPromises = []; | |
const pizzaDir = `${dataRoot}/pizza`; | |
const pizzaFiles = fs.readdirSync(pizzaDir); | |
pizzaFiles.forEach(file => { | |
fileUploadPromises.push(trainer.createImagesFromData(project.id, fs.readFileSync(`${pizzaDir}/${file}`), { tagIds: [pizzaTag.id] })); | |
}); | |
await Promise.all(fileUploadPromises); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# index.js | |
// Create project | |
const util = require('util'); | |
const fs = require('fs'); | |
const TrainingApiClient = require("azure-cognitiveservices-customvision-training"); | |
const PredictionApiClient = require("azure-cognitiveservices-customvision-prediction"); | |
const setTimeoutPromise = util.promisify(setTimeout); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .env | |
TRAINING_KEY=<your training key> | |
PREDICTION_KEY=<your prediction key> | |
TRAINING_RESOURCE_ID=<your training resource id> | |
PREDICTION_RESOURCE_ID=<your prediction resource id> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# django_azure_demo/settings.py | |
""" | |
Django settings for django_azure_demo project. | |
Generated by 'django-admin startproject' using Django 1.11.20. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/1.11/topics/settings/ | |
For the full list of settings and their values, see |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
django==2.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="httpPlatformHandler" path="*" verb="*" | |
modules="httpPlatformHandler" resourceType="Unspecified" /> | |
</handlers> | |
<httpPlatform processPath="D:\home\Python364x86\python.exe" arguments="run_waitress_server.py" requestTimeout="00:04:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true"> | |
<environmentVariables> | |
<environmentVariable name="PYTHONPATH" value="D:\home\site\wwwroot" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from waitress import serve | |
from django.core.wsgi import get_wsgi_application | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_azure_demo.settings") | |
application = get_wsgi_application() | |
serve(application,host="0.0.0.0",port=os.environ["PORT"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[config] | |
command = deploy.cmd |
NewerOlder