aletrn commited on
Commit
9b0c3be
1 Parent(s): 426f043

[docs] add configuration options

Browse files
docs/conf.py CHANGED
@@ -21,6 +21,7 @@ extensions = [
21
  'sphinx.ext.autodoc',
22
  'sphinx.ext.viewcode',
23
  'sphinx.ext.napoleon',
 
24
  # 'sphinx_autodoc_defaultargs'
25
  ]
26
  # Napoleon settings
@@ -38,6 +39,9 @@ napoleon_google_docstring = True
38
  # napoleon_type_aliases = None
39
  # napoleon_attr_annotations = True
40
 
 
 
 
41
  templates_path = ['_templates']
42
  exclude_patterns = [
43
  '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*'
@@ -70,3 +74,8 @@ html_sidebars = {
70
  ]
71
  }
72
  html_static_path = ['_static']
 
 
 
 
 
 
21
  'sphinx.ext.autodoc',
22
  'sphinx.ext.viewcode',
23
  'sphinx.ext.napoleon',
24
+ 'sphinx_autodoc_typehints'
25
  # 'sphinx_autodoc_defaultargs'
26
  ]
27
  # Napoleon settings
 
39
  # napoleon_type_aliases = None
40
  # napoleon_attr_annotations = True
41
 
42
+ #
43
+ typehints_defaults = "comma"
44
+
45
  templates_path = ['_templates']
46
  exclude_patterns = [
47
  '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*'
 
74
  ]
75
  }
76
  html_static_path = ['_static']
77
+ html_theme_options = {
78
+ "description": "Segment Anything applied to geodata",
79
+ "fixed_sidebar": "true",
80
+ "sidebar_collapse": "false"
81
+ }
docs/index.rst CHANGED
@@ -9,8 +9,9 @@ Welcome to SamGIS's documentation!
9
  .. toctree::
10
  :maxdepth: 2
11
  :caption: Contents:
 
12
 
13
-
14
 
15
  Indices and tables
16
  ==================
 
9
  .. toctree::
10
  :maxdepth: 2
11
  :caption: Contents:
12
+ :hidden:
13
 
14
+ modules
15
 
16
  Indices and tables
17
  ==================
requirements_docs.txt CHANGED
@@ -1 +1,2 @@
1
  sphinx
 
 
1
  sphinx
2
+ sphinx-autodoc-typehints
src/prediction_api/predictors.py CHANGED
@@ -14,9 +14,14 @@ models_dict = {"fastsam": {"instance": None}}
14
 
15
 
16
  def samexporter_predict(
17
- bbox: llist_float, prompt: list[dict], zoom: float, model_name: str = "fastsam") -> Dict[str, int]:
 
 
 
 
18
  """
19
  Return predictions as a geojson from a geo-referenced image using the given input prompt.
 
20
  1. if necessary instantiate a segment anything machine learning instance model
21
  2. download a geo-referenced raster image delimited by the coordinates bounding box (bbox)
22
  3. get a prediction image from the segment anything instance model using the input prompt
@@ -25,7 +30,7 @@ def samexporter_predict(
25
  Args:
26
  bbox: coordinates bounding box
27
  prompt: machine learning input prompt
28
- zoom: zoom value
29
  model_name: machine learning model name
30
 
31
  Returns:
@@ -73,7 +78,7 @@ def get_raster_inference(
73
  model_name: model name string
74
 
75
  Returns:
76
- Tuple[np.ndarray, int]: raster prediction mask, prediction number
77
  """
78
  np_img = np.array(img)
79
  app_logger.info(f"img type {type(np_img)}, prompt:{prompt}.")
 
14
 
15
 
16
  def samexporter_predict(
17
+ bbox: llist_float,
18
+ prompt: list[dict],
19
+ zoom: float,
20
+ model_name: str = "fastsam"
21
+ ) -> Dict[str, int]:
22
  """
23
  Return predictions as a geojson from a geo-referenced image using the given input prompt.
24
+
25
  1. if necessary instantiate a segment anything machine learning instance model
26
  2. download a geo-referenced raster image delimited by the coordinates bounding box (bbox)
27
  3. get a prediction image from the segment anything instance model using the input prompt
 
30
  Args:
31
  bbox: coordinates bounding box
32
  prompt: machine learning input prompt
33
+ zoom:
34
  model_name: machine learning model name
35
 
36
  Returns:
 
78
  model_name: model name string
79
 
80
  Returns:
81
+ raster prediction mask, prediction number
82
  """
83
  np_img = np.array(img)
84
  app_logger.info(f"img type {type(np_img)}, prompt:{prompt}.")
static/app.js DELETED
@@ -1,33 +0,0 @@
1
- const jsonBtn = document.getElementById("getJson");
2
- const apiBtn = document.getElementById("getApi");
3
- const output = document.getElementById("output");
4
- const coordsForm = document.getElementById("coords-form");
5
-
6
- function formData2json(dataId, newObj={}) {
7
- const formData = new FormData(dataId);
8
- formData.forEach(function(value, key){
9
- newObj[key] = value;
10
- });
11
- return JSON.stringify(newObj);
12
- }
13
-
14
- coordsForm.addEventListener('submit', event => {
15
- event.preventDefault();
16
- const inputJson = formData2json(coordsForm)
17
- console.log("inputJson", inputJson, "#");
18
-
19
- fetch('/infer_samgeo', {
20
- method: 'POST', // or 'PUT'
21
- body: inputJson, // a FormData will automatically set the 'Content-Type',
22
- headers: {"Content-Type": "application/json"},
23
- }).then(function (response) {
24
- return response.json();
25
- }).then(function (data) {
26
- console.log("data:", data, "#")
27
- output.innerHTML = JSON.stringify(data)
28
- }).catch(function (err) {
29
- console.log("err:", err, "#")
30
- output.innerHTML = `err:${JSON.stringify(err)}.`;
31
- });
32
- event.preventDefault();
33
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/index.html DELETED
@@ -1,41 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" />
8
- <title>Fetch API</title>
9
- </head>
10
- <body>
11
- <div class="container">
12
- <h1>Fetch API</h1>
13
- <form id="coords-form">
14
- <label>
15
- bbox: x1 <input type="number" id="x-center-form" name="x1" value="-122.1497"/>
16
- </label>
17
- <label>
18
- bbox: x2 <input type="number" id="y-center-form" name="x2" value="37.6311"/>
19
- </label>
20
- <label>
21
- bbox: y1 <input type="number" id="y-center-form" name="y1" value="-122.1203"/>
22
- </label>
23
- <label>
24
- bbox: y2 <input type="number" id="y-center-form" name="y2" value="37.6458"/>
25
- </label>
26
- <br/><br/>
27
- <label>
28
- x point: <input type="number" id="x-form" name="x" value="-122.1419"/>
29
- </label>
30
- <label>
31
- y point: <input type="number" id="y-form" name="y" value="37.6383"/>
32
- </label>
33
- <br/><br/>
34
- <button type="submit" id="submit-btn">submit form</button>
35
- </form>
36
- <br><br>
37
- <div id="output"></div>
38
- </div>
39
- <script src="app.js"></script>
40
- </body>
41
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/style.css DELETED
File without changes