prefab 1.1.3__tar.gz → 1.1.4__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.
- {prefab-1.1.3 → prefab-1.1.4}/PKG-INFO +1 -1
- {prefab-1.1.3 → prefab-1.1.4}/docs/CHANGELOG.md +6 -1
- prefab-1.1.4/docs/reference/predict.md +3 -0
- {prefab-1.1.3 → prefab-1.1.4}/mkdocs.yml +1 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/__init__.py +1 -1
- {prefab-1.1.3 → prefab-1.1.4}/prefab/predict.py +87 -40
- {prefab-1.1.3 → prefab-1.1.4}/pyproject.toml +1 -1
- {prefab-1.1.3 → prefab-1.1.4}/.gitattributes +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/.github/workflows/docs-deploy.yml +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/.github/workflows/python-publish.yml +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/.gitignore +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/LICENSE +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/README.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/CNAME +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/blog-cards/python-for-photonics.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/favicon.ico +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/logo-white.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/logo.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/prefab_logo_white.svg +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/promo_c.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/assets/promo_p.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/.authors.yml +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/index.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_11_1.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_11_2.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_13_2.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_13_3.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_13_4.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_3_1.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_3_2.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_3_3.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_7_2.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_7_3.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_7_4.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/prefab-v1.1.0_files/prefab-v1.1.0_9_2.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/posts/python-for-photonics.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/blog/prefab-v1.1.0.ipynb +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/examples/1_prediction.ipynb +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/examples/2_correction.ipynb +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/examples/3_sidewall_angle.ipynb +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/examples/4_SEM_generation.ipynb +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/index.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/models.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/overrides/main.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/compare.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/device.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/geometry.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/models.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/read.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/docs/reference/shapes.md +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/__main__.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/compare.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/device.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/geometry.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/models.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/read.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/prefab/shapes.py +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/404.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/_mkdocstrings.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/favicon.ico +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/images/favicon.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/bundle.a7c05c9e.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/bundle.a7c05c9e.min.js.map +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ar.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.da.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.de.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.du.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.el.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.es.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.fi.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.fr.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.he.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.hi.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.hu.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.hy.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.it.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ja.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.jp.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.kn.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ko.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.multi.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.nl.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.no.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.pt.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ro.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ru.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.sa.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.sv.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.ta.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.te.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.th.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.tr.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.vi.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/min/lunr.zh.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/tinyseg.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/lunr/wordcut.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/workers/search.b8dbb3d2.min.js +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/javascripts/workers/search.b8dbb3d2.min.js.map +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/logo.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/logo_neue.svg +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/promo_c.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/promo_p.png +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/stylesheets/main.66ac8b77.min.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/stylesheets/main.66ac8b77.min.css.map +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/stylesheets/palette.06af60db.min.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/assets/stylesheets/palette.06af60db.min.css.map +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/css/ansi-colours.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/css/jupyter-cells.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/css/pandas-dataframe.css +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/examples/1_prediction/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/examples/2_correction/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/models/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/objects.inv +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/reference/compare/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/reference/device/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/reference/geometry/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/reference/models/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/reference/read/index.html +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/search/search_index.json +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/sitemap.xml +0 -0
- {prefab-1.1.3 → prefab-1.1.4}/site/sitemap.xml.gz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: prefab
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: Artificial nanofabrication of integrated photonic circuits using deep learning
|
|
5
5
|
Project-URL: Homepage, https://prefabphotonics.com
|
|
6
6
|
Project-URL: Repository, https://github.com/PreFab-Photonics/PreFab
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.4](https://github.com/PreFab-Photonics/PreFab/releases/tag/v1.1.4) - 2024-11-01
|
|
4
|
+
|
|
5
|
+
- Added custom vector-Jacobian product (VJP) for the `predict.predict_array_with_grad` function.
|
|
6
|
+
- Changed some of the docstrings in `prefab.predict` to be more consistent and clear.
|
|
7
|
+
|
|
3
8
|
## [1.1.3](https://github.com/PreFab-Photonics/PreFab/releases/tag/v1.1.3) - 2024-10-26
|
|
4
9
|
|
|
5
10
|
- Moved prediction logic to `prefab.predict` module.
|
|
@@ -19,7 +24,7 @@
|
|
|
19
24
|
|
|
20
25
|
## [1.1.1](https://github.com/PreFab-Photonics/PreFab/releases/tag/v1.1.1) - 2024-09-24
|
|
21
26
|
|
|
22
|
-
- Manually adding small random noise to the
|
|
27
|
+
- Manually adding small random noise to the "SEMulated" images to better match the real data. This is ideally included in the model training, but for now this is a quick fix.
|
|
23
28
|
- Added z-padding to the device array before exporting to STL with `Device.to_stl` to ensure that the exported device is closed.
|
|
24
29
|
- Removed buffer from `Device.device_array` before exporting to with `Device.to_gdsfactory`.
|
|
25
30
|
- The additions from `1.0.3` and `1.0.4` releases, which should be considered part of this release. Release planning a work in progress.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Provides prediction functions for ndarrays of device geometries."""
|
|
2
|
+
|
|
1
3
|
import base64
|
|
2
4
|
import io
|
|
3
5
|
import json
|
|
@@ -6,6 +8,8 @@ import os
|
|
|
6
8
|
import numpy as np
|
|
7
9
|
import requests
|
|
8
10
|
import toml
|
|
11
|
+
from autograd import primitive
|
|
12
|
+
from autograd.extend import defvjp
|
|
9
13
|
from PIL import Image
|
|
10
14
|
from tqdm import tqdm
|
|
11
15
|
|
|
@@ -23,24 +27,34 @@ def predict_array(
|
|
|
23
27
|
gpu: bool = False,
|
|
24
28
|
) -> np.ndarray:
|
|
25
29
|
"""
|
|
26
|
-
|
|
30
|
+
Predict the nanofabrication outcome of a device array using a specified model.
|
|
27
31
|
|
|
28
|
-
This function sends the device array to a prediction service, which uses
|
|
29
|
-
learning model to predict the outcome of the nanofabrication
|
|
30
|
-
can be performed on a GPU if specified.
|
|
32
|
+
This function sends the device array to a serverless prediction service, which uses
|
|
33
|
+
a specified machine learning model to predict the outcome of the nanofabrication
|
|
34
|
+
process. The prediction can be performed on a GPU if specified.
|
|
31
35
|
|
|
32
36
|
Parameters
|
|
33
37
|
----------
|
|
34
38
|
device_array : np.ndarray
|
|
35
|
-
|
|
39
|
+
A 2D array representing the planar geometry of the device. This array undergoes
|
|
40
|
+
various transformations to predict the nanofabrication process.
|
|
36
41
|
model : Model
|
|
37
|
-
The model to use for prediction
|
|
42
|
+
The model to use for prediction, representing a specific fabrication process and
|
|
43
|
+
dataset. This model encapsulates details about the fabrication foundry, process,
|
|
44
|
+
material, technology, thickness, and sidewall presence, as defined in
|
|
45
|
+
`models.py`. Each model is associated with a version and dataset that detail its
|
|
46
|
+
creation and the data it was trained on, ensuring the prediction is tailored to
|
|
47
|
+
specific fabrication parameters.
|
|
38
48
|
model_type : str
|
|
39
49
|
The type of model to use (e.g., 'p', 'c', 's').
|
|
40
50
|
binarize : bool
|
|
41
|
-
|
|
51
|
+
If True, the predicted device geometry will be binarized using a threshold
|
|
52
|
+
method. This is useful for converting probabilistic predictions into binary
|
|
53
|
+
geometries.
|
|
42
54
|
gpu : bool, optional
|
|
43
|
-
|
|
55
|
+
If True, the prediction will be performed on a GPU. Defaults to False. Note: The
|
|
56
|
+
GPU option has more overhead and will take longer for small devices, but will be
|
|
57
|
+
faster for larger devices.
|
|
44
58
|
|
|
45
59
|
Returns
|
|
46
60
|
-------
|
|
@@ -69,38 +83,11 @@ def predict_array(
|
|
|
69
83
|
raise RuntimeError(f"Request failed: {e}") from e
|
|
70
84
|
|
|
71
85
|
|
|
72
|
-
def
|
|
73
|
-
device_array: np.ndarray, model: Model
|
|
86
|
+
def _predict_array_with_grad(
|
|
87
|
+
device_array: np.ndarray, model: Model
|
|
74
88
|
) -> tuple[np.ndarray, np.ndarray]:
|
|
75
|
-
"""
|
|
76
|
-
Predicts the output array and its gradient for a given device array using a
|
|
77
|
-
specified model.
|
|
78
|
-
|
|
79
|
-
This function sends the device array to a prediction service, which uses a machine
|
|
80
|
-
learning model to predict both the outcome and the gradient of the nanofabrication
|
|
81
|
-
process.
|
|
82
|
-
|
|
83
|
-
Parameters
|
|
84
|
-
----------
|
|
85
|
-
device_array : np.ndarray
|
|
86
|
-
The input device array to be predicted.
|
|
87
|
-
model : Model
|
|
88
|
-
The model to use for prediction.
|
|
89
|
-
model_type : str
|
|
90
|
-
The type of model to use (e.g., 'p', 'c', 's').
|
|
91
|
-
|
|
92
|
-
Returns
|
|
93
|
-
-------
|
|
94
|
-
tuple[np.ndarray, np.ndarray]
|
|
95
|
-
A tuple containing the predicted output array and its gradient.
|
|
96
|
-
|
|
97
|
-
Raises
|
|
98
|
-
------
|
|
99
|
-
RuntimeError
|
|
100
|
-
If the request to the prediction service fails.
|
|
101
|
-
"""
|
|
102
89
|
headers = _prepare_headers()
|
|
103
|
-
predict_data = _prepare_predict_data(device_array, model,
|
|
90
|
+
predict_data = _prepare_predict_data(device_array, model, "p", False)
|
|
104
91
|
endpoint_url = f"{BASE_URL}-with-grad-v1.modal.run"
|
|
105
92
|
|
|
106
93
|
response = requests.post(
|
|
@@ -116,8 +103,68 @@ def predict_array_with_grad(
|
|
|
116
103
|
return (prediction_array, gradient_array)
|
|
117
104
|
|
|
118
105
|
|
|
106
|
+
@primitive
|
|
107
|
+
def predict_array_with_grad(device_array: np.ndarray, model: Model) -> np.ndarray:
|
|
108
|
+
"""
|
|
109
|
+
Predict the nanofabrication outcome of a device array and compute its gradient.
|
|
110
|
+
|
|
111
|
+
This function predicts the outcome of the nanofabrication process for a given
|
|
112
|
+
device array using a specified model. It also computes the gradient of the
|
|
113
|
+
prediction with respect to the input device array.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
device_array : np.ndarray
|
|
118
|
+
A 2D array representing the planar geometry of the device.
|
|
119
|
+
model : Model
|
|
120
|
+
The model to use for prediction, representing a specific fabrication process.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
np.ndarray
|
|
125
|
+
The predicted output array.
|
|
126
|
+
"""
|
|
127
|
+
prediction_array, gradient_array = _predict_array_with_grad(
|
|
128
|
+
device_array=device_array, model=model
|
|
129
|
+
)
|
|
130
|
+
predict_array_with_grad.gradient_array = gradient_array
|
|
131
|
+
return prediction_array
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def predict_array_with_grad_vjp(ans: np.ndarray, x: np.ndarray, model: Model):
|
|
135
|
+
"""
|
|
136
|
+
Define the vector-Jacobian product (VJP) for the prediction function.
|
|
137
|
+
|
|
138
|
+
This function provides the VJP for the `predict_array_with_grad` function,
|
|
139
|
+
which is used in reverse-mode automatic differentiation to compute gradients.
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
ans : np.ndarray
|
|
144
|
+
The output of the `predict_array_with_grad` function.
|
|
145
|
+
x : np.ndarray
|
|
146
|
+
The input device array for which the gradient is computed.
|
|
147
|
+
model : Model
|
|
148
|
+
The model used for prediction.
|
|
149
|
+
|
|
150
|
+
Returns
|
|
151
|
+
-------
|
|
152
|
+
function
|
|
153
|
+
A function that computes the VJP given an upstream gradient `g`.
|
|
154
|
+
"""
|
|
155
|
+
grad_x = predict_array_with_grad.gradient_array
|
|
156
|
+
|
|
157
|
+
def vjp(g: np.ndarray) -> np.ndarray:
|
|
158
|
+
return g * grad_x
|
|
159
|
+
|
|
160
|
+
return vjp
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
defvjp(predict_array_with_grad, predict_array_with_grad_vjp)
|
|
164
|
+
|
|
165
|
+
|
|
119
166
|
def _encode_array(array):
|
|
120
|
-
"""Encode
|
|
167
|
+
"""Encode an ndarray as a base64 encoded image for transmission."""
|
|
121
168
|
image = Image.fromarray(np.uint8(array * 255))
|
|
122
169
|
buffered = io.BytesIO()
|
|
123
170
|
image.save(buffered, format="PNG")
|
|
@@ -126,7 +173,7 @@ def _encode_array(array):
|
|
|
126
173
|
|
|
127
174
|
|
|
128
175
|
def _decode_array(encoded_png):
|
|
129
|
-
"""Decode a base64 encoded
|
|
176
|
+
"""Decode a base64 encoded image and return an ndarray."""
|
|
130
177
|
binary_data = base64.b64decode(encoded_png)
|
|
131
178
|
image = Image.open(io.BytesIO(binary_data))
|
|
132
179
|
return np.array(image) / 255
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "prefab"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.4"
|
|
8
8
|
description = "Artificial nanofabrication of integrated photonic circuits using deep learning"
|
|
9
9
|
authors = [{ name = "Dusan Gostimirovic", email = "dusan@prefabphotonics.com" }]
|
|
10
10
|
keywords = ["photonics", "nanofabrication", "machine-learning"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|