-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hotosm/enhance/vectorizer
Enhance : Vectorizer
- Loading branch information
Showing
6 changed files
with
77 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tensorflow==2.12.0 efficientnet==1.1.1 | ||
pip install -e . | ||
- name: Run tests | ||
run: python -m unittest discover -s tests -p 'test_*.py' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
setup( | ||
name="fairpredictor", | ||
version="0.0.30", | ||
version="0.0.31", | ||
url="https://github.com/kshitijrajsharma/fairpredictor", | ||
author="Kshitij Raj Sharma", | ||
author_email="[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
bbox = [-84.1334429383278, 9.953153171808898, -84.13033694028854, 9.954719779271468] | ||
zoom_level = 19 | ||
from predictor import download | ||
|
||
image_download_path = download( | ||
bbox, | ||
zoom_level=zoom_level, | ||
tms_url="bing", | ||
tile_size=256, | ||
download_path="/Users/kshitij/hotosm/fairpredictor/download/test", | ||
) | ||
print(image_download_path) | ||
import os | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
||
import efficientnet.tfkeras as efn | ||
import requests | ||
|
||
from predictor import predict | ||
|
||
# Global variables | ||
TMS_URL = "https://tiles.openaerialmap.org/6501a65c0906de000167e64d/0/6501a65c0906de000167e64e/{z}/{x}/{y}" | ||
BBOX = [100.56228021333352, 13.685230854641182, 100.56383321235313, 13.685961853747969] | ||
FAIR_BASE_URL = "https://fair-dev.hotosm.org/api/v1/workspace/download" | ||
DATASET_ID = "dataset_65" | ||
TRAINING_ID = "training_297" | ||
|
||
|
||
class TestPredictor(unittest.TestCase): | ||
def setUp(self): | ||
model_url = f"{FAIR_BASE_URL}/{DATASET_ID}/output/{TRAINING_ID}/checkpoint.h5" | ||
self.model_path = tempfile.NamedTemporaryFile(suffix=".h5").name | ||
response = requests.get(model_url, stream=True) | ||
with open(self.model_path, "wb") as out_file: | ||
shutil.copyfileobj(response.raw, out_file) | ||
|
||
def tearDown(self): | ||
if self.model_path: | ||
try: | ||
os.remove(self.model_path) | ||
except OSError: | ||
pass | ||
|
||
def test_predict(self): | ||
zoom_level = 20 | ||
predictions = predict(BBOX, self.model_path, zoom_level, TMS_URL) | ||
self.assertIsInstance(predictions, dict) | ||
self.assertTrue(len(predictions["features"]) > 0) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |