Skip to content

Commit 1492474

Browse files
author
Artsiom Khadzkou
committed
Fixs before release
1 parent 6da5217 commit 1492474

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1396
-673
lines changed

LICENSE.txt LICENSE

File renamed without changes.

README.md

+483-497
Large diffs are not rendered by default.

compreface/__init__.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
216

317
from .core import CompreFace

compreface/client/__init__.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
23
3-
from .compare_face_from_image import CompareFaceFromImageClient
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
from .verification_face_from_image import VerificationFaceFromImageClient
418
from .add_example_of_subject import AddExampleOfSubjectClient
519
from .delete_example_by_id import DeleteExampleByIdClient
620
from .recognize_face_from_image import RecognizeFaceFromImageClient

compreface/client/add_example_of_subject.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
23
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
import requests
18+
from compreface.common.multipart_constructor import multipart_constructor
319
from compreface.common.typed_dict import DetProbOptionsDict, check_fields_by_name
420
from compreface.config.api_list import RECOGNIZE_CRUD_API
5-
import os
6-
import requests
721
from requests_toolbelt.multipart.encoder import MultipartEncoder
8-
922
from ..common import ClientRequest
1023

1124

@@ -38,23 +51,15 @@ def get(self) -> dict:
3851
:return: json with this subject from server.
3952
"""
4053

41-
def post(self, image_path: str = '', subject: str = '', options: DetProbOptionsDict = {}) -> dict:
54+
def post(self, image: str = '' or bytes, subject: str = '', options: DetProbOptionsDict = {}) -> dict:
4255
url: str = self.url + '?subject=' + subject
43-
name_img: str = os.path.basename(image_path)
44-
4556
# Validation loop and adding fields to the url.
4657
for key in options.keys():
4758
# Checks fields with necessary rules.
4859
# key - key field by options.
4960
check_fields_by_name(key, options[key])
5061
url += '&' + key + "=" + str(options[key])
51-
52-
# Encoding image from path and encode in multipart for sending to the server.
53-
m = MultipartEncoder(
54-
fields={'file': (name_img, open(image_path, 'rb'))}
55-
)
56-
57-
# Sending encode image for add subject.
62+
m = multipart_constructor(image)
5863
result = requests.post(url, data=m, headers={'Content-Type': m.content_type,
5964
'x-api-key': self.api_key})
6065
return result.json()

compreface/client/delete_example_by_id.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
216

317
from compreface.config.api_list import RECOGNIZE_CRUD_API
418
import requests

compreface/client/detect_face_from_image.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
from compreface.common.multipart_constructor import multipart_constructor
118
import os
219
import requests
320
from compreface.common.typed_dict import AllOptionsDict, check_fields_by_name
@@ -29,9 +46,8 @@ def get(self):
2946
:return: json from server.
3047
"""
3148

32-
def post(self, image_path: str = '', options: AllOptionsDict = {}):
49+
def post(self, image: str = '' or bytes, options: AllOptionsDict = {}):
3350
url: str = self.url + '?'
34-
name_img: str = os.path.basename(image_path)
3551

3652
# Validation loop and adding fields to the url.
3753
for key in options.keys():
@@ -41,9 +57,7 @@ def post(self, image_path: str = '', options: AllOptionsDict = {}):
4157
url += '&' + key + "=" + str(options[key])
4258

4359
# Encoding image from path and encode in multipart for sending to the server.
44-
m = MultipartEncoder(
45-
fields={'file': (name_img, open(image_path, 'rb'))}
46-
)
60+
m = multipart_constructor(image)
4761

