File size: 3,841 Bytes
7c6fa68 d77b9aa 7c6fa68 d427534 7c6fa68 e9833fa 6345dd2 7c6fa68 fa76f5f 3df2f66 7c6fa68 fa76f5f 7c6fa68 43f594e fa76f5f 7c6fa68 43f594e 7c6fa68 43f594e 7c6fa68 59ebac7 3dbe011 43f594e 7d6e00c 3dbe011 43f594e 59ebac7 9954ac1 59ebac7 b2b1ed7 43f594e 59ebac7 9e6626c 7c6fa68 43f594e 7c6fa68 595ec2d 7c6fa68 595ec2d 7c6fa68 5a246f7 2979556 5a246f7 00b4479 7c6fa68 00b4479 6f2f547 7c6fa68 00b4479 6f2f547 2979556 00b4479 22c2921 2ac5c46 22c2921 00b4479 595ec2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
---
title: SamGIS
emoji: 🗺️
colorFrom: red
colorTo: blue
sdk: docker
pinned: false
license: mit
---
## Segment Anything models
It's possible to prepare the model files using https://github.com/vietanhdev/samexporter/ or using the ones
from https://huggingface.co/aletrn/sam-quantized (copy them within the folder `/machine_learning_models`).
## SamGIS - HuggingFace version
The SamGIS HuggingSpace url is https://huggingface.co/spaces/aletrn/samgis.
Build the docker image this way:
```bash
# clean any old active containers
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
# build the base docker image with the ARG DEPENDENCY_GROUP=fastapi used by poetry
docker build . -f dockerfiles/dockerfile-samgis-base --build-arg DEPENDENCY_GROUP=fastapi \
--tag example-docker-namespace/samgis-base-fastapi --progress=plain
# build the image, use the tag "samgis-huggingface"
docker build . --tag example-docker-namespace/samgis-huggingface --progress=plain
```
Run the container (keep it on background) and show logs
```bash
docker run -d --name samgis-huggingface -p 7860:7860 example-docker-namespace/samgis-huggingface; docker logs -f samgis-huggingface
```
Test it with curl:
```bash
curl -X 'POST' \
'http://localhost:7860/infer_samgeo' \
-H 'accept: application/json' \
-d '{}'
```
or better visiting the swagger page on http://localhost:7860/docs
## SamGIS - lambda AWS version
Build the docker image this way:
```bash
# clean any old active containers
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
# build the base docker image with the docker aws repository tag
docker build . -f dockerfiles/dockerfile-samgis-base --build-arg DEPENDENCY_GROUP=aws_lambda \
--tag example-docker-namespace/samgis-base-aws-lambda --progress=plain
# build the final docker image
docker build . -f dockerfiles/dockerfile-lambda-fastsam-api --tag example-docker-namespace/lambda-fastsam-api --progress=plain
```
Run the container (keep it on background) and show logs
```bash
docker run -d --name lambda-fastsam-api -p 8080:8080 lambda-fastsam-api; docker logs -f lambda-fastsam-api
```
Test it with curl:
```bash
URL=http://localhost:8080/2015-03-31/functions/function/invocations
curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
```
### Publish the aws lambda docker image
Login on aws ECR with the correct aws profile (change the example `example-docker-namespace/` repository url with the one from
the [ECR push command instructions page](https://eu-west-1.console.aws.amazon.com/ecr/repositories/)).
### Dependencies installation and local tests
The docker build process needs only the base dependency group plus the `aws_lambda` or `fastapi` optional one.
Install also the `test` and/or `docs` groups if needed.
### Tests
Tests are defined in the `tests` folder in this project. Use PIP to install the test dependencies and run tests.
```bash
python -m pytest --cov=samgis --cov-report=term-missing && coverage html
```
### How to update the static documentation with sphinx
Run the sphinx-apidoc: it's a tool for automatic generation of Sphinx sources that, using the autodoc
extension, document a whole package in the style of other automatic API documentation tools. See the
[documentation page](https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html) for details.
Run the command from the project root:
```bash
# missing docs folder (run from project root)
cd docs && sphinx-quickstart -p SamGIS -r 1.0.0 -l python --master index
# update docs folder (from project root)
sphinx-apidoc -f -o docs samgis
```
Then it's possible to generate the HTML pages
```bash
cd docs && make html && ../
# to clean old files
cd docs && make clean html && cd ../
```
The static documentation it's now ready at the path `docs/_build/html/index.html`.
|