This file contains hidden or 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
@app.route("/classify") | |
@cross_origin() | |
def classify_symbol(): | |
json_str = request.args.get('points') | |
if json_str is None: | |
return {"top5": [" ", " ", " ", " ", " "]} | |
json_data = json.loads(json_str) | |
if 'data' not in json_data: | |
return {"top5": [" ", " ", " ", " ", " "]} |
This file contains hidden or 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
order = sorted([str(i) for i in range(1098)]) | |
chars = sorted(set(np.load("data_processed/dataY.npy"))) | |
def fix_predictions(output): | |
outs = [chars[int(order[i.item()])] for i in torch.topk(output, 5, dim = 1).indices[0]] | |
return ["\\" + i.split("_")[1] for i in outs] |
This file contains hidden or 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
model = Model() | |
model.eval() | |
state_dict = torch.load("Test.pt", map_location = torch.device("cpu")) | |
model.load_state_dict(state_dict['model']) | |
size = 32 |
This file contains hidden or 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
from PIL import Image, ImageDraw | |
import numpy as np | |
import torch | |
from train2 import Model | |
from torchvision.transforms import ToTensor |
This file contains hidden or 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
from flask import Flask | |
from flask_cors import CORS, cross_origin | |
app = Flask(__name__) | |
cors = CORS(app) | |
app.config['CORS_HEADERS'] = 'Content-Type' | |
@app.route("/classify") | |
@cross_origin() | |
def classify_symbol(): |
This file contains hidden or 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 | |
import random | |
from shutil import copyfile | |
from tqdm.auto import tqdm | |
size = 32 | |
os.makedirs(f"images_data{size}/train", exist_ok = True) | |
os.makedirs(f"images_data{size}/val", exist_ok = True) | |
os.makedirs(f"images_data{size}/test", exist_ok = True) |
This file contains hidden or 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
function addReTypesetHandler() { | |
var script = document.createElement("script"); | |
script.innerHTML = ` | |
last = "1"; | |
setInterval(function() { | |
var tag = document.getElementsByClassName("invisible")[0]; | |
if (tag.innerHTML != last) { | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub]); | |
last = tag.innerHTML; | |
} |
This file contains hidden or 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
function addClassifyRequestInterval() { | |
setInterval(function() { | |
if (!shouldUpdate) { | |
return | |
} | |
shouldUpdate = false; | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (xhttp.readyState == 4 && xhttp.status == 200) { |
This file contains hidden or 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
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/classify") | |
def classify_symbol(): | |
return {"top5": ["A", "B", "C", "D", "E"]} | |
This file contains hidden or 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
def run_pipeline(pipeline): | |
with depthai.Device(pipeline) as device: | |
q_nn = device.getOutputQueue("nn", maxSize=4, blocking=False) | |
while True: | |
in_nn = q_nn.tryGet() | |
if in_nn is not None: | |
# get data | |
output = in_nn.getAllLayerNames()[-1] | |
data = np.array(in_nn.getLayerFp16(output)) |
NewerOlder