Первая версия webapp
parent
97463c6b35
commit
5da1ecb2e2
@ -0,0 +1,21 @@
|
||||
{
|
||||
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "flask",
|
||||
"env": {
|
||||
"FLASK_APP": "webApp.py",
|
||||
"FLASK_DEBUG": "1"
|
||||
},
|
||||
"args": ["run", "--no-debugger", "--no-reload"]
|
||||
//"args": [ "5cc5570b-6ed9-3b33-9db4-bdb8ecb9f890", "test-data/lectionAudi/2021-03-12 13-51-19.JPG" ]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,52 +1,41 @@
|
||||
absl-py==1.4.0
|
||||
astunparse==1.6.3
|
||||
cachetools==5.3.0
|
||||
blinker==1.6.2
|
||||
certifi==2023.5.7
|
||||
charset-normalizer==3.1.0
|
||||
flatbuffers==23.5.9
|
||||
gast==0.4.0
|
||||
google-auth==2.18.1
|
||||
google-auth-oauthlib==1.0.0
|
||||
google-pasta==0.2.0
|
||||
grpcio==1.54.2
|
||||
h5py==3.8.0
|
||||
click==8.1.3
|
||||
colorama==0.4.6
|
||||
contourpy==1.1.0
|
||||
cycler==0.11.0
|
||||
filelock==3.12.2
|
||||
Flask==2.3.2
|
||||
fonttools==4.40.0
|
||||
idna==3.4
|
||||
jax==0.4.10
|
||||
keras==2.12.0
|
||||
libclang==16.0.0
|
||||
Markdown==3.4.3
|
||||
MarkupSafe==2.1.2
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
kiwisolver==1.4.4
|
||||
MarkupSafe==2.1.3
|
||||
matplotlib==3.7.1
|
||||
ml-dtypes==0.1.0
|
||||
numpy==1.23.5
|
||||
oauthlib==3.2.2
|
||||
mpmath==1.3.0
|
||||
networkx==3.1
|
||||
numpy==1.25.0
|
||||
opencv-python==4.7.0.72
|
||||
opt-einsum==3.3.0
|
||||
packaging==23.1
|
||||
pandas==2.0.1
|
||||
pandas==2.0.2
|
||||
Pillow==9.5.0
|
||||
protobuf==4.23.1
|
||||
psutil==5.9.5
|
||||
pyparsing==3.1.0
|
||||
python-dateutil==2.8.2
|
||||
pytz==2023.3
|
||||
PyYAML==6.0
|
||||
pyasn1==0.5.0
|
||||
pyasn1-modules==0.3.0
|
||||
requests==2.30.0
|
||||
requests-oauthlib==1.3.1
|
||||
rsa==4.9
|
||||
scipy==1.10.1
|
||||
requests==2.31.0
|
||||
scipy==1.11.0
|
||||
seaborn==0.12.2
|
||||
six==1.16.0
|
||||
tensorboard==2.12.3
|
||||
tensorboard-data-server==0.7.0
|
||||
tensorflow==2.12.0
|
||||
tensorflow-estimator==2.12.0
|
||||
tensorflow-intel==2.12.0
|
||||
tensorflow-io-gcs-filesystem==0.31.0
|
||||
termcolor==2.3.0
|
||||
sympy==1.12
|
||||
torch==2.0.1
|
||||
torchvision==0.15.2
|
||||
tqdm==4.65.0
|
||||
typing_extensions==4.5.0
|
||||
ultralytics==8.0.105
|
||||
urllib3==1.26.15
|
||||
Werkzeug==2.3.4
|
||||
wrapt==1.14.1
|
||||
typing_extensions==4.6.3
|
||||
tzdata==2023.3
|
||||
ultralytics==8.0.123
|
||||
urllib3==2.0.3
|
||||
Werkzeug==2.3.6
|
||||
|
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Анализ аудиторий</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Загрузите изображение в поле ниже, чтобы проверить, на фотография пустая
|
||||
или заполненная аудитория.
|
||||
</p>
|
||||
<form id="uploadForm" action="analyze">
|
||||
<div>
|
||||
<label for="image">Нажмите, чтобы загрузить изображение</label>
|
||||
<input type="file" name="image" id="image" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="ontology">Онтология предметной области</label>
|
||||
<input type="file" name="ontology" id="ontology" />
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit">Отправить</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<img src="" alt="Результат" id="imgslot" />
|
||||
|
||||
<script>
|
||||
document
|
||||
.getElementById("uploadForm")
|
||||
.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const data = new FormData(event.target);
|
||||
fetch("/analyze", { method: "POST", body: data })
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
debugger;
|
||||
if (data.image) {
|
||||
document.getElementById("imgslot").src =
|
||||
"data:image/jpg;base64," + data.image;
|
||||
}
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,36 @@
|
||||
import base64
|
||||
import cv2 as cv
|
||||
from flask import Flask, redirect, request
|
||||
import numpy
|
||||
from imageWorking import get_image_buf_as_array
|
||||
from main import analyze_base
|
||||
|
||||
app = Flask(__name__, static_url_path = "/")
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
return redirect('index.html')
|
||||
|
||||
@app.route("/analyze", methods=["POST"])
|
||||
def analyze():
|
||||
if 'image' not in request.files or request.files['image'].filename == '':
|
||||
return {
|
||||
'success': False,
|
||||
'error': 'Укажите изображение',
|
||||
}
|
||||
if 'ontology' in request.files and request.files['ontology'].filename != '':
|
||||
return {
|
||||
'success': False,
|
||||
'error': 'Загрузка онтологии ещё не реализована',
|
||||
}
|
||||
img = request.files['image'].read();
|
||||
img = numpy.fromstring(img, numpy.uint8)
|
||||
img = get_image_buf_as_array(img)
|
||||
queries = [ 'QueryGetNotEmpty', 'QueryGetCheck', 'QueryGetEmpty' ]
|
||||
results, response = analyze_base('5cc5570b-6ed9-3b33-9db4-bdb8ecb9f890', img, queries)
|
||||
imencoded = cv.imencode(".jpg", results[0].plot())[1]
|
||||
return {
|
||||
'success': True,
|
||||
'data': response,
|
||||
'image': base64.b64encode(imencoded).decode("utf-8"),
|
||||
}
|
Loading…
Reference in New Issue