picarta 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- picarta-0.1/PKG-INFO +25 -0
- picarta-0.1/README.md +8 -0
- picarta-0.1/picarta/__init__.py +1 -0
- picarta-0.1/picarta/picarta.py +47 -0
- picarta-0.1/picarta.egg-info/PKG-INFO +25 -0
- picarta-0.1/picarta.egg-info/SOURCES.txt +12 -0
- picarta-0.1/picarta.egg-info/dependency_links.txt +1 -0
- picarta-0.1/picarta.egg-info/entry_points.txt +3 -0
- picarta-0.1/picarta.egg-info/requires.txt +1 -0
- picarta-0.1/picarta.egg-info/top_level.txt +2 -0
- picarta-0.1/setup.cfg +4 -0
- picarta-0.1/setup.py +27 -0
- picarta-0.1/tests/__init__.py +0 -0
- picarta-0.1/tests/test_picarta.py +22 -0
picarta-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: picarta
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A package to geolocate images from URL or local files using Picarta AI
|
|
5
|
+
Home-page: https://picarta.ai
|
|
6
|
+
Author: Picarta
|
|
7
|
+
Author-email: info@picarta.ai
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# Picarta
|
|
17
|
+
|
|
18
|
+
A Python package to geolocate images from URL or local files using Picarta AI.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install picarta
|
|
24
|
+
|
|
25
|
+
|
picarta-0.1/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .picarta import Picarta
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import requests
|
|
3
|
+
import base64
|
|
4
|
+
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Picarta:
|
|
9
|
+
def __init__(self, api_token, url="https://picarta.ai/classify", top_k=10):
|
|
10
|
+
self.api_token = api_token
|
|
11
|
+
self.url = url
|
|
12
|
+
self.top_k = top_k
|
|
13
|
+
self.headers = {"Content-Type": "application/json"}
|
|
14
|
+
|
|
15
|
+
def is_valid_url(self, input_str):
|
|
16
|
+
try:
|
|
17
|
+
result = urlparse(input_str)
|
|
18
|
+
return all([result.scheme, result.netloc])
|
|
19
|
+
except ValueError:
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
def read_image(self, image_path):
|
|
23
|
+
with open(image_path, "rb") as image_file:
|
|
24
|
+
return base64.b64encode(image_file.read()).decode('utf-8')
|
|
25
|
+
|
|
26
|
+
def localize(self, img_path, center_latitude=None, center_longitude=None, radius=None):
|
|
27
|
+
if self.is_valid_url(img_path):
|
|
28
|
+
image_data = img_path
|
|
29
|
+
else:
|
|
30
|
+
image_data = self.read_image(img_path)
|
|
31
|
+
|
|
32
|
+
payload = {
|
|
33
|
+
"TOKEN": self.api_token,
|
|
34
|
+
"IMAGE": image_data,
|
|
35
|
+
"TOP_K": self.top_k,
|
|
36
|
+
"Center_LATITUDE": center_latitude,
|
|
37
|
+
"Center_LONGITUDE": center_longitude,
|
|
38
|
+
"RADIUS": radius
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
response = requests.post(self.url, headers=self.headers, json=payload)
|
|
42
|
+
|
|
43
|
+
if response.status_code == 200:
|
|
44
|
+
return response.json()
|
|
45
|
+
else:
|
|
46
|
+
response.raise_for_status()
|
|
47
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: picarta
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A package to geolocate images from URL or local files using Picarta AI
|
|
5
|
+
Home-page: https://picarta.ai
|
|
6
|
+
Author: Picarta
|
|
7
|
+
Author-email: info@picarta.ai
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# Picarta
|
|
17
|
+
|
|
18
|
+
A Python package to geolocate images from URL or local files using Picarta AI.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install picarta
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
picarta/__init__.py
|
|
4
|
+
picarta/picarta.py
|
|
5
|
+
picarta.egg-info/PKG-INFO
|
|
6
|
+
picarta.egg-info/SOURCES.txt
|
|
7
|
+
picarta.egg-info/dependency_links.txt
|
|
8
|
+
picarta.egg-info/entry_points.txt
|
|
9
|
+
picarta.egg-info/requires.txt
|
|
10
|
+
picarta.egg-info/top_level.txt
|
|
11
|
+
tests/__init__.py
|
|
12
|
+
tests/test_picarta.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
picarta-0.1/setup.cfg
ADDED
picarta-0.1/setup.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="picarta",
|
|
5
|
+
version="0.1",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
install_requires=[
|
|
8
|
+
"requests",
|
|
9
|
+
],
|
|
10
|
+
entry_points={
|
|
11
|
+
'console_scripts': [
|
|
12
|
+
'localize-image=picarta.picarta:main',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
author="Picarta",
|
|
16
|
+
author_email="info@picarta.ai",
|
|
17
|
+
description="A package to geolocate images from URL or local files using Picarta AI",
|
|
18
|
+
long_description=open('README.md').read(),
|
|
19
|
+
long_description_content_type="text/markdown",
|
|
20
|
+
url="https://picarta.ai",
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
],
|
|
26
|
+
python_requires='>=3.6',
|
|
27
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from picarta import Picarta
|
|
3
|
+
|
|
4
|
+
class TestPicarta(unittest.TestCase):
|
|
5
|
+
def setUp(self):
|
|
6
|
+
self.api_token = "YOUR_API_TOKEN"
|
|
7
|
+
self.localizer = Picarta(self.api_token)
|
|
8
|
+
|
|
9
|
+
def test_is_valid_url(self):
|
|
10
|
+
self.assertTrue(self.localizer.is_valid_url("https://example.com/image.jpg"))
|
|
11
|
+
self.assertFalse(self.localizer.is_valid_url("not_a_url"))
|
|
12
|
+
|
|
13
|
+
def test_localize_image_url(self):
|
|
14
|
+
result = self.localizer.localize("https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg")
|
|
15
|
+
self.assertIsNotNone(result)
|
|
16
|
+
|
|
17
|
+
def test_localize_image_local(self):
|
|
18
|
+
result = self.localizer.localize("path/to/local/image.jpg")
|
|
19
|
+
self.assertIsNotNone(result)
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
unittest.main()
|