Package: samgis
title: SamGIS
emoji: 🗺️
colorFrom: red
colorTo: blue
sdk: docker
pinned: false
license: mitSegment Anything modelsIt's possible to prepare the model files usinghttps://github.com/vietanhdev/samexporter/or using the ones
fromhttps://huggingface.co/aletrn/sam-quantized(copy them within the folder/machine_learning_models).SamGIS - HuggingFace versionThe SamGIS HuggingSpace url ishttps://huggingface.co/spaces/aletrn/samgis.
Build the docker image this way:# clean any old active containersdockerstop$(dockerps-a-q);dockerrm$(dockerps-a-q)# build the base docker image from the repository root folder using ARGs:# - DEPENDENCY_GROUP=fastapi used by poetry# VITE__MAP_DESCRIPTION, VITE__SAMGIS_SPACE used by 'docker build'(set-oallexport&&source<(cat./static/.env|grepVITE__)&&set+oallexport;env|grepVITE__;dockerbuild.-fdockerfiles/dockerfile-samgis-base--progress=plain\--build-argDEPENDENCY_GROUP=fastapi\--build-argVITE__MAP_DESCRIPTION=${VITE__MAP_DESCRIPTION}\--build-argVITE__SAMGIS_SPACE=${VITE__SAMGIS_SPACE}\--tagregistry.gitlab.com/aletrn/gis-prediction)# build the image, use the tag "samgis-huggingface"dockerbuild.--tagexample-docker-namespace/samgis-huggingface--progress=plainRun the container (keep it on background) and show logsdockerrun-d--namesamgis-huggingface-p7860:7860example-docker-namespace/samgis-huggingface;dockerlogs-fsamgis-huggingfaceTest it with curl using a json payload:URL=http://localhost:7860/infer_samgis
curl-d@./events/payload_point_eolie.json-H'accept: application/json'${URL}or better visiting the swagger page onhttp://localhost:7860/docsSamGIS - lambda AWS versionBuild the docker image this way:# clean any old active containersdockerstop$(dockerps-a-q);dockerrm$(dockerps-a-q)# build the base docker image with the docker aws repository tagdockerbuild.-fdockerfiles/dockerfile-samgis-base--build-argDEPENDENCY_GROUP=aws_lambda\--tagexample-docker-namespace/samgis-base-aws-lambda--progress=plain# build the final docker imagedockerbuild.-fdockerfiles/dockerfile-lambda-fastsam-api--tagexample-docker-namespace/lambda-fastsam-api--progress=plainRun the container (keep it on background) and show logsdockerrun-d--namelambda-fastsam-api-p8080:8080lambda-fastsam-api;dockerlogs-flambda-fastsam-apiTest it with curl using a json payload: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 imageLogin on aws ECR with the correct aws profile (change the exampleexample-docker-namespace/repository url with the one from
theECR push command instructions page).Dependencies installation and local testsThe docker build process needs only the base dependency group plus theaws_lambdaorfastapioptional one.
Install also thetestand/ordocsgroups if needed.TestsTests are defined in thetestsfolder in this project. Use PIP to install the test dependencies and run tests.python-mpytest--cov=samgis--cov-report=term-missing&&coveragehtmlHow to update the static documentation with sphinxThis project documentation uses 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 thedocumentation pagefor details.
Run the command from the project root:# missing docs folder (run from project root) initialize this waycddocs&&sphinx-quickstart-pSamGIS-r1.0.0-lpython--masterindex# update docs folder (from project root)sphinx-apidoc-f-odocssamgisThen it's possible to generate the HTML pagescddocs&&makehtml&&../# to clean old filescddocs&&makecleanhtml&&cd../The static documentation it's now ready at the pathdocs/_build/html/index.html.To create a work in progress openapi json or yaml file useextract-openapi-fastapi.pyextract-openapi-lambda.py(useful to export the json schema request and response from lambda app api)