4862
# Sending encode image for detection faces.
4963
result = requests.post(url, data=m, headers={'Content-Type': m.content_type,

compreface/client/recognize_face_from_image.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
23
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
from compreface.common.multipart_constructor import multipart_constructor
318
from compreface.common.typed_dict import ExpandedOptionsDict, check_fields_by_name
419
from compreface.config.api_list import RECOGNIZE_API
520
import os
@@ -32,9 +47,8 @@ def get(self):
3247
:return: json from server.
3348
"""
3449

35-
def post(self, image_path: str = '', options: ExpandedOptionsDict = {}):
50+
def post(self, image: str = '' or bytes, options: ExpandedOptionsDict = {}):
3651
url: str = self.url + "?"
37-
name_img: str = os.path.basename(image_path)
3852

3953
# Validation loop and adding fields to the url.
4054
for key in options.keys():
@@ -44,9 +58,7 @@ def post(self, image_path: str = '', options: ExpandedOptionsDict = {}):
4458
url += '&' + key + "=" + str(options[key])
4559

4660
# Encoding image from path and encode in multipart for sending to the server.
47-
m = MultipartEncoder(
48-
fields={'file': (name_img, open(image_path, 'rb'))}
49-
)
61+
m = multipart_constructor(image)
5062

5163
# Sending encode image for recognize faces.
5264
result = requests.post(url, data=m, headers={'Content-Type': m.content_type,

compreface/client/compare_face_from_image.py compreface/client/verification_face_from_image.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
from compreface.common.multipart_constructor import multipart_constructor
218
import os
319
import requests
420
from compreface.common.typed_dict import ExpandedOptionsDict, check_fields_by_name
@@ -7,7 +23,7 @@
723
from ..common import ClientRequest
824

925

10-
class CompareFaceFromImageClient(ClientRequest):
26+
class VerificationFaceFromImageClient(ClientRequest):
1127
"""
1228
Compare face in image. It uses image path for encode and send to CompreFace
1329
server with validation by image id.
@@ -33,12 +49,12 @@ def get(self):
3349
"""
3450

3551
def post(self,
36-
image_path: str = '',
52+
image: str = '' or bytes,
3753
image_id: str = '',
3854
options: ExpandedOptionsDict = {}) -> dict:
3955

4056
url: str = self.url + '/' + image_id + '/verify?'
41-
name_img: str = os.path.basename(image_path)
57+
4258
# Validation loop and adding fields to the url.
4359
for key in options.keys():
4460
# Checks fields with necessary rules.
@@ -47,9 +63,7 @@ def post(self,
4763
url += '&' + key + "=" + str(options[key])
4864

4965
# Encoding image from path and encode in multipart for sending to the server.
50-
m = MultipartEncoder(
51-
fields={'file': (name_img, open(image_path, 'rb'))}
52-
)
66+
m = multipart_constructor(image)
5367

5468
# Sending encode image for verify face.
5569
result = requests.post(url, data=m, headers={'Content-Type': m.content_type,

compreface/client/verify_face_from_image.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
17+
from compreface.common.multipart_constructor import multipart_constructor_with_two_images
118
import requests
219
from compreface.config.api_list import VERIFICATION_API
320
import os
@@ -34,13 +51,11 @@ def get(self):
3451
"""
3552

3653
def post(self,
37-
source_image_path: str = '',
38-
target_image_path: str = '',
54+
source_image: str = '' or bytes,
55+
target_image: str = '' or bytes,
3956
options: AllOptionsDict = {}) -> dict:
4057

4158
url: str = self.url + '/verify?'
42-
source_name_img: str = os.path.basename(source_image_path)
43-
target_name_img: str = os.path.basename(target_image_path)
4459
# Validation loop and adding fields to the url.
4560
for key in options.keys():
4661
# Checks fields with necessary rules.
@@ -49,12 +64,7 @@ def post(self,
4964
url += '&' + key + "=" + str(options[key])
5065

5166
# Encoding image from path and encode in multipart for sending to the server.
52-
m = MultipartEncoder(
53-
fields={'source_image': (source_name_img, open(
54-
source_image_path, 'rb')), 'target_image': (target_name_img, open(
55-
target_image_path, 'rb'))}
56-
57-
)
67+
m = multipart_constructor_with_two_images(source_image, target_image)
5868

5969
# Sending encode image for verify face.
6070
result = requests.post(url, data=m, headers={'Content-Type': m.content_type,

compreface/collections/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1+
"""
2+
Copyright(c) 2021 the original author or authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https: // www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
"""
16+
117
from .face_collections import FaceCollection

0 commit comments

Comments
 (0)