@ -0,0 +1,8 @@
|
||||
{
|
||||
"semi": true,
|
||||
"trailingComma": "all",
|
||||
"singleQuote": true,
|
||||
"printWidth": 160,
|
||||
"tabWidth": 2,
|
||||
"endOfLine": "auto"
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="webApp" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="VideoAnalysis" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="FLASK_APP" value="src/webApp.py" />
|
||||
<env name="FLASK_DEBUG" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="flask" />
|
||||
<option name="PARAMETERS" value="run" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="true" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
|
||||
// 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": "src/webApp.py",
|
||||
"FLASK_DEBUG": "1"
|
||||
},
|
||||
"args": ["run", "--no-debugger", "--no-reload"]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
|
||||
def is_ontology_exists(uid: str, url: str) -> bool:
|
||||
'''
|
||||
Проверяет, существует ли онтология в сервисе.
|
||||
@param uid: УИД онтологии.
|
||||
@param url: Базовый URL сервиса.
|
||||
'''
|
||||
list_ontologies = requests.get(url).json()['response']['items']
|
||||
for onto in list_ontologies:
|
||||
if onto['uid'] == uid:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def rename_entity(list_names: dict) -> dict:
|
||||
'''
|
||||
Нормализация названий объектов.
|
||||
@param list_names: Список названий объектов.
|
||||
'''
|
||||
temp_list = list()
|
||||
for entity in list_names.values():
|
||||
entity: str
|
||||
temp_list.append(entity.title().replace(' ', ''))
|
||||
return temp_list
|
||||
|
||||
|
||||
def get_entity_square(width: float, height: float) -> float:
|
||||
'''
|
||||
Получение площади занимаемой области.
|
||||
@param width: Ширина области в px.
|
||||
@param height: Высота области в px.
|
||||
'''
|
||||
return abs(width * height)
|
||||
|
||||
|
||||
def get_request_data(entities: dict, objects: np.ndarray, confs: np.ndarray, boxes: np.ndarray) -> tuple[list, list]:
|
||||
'''
|
||||
Формирование данных для сервиса онтологий.
|
||||
@param entities: Список имён объектов.
|
||||
@param results_ndarray: Результат распознавания объектов.
|
||||
'''
|
||||
classroom = 'classroom'
|
||||
entities = rename_entity(entities)
|
||||
object_properties = list()
|
||||
data_properties = list()
|
||||
|
||||
for entity_idx, entity in enumerate(entities):
|
||||
if (entity_idx in objects):
|
||||
object_properties.append({'domain': entity, 'property': 'locatedIn', 'range': classroom})
|
||||
else:
|
||||
object_properties.append({'domain': entity, 'property': 'notLocatedIn', 'range': classroom})
|
||||
|
||||
for object_idx, object in enumerate(objects):
|
||||
conf = confs[object_idx]
|
||||
box = boxes[object_idx]
|
||||
entity = entities[object.item()]
|
||||
data_properties.append({'domain': entity, 'property': 'hasArea', 'value': get_entity_square(float(box[2]), float(box[3]))})
|
||||
data_properties.append({'domain': entity, 'property': 'hasConfidence', 'value': float(conf)})
|
||||
|
||||
return object_properties, data_properties
|
@ -1,50 +0,0 @@
|
||||
absl-py==1.4.0
|
||||
astunparse==1.6.3
|
||||
cachetools==5.3.0
|
||||
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
|
||||
idna==3.4
|
||||
jax==0.4.10
|
||||
keras==2.12.0
|
||||
libclang==16.0.0
|
||||
Markdown==3.4.3
|
||||
MarkupSafe==2.1.2
|
||||
matplotlib==3.7.1
|
||||
ml-dtypes==0.1.0
|
||||
numpy==1.23.5
|
||||
oauthlib==3.2.2
|
||||
opencv-python==4.7.0.72
|
||||
opt-einsum==3.3.0
|
||||
packaging==23.1
|
||||
pandas==2.0.1
|
||||
Pillow==9.5.0
|
||||
protobuf==4.23.1
|
||||
psutil==5.9.5
|
||||
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
|
||||
six==1.16.0
|
||||
tensorboard==2.12.3
|
||||
tensorboard-data-server==0.7.0
|
||||
tensorflow_macos==2.12.0
|
||||
tensorflow-estimator==2.12.0
|
||||
termcolor==2.3.0
|
||||
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
|
@ -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
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,53 @@
|
||||
const renderResultMarkup = (query, result) =>
|
||||
`
|
||||
<h1 class="display-6">${query}</h1>
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr>
|
||||
${result.columns.map((column) => `<th>${column}</th>`).join('')}
|
||||
</tr>
|
||||
${result.rows.map(
|
||||
(row) =>
|
||||
`<tr>${Object.entries(row)
|
||||
.map(([key, value]) => `<td>${value.value}</td>`)
|
||||
.join('')}</tr>`,
|
||||
)}
|
||||
</table>`;
|
||||
|
||||
const processAnalyzeResult = (data) => {
|
||||
const img = document.getElementById('imgslot');
|
||||
const queriesResult = document.getElementById('queriesResult');
|
||||
|
||||
img.src = 'none.png';
|
||||
if (data.image) {
|
||||
img.src = 'data:image/jpg;base64,' + data.image;
|
||||
}
|
||||
|
||||
queriesResult.innerHTML = '';
|
||||
if (data.data && data.data.response) {
|
||||
for (const [query, result] of Object.entries(data.data.response)) {
|
||||
queriesResult.innerHTML += renderResultMarkup(query, result);
|
||||
}
|
||||
} else if (data.data && data.data.error) {
|
||||
queriesResult.innerHTML = `<div class="alert alert-danger">${JSON.stringify(data.data.error)}</div>`;
|
||||
}
|
||||
};
|
||||
|
||||
const handleFormSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
const data = new FormData(event.target);
|
||||
const loaderWrapper = document.getElementById('loaderWrapper');
|
||||
loaderWrapper.classList.remove('d-none');
|
||||
fetch('/analyze', { method: 'POST', body: data })
|
||||
.then((res) => res.json())
|
||||
.then(processAnalyzeResult)
|
||||
.catch(() => {
|
||||
alert('Произошла внутренняя ошибка.');
|
||||
})
|
||||
.finally(() => {
|
||||
loaderWrapper.classList.add('d-none');
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById('uploadForm').addEventListener('submit', handleFormSubmit);
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
#wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
#loaderWrapper {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: #33333333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
Loading…
Reference in New Issue