Add support of multi queries
This commit is contained in:
parent
4916198aab
commit
e1e4704659
16
main.py
16
main.py
@ -22,7 +22,6 @@ def analyse_file(uid, image_path):
|
|||||||
raise Exception(f'Изображение {image_path} не существует')
|
raise Exception(f'Изображение {image_path} не существует')
|
||||||
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
|
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
|
||||||
model.names = neuralNetwork.rename_entity(model.names)
|
model.names = neuralNetwork.rename_entity(model.names)
|
||||||
list_sqwrl = ontologyWorking.get_list_sqwrl(uid, url)
|
|
||||||
|
|
||||||
results = model(imageWorking.get_image_as_array(image_path))
|
results = model(imageWorking.get_image_as_array(image_path))
|
||||||
object_properties = list()
|
object_properties = list()
|
||||||
@ -46,15 +45,16 @@ def analyse_file(uid, image_path):
|
|||||||
'QueryGetCheck': '',
|
'QueryGetCheck': '',
|
||||||
'QueryGetEmpty': ''
|
'QueryGetEmpty': ''
|
||||||
}
|
}
|
||||||
for sqwrl in list_sqwrl['response']:
|
params = '&'.join([f'names={query}' for query in result.keys()])
|
||||||
response = requests.post(url + f'{uid}/query/{sqwrl["name"]}', json=data).json()
|
response = requests.post(url + f'{uid}/query/multi?{params}', json=data).json()
|
||||||
if response['error']:
|
if response['error']:
|
||||||
raise Exception(response['error'])
|
raise Exception(response['error'])
|
||||||
result[sqwrl['name']] = [resultSQWRL['name']['value'] for resultSQWRL in response['response']['rows']]
|
for query in response['response']:
|
||||||
print(f'Запрос {sqwrl["name"]} выполнен')
|
result[query] = [resultSQWRL['name']['value'] for resultSQWRL in response['response'][query]['rows']]
|
||||||
|
print(f'Запрос выполнен')
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print('Результаты')
|
print('Результат:')
|
||||||
if result['QueryGetNotEmpty']:
|
if result['QueryGetNotEmpty']:
|
||||||
print('Аудитория занята')
|
print('Аудитория занята')
|
||||||
elif result['QueryGetCheck']:
|
elif result['QueryGetCheck']:
|
||||||
|
@ -9,10 +9,6 @@ def is_ontology_exists(uid, url):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_list_sqwrl(uid, url):
|
|
||||||
return requests.get(url + f'{uid}/query/', verify=False).json()
|
|
||||||
|
|
||||||
|
|
||||||
def get_entity_square(results_ndarray_i):
|
def get_entity_square(results_ndarray_i):
|
||||||
square = float((results_ndarray_i[2] - results_ndarray_i[0]) *
|
square = float((results_ndarray_i[2] - results_ndarray_i[0]) *
|
||||||
(results_ndarray_i[3] - results_ndarray_i[1]))
|
(results_ndarray_i[3] - results_ndarray_i[1]))
|
||||||
|
Loading…
Reference in New Issue
Block a user