View train_mnist_model.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test_request.py
import cv2 as cv | |
import requests | |
import os | |
# Request info | |
url = "<EAS service URL>" | |
token = "<EAS service token>" | |
headers = { 'Authorization' : token } | |
# Image data |
View index.html
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MNIST Flask app</title> | |
</head> | |
<body> | |
<h1>MNIST image classifier</h1> | |
<form id="upload-form" action="{{ url_for('upload_and_predict') }}" method="POST" enctype="multipart/form-data"> |
View mnist_app.py
from flask import Flask, render_template, url_for, request | |
import os | |
import requests | |
import cv2 as cv | |
app = Flask(__name__) | |
eas_url = "<EAS service URL>" | |
token = "EAS service token" |
View app.json
{ | |
"name": "pai_demo_app", | |
"processor_entry": "./app.py", | |
"processor_type": "python", | |
"processor_path": "oss://eas-model-singpore/<your_user_id>/processor.tar.gz", | |
"data_image": "registry-intl.ap-southeast-1.aliyuncs.com/<your_repository_name>/eas-demo-image", | |
"metadata": { | |
"region": "ap-southeast-1", | |
"instance": 1, | |
"memory": 16, |
View app.py
# -*- coding: utf-8 -*- | |
import allspark | |
import tensorflow as tf | |
import cv2 as cv | |
import numpy as np | |
import math | |
import os | |
import mnist_util |
View mnist_util.py
import cv2 as cv | |
import numpy as np | |
import math | |
def _pad(img): | |
""" Pad input image to get square image. """ | |
(h, w) = img.shape | |
if w > h: | |
diff = w - h |
View train_mnist_model.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View import_data.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.