fxn 0.0.31__tar.gz → 0.0.33__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.
- fxn-0.0.33/PKG-INFO +290 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/graph/client.py +4 -6
- fxn-0.0.33/fxn/libs/macos/Function.dylib +0 -0
- fxn-0.0.33/fxn/libs/windows/Function.dll +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/prediction/service.py +32 -20
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/predictor.py +1 -1
- {fxn-0.0.31 → fxn-0.0.33}/fxn/version.py +1 -1
- fxn-0.0.33/fxn.egg-info/PKG-INFO +290 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn.egg-info/SOURCES.txt +3 -1
- {fxn-0.0.31 → fxn-0.0.33}/fxn.egg-info/entry_points.txt +0 -1
- fxn-0.0.33/pyproject.toml +61 -0
- fxn-0.0.31/PKG-INFO +0 -85
- fxn-0.0.31/fxn.egg-info/PKG-INFO +0 -85
- fxn-0.0.31/setup.py +0 -66
- {fxn-0.0.31 → fxn-0.0.33}/LICENSE +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/README.md +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/auth.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/env.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/misc.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/predict.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/cli/predictors.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/function.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/graph/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/libs/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/libs/linux/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/libs/macos/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/libs/windows/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/magic.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/environment.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/prediction/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/prediction/fxnc.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/storage.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/services/user.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/__init__.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/dtype.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/environment.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/prediction.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/predictor.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/profile.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/storage.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/tag.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/user.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn/types/value.py +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn.egg-info/dependency_links.txt +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn.egg-info/requires.txt +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/fxn.egg-info/top_level.txt +0 -0
- {fxn-0.0.31 → fxn-0.0.33}/setup.cfg +0 -0
fxn-0.0.33/PKG-INFO
ADDED
@@ -0,0 +1,290 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: fxn
|
3
|
+
Version: 0.0.33
|
4
|
+
Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
|
5
|
+
Author-email: "NatML Inc." <hi@fxn.ai>
|
6
|
+
License: Apache License
|
7
|
+
Version 2.0, January 2004
|
8
|
+
http://www.apache.org/licenses/
|
9
|
+
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
11
|
+
|
12
|
+
1. Definitions.
|
13
|
+
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
16
|
+
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
18
|
+
the copyright owner that is granting the License.
|
19
|
+
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
21
|
+
other entities that control, are controlled by, or are under common
|
22
|
+
control with that entity. For the purposes of this definition,
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
24
|
+
direction or management of such entity, whether by contract or
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
27
|
+
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
29
|
+
exercising permissions granted by this License.
|
30
|
+
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
32
|
+
including but not limited to software source code, documentation
|
33
|
+
source, and configuration files.
|
34
|
+
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
36
|
+
transformation or translation of a Source form, including but
|
37
|
+
not limited to compiled object code, generated documentation,
|
38
|
+
and conversions to other media types.
|
39
|
+
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
41
|
+
Object form, made available under the License, as indicated by a
|
42
|
+
copyright notice that is included in or attached to the work
|
43
|
+
(an example is provided in the Appendix below).
|
44
|
+
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
51
|
+
the Work and Derivative Works thereof.
|
52
|
+
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
54
|
+
the original version of the Work and any modifications or additions
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
66
|
+
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
69
|
+
subsequently incorporated within the Work.
|
70
|
+
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
77
|
+
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
83
|
+
where such license applies only to those patent claims licensable
|
84
|
+
by such Contributor that are necessarily infringed by their
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
87
|
+
institute patent litigation against any entity (including a
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
90
|
+
or contributory patent infringement, then any patent licenses
|
91
|
+
granted to You under this License for that Work shall terminate
|
92
|
+
as of the date such litigation is filed.
|
93
|
+
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
96
|
+
modifications, and in Source or Object form, provided that You
|
97
|
+
meet the following conditions:
|
98
|
+
|
99
|
+
(a) You must give any other recipients of the Work or
|
100
|
+
Derivative Works a copy of this License; and
|
101
|
+
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
103
|
+
stating that You changed the files; and
|
104
|
+
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
107
|
+
attribution notices from the Source form of the Work,
|
108
|
+
excluding those notices that do not pertain to any part of
|
109
|
+
the Derivative Works; and
|
110
|
+
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
113
|
+
include a readable copy of the attribution notices contained
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
116
|
+
of the following places: within a NOTICE text file distributed
|
117
|
+
as part of the Derivative Works; within the Source form or
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
119
|
+
within a display generated by the Derivative Works, if and
|
120
|
+
wherever such third-party notices normally appear. The contents
|
121
|
+
of the NOTICE file are for informational purposes only and
|
122
|
+
do not modify the License. You may add Your own attribution
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
125
|
+
that such additional attribution notices cannot be construed
|
126
|
+
as modifying the License.
|
127
|
+
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
129
|
+
may provide additional or different license terms and conditions
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
133
|
+
the conditions stated in this License.
|
134
|
+
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
138
|
+
this License, without any additional terms or conditions.
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
140
|
+
the terms of any separate license agreement you may have executed
|
141
|
+
with Licensor regarding such Contributions.
|
142
|
+
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
145
|
+
except as required for reasonable and customary use in describing the
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
147
|
+
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
157
|
+
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
163
|
+
incidental, or consequential damages of any character arising as a
|
164
|
+
result of this License or out of the use or inability to use the
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
167
|
+
other commercial damages or losses), even if such Contributor
|
168
|
+
has been advised of the possibility of such damages.
|
169
|
+
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
173
|
+
or other liability obligations and/or rights consistent with this
|
174
|
+
License. However, in accepting such obligations, You may act only
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
179
|
+
of your accepting any such warranty or additional liability.
|
180
|
+
|
181
|
+
END OF TERMS AND CONDITIONS
|
182
|
+
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
184
|
+
|
185
|
+
To apply the Apache License to your work, attach the following
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
187
|
+
replaced with your own identifying information. (Don't include
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
189
|
+
comment syntax for the file format. We also recommend that a
|
190
|
+
file or class name and description of purpose be included on the
|
191
|
+
same "printed page" as the copyright notice for easier
|
192
|
+
identification within third-party archives.
|
193
|
+
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
195
|
+
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
197
|
+
you may not use this file except in compliance with the License.
|
198
|
+
You may obtain a copy of the License at
|
199
|
+
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
201
|
+
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
205
|
+
See the License for the specific language governing permissions and
|
206
|
+
limitations under the License.
|
207
|
+
Project-URL: Homepage, https://fxn.ai
|
208
|
+
Project-URL: Documentation, https://docs.fxn.ai
|
209
|
+
Project-URL: Source, https://github.com/fxnai/fxn
|
210
|
+
Project-URL: Changelog, https://github.com/fxnai/fxn/blob/main/Changelog.md
|
211
|
+
Classifier: Programming Language :: Python :: 3
|
212
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
213
|
+
Classifier: Operating System :: OS Independent
|
214
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
215
|
+
Classifier: Topic :: Software Development :: Libraries
|
216
|
+
Requires-Python: >=3.9
|
217
|
+
Description-Content-Type: text/markdown
|
218
|
+
License-File: LICENSE
|
219
|
+
Requires-Dist: aiohttp
|
220
|
+
Requires-Dist: magika
|
221
|
+
Requires-Dist: numpy
|
222
|
+
Requires-Dist: pillow
|
223
|
+
Requires-Dist: pydantic>=2.0
|
224
|
+
Requires-Dist: requests
|
225
|
+
Requires-Dist: rich
|
226
|
+
Requires-Dist: typer
|
227
|
+
|
228
|
+
# Function for Python and CLI
|
229
|
+
|
230
|
+

|
231
|
+
|
232
|
+
[](https://fxn.ai/community)
|
233
|
+
|
234
|
+
Run AI prediction functions (a.k.a "predictors") in your Python apps. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
|
235
|
+
|
236
|
+
## Installing Function
|
237
|
+
Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
|
238
|
+
```sh
|
239
|
+
pip install --upgrade fxn
|
240
|
+
```
|
241
|
+
|
242
|
+
> [!NOTE]
|
243
|
+
> Function requires Python 3.9+
|
244
|
+
|
245
|
+
## Making a Prediction
|
246
|
+
Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
|
247
|
+
|
248
|
+
### In Python
|
249
|
+
Run the following Python script:
|
250
|
+
```py
|
251
|
+
from fxn import Function
|
252
|
+
|
253
|
+
# Create the Function client
|
254
|
+
fxn = Function()
|
255
|
+
# Create a prediction
|
256
|
+
prediction = fxn.predictions.create(
|
257
|
+
tag="@samplefxn/stable-diffusion",
|
258
|
+
inputs={
|
259
|
+
"prompt": "An astronaut riding a horse on Mars"
|
260
|
+
}
|
261
|
+
)
|
262
|
+
# Show the generated image
|
263
|
+
image = prediction.results[0]
|
264
|
+
image.show()
|
265
|
+
```
|
266
|
+
|
267
|
+
### In the CLI
|
268
|
+
Open up a terminal and run the following command:
|
269
|
+
|
270
|
+
```sh
|
271
|
+
fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
|
272
|
+
```
|
273
|
+
|
274
|
+
Within a few seconds, you should see a creepy-looking image pop up 😅:
|
275
|
+
|
276
|
+

|
277
|
+
|
278
|
+
## Creating a Predictor
|
279
|
+
At some point, you might want to create your own predictor. With Function, you don't have to deal with GitHub repos, Dockerfiles, or weird YAMLs. All you need is a Jupyter Notebook with a `predict` function. See our [samples project](https://github.com/fxnai/samples) for more.
|
280
|
+
|
281
|
+
___
|
282
|
+
|
283
|
+
## Useful Links
|
284
|
+
- [Discover predictors to use in your apps](https://fxn.ai/explore).
|
285
|
+
- [Join our Discord community](https://fxn.ai/community).
|
286
|
+
- [Check out our docs](https://docs.fxn.ai).
|
287
|
+
- Learn more about us [on our blog](https://blog.fxn.ai).
|
288
|
+
- Reach out to us at [hi@fxn.ai](mailto:hi@fxn.ai).
|
289
|
+
|
290
|
+
Function is a product of [NatML Inc](https://github.com/natmlx).
|
@@ -32,14 +32,12 @@ class GraphClient:
|
|
32
32
|
json={ "query": query, "variables": variables },
|
33
33
|
headers={ "Authorization": f"Bearer {self.access_key}" } if self.access_key else { }
|
34
34
|
)
|
35
|
-
# Check
|
36
35
|
payload = response.json()
|
36
|
+
# Check error
|
37
37
|
try:
|
38
38
|
response.raise_for_status()
|
39
|
-
except:
|
40
|
-
|
41
|
-
|
42
|
-
if "errors" in payload:
|
43
|
-
raise RuntimeError(payload["errors"][0]["message"])
|
39
|
+
except Exception as ex:
|
40
|
+
error = payload["errors"][0]["message"] if "errors" in payload else str(ex)
|
41
|
+
raise RuntimeError(error)
|
44
42
|
# Return
|
45
43
|
return payload["data"]
|
Binary file
|
Binary file
|
@@ -44,7 +44,9 @@ class PredictionService:
|
|
44
44
|
inputs: Dict[str, Union[ndarray, str, float, int, bool, List, Dict[str, Any], Path, Image.Image, Value]] = None,
|
45
45
|
raw_outputs: bool=False,
|
46
46
|
return_binary_path: bool=True,
|
47
|
-
data_url_limit: int=None
|
47
|
+
data_url_limit: int=None,
|
48
|
+
client_id: str=None,
|
49
|
+
configuration_id: str=None
|
48
50
|
) -> Prediction:
|
49
51
|
"""
|
50
52
|
Create a prediction.
|
@@ -55,6 +57,8 @@ class PredictionService:
|
|
55
57
|
raw_outputs (bool): Skip converting output values into Pythonic types. This only applies to `CLOUD` predictions.
|
56
58
|
return_binary_path (bool): Write binary values to file and return a `Path` instead of returning `BytesIO` instance.
|
57
59
|
data_url_limit (int): Return a data URL if a given output value is smaller than this size in bytes. This only applies to `CLOUD` predictions.
|
60
|
+
client_id (str): Function client identifier. Specify this to override the current client identifier.
|
61
|
+
configuration_id (str): Configuration identifier. Specify this to override the current client configuration identifier.
|
58
62
|
|
59
63
|
Returns:
|
60
64
|
Prediction: Created prediction.
|
@@ -66,13 +70,13 @@ class PredictionService:
|
|
66
70
|
key = uuid4().hex
|
67
71
|
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() } if inputs is not None else { }
|
68
72
|
# Query
|
69
|
-
response = post(
|
73
|
+
response = post(
|
70
74
|
f"{self.client.api_url}/predict/{tag}?rawOutputs=true&dataUrlLimit={data_url_limit}",
|
71
75
|
json=values,
|
72
76
|
headers={
|
73
77
|
"Authorization": f"Bearer {self.client.access_key}",
|
74
|
-
"fxn-client": self.__get_client_id(),
|
75
|
-
"fxn-configuration-token": self.
|
78
|
+
"fxn-client": client_id if client_id is not None else self.__get_client_id(),
|
79
|
+
"fxn-configuration-token": configuration_id if configuration_id is not None else self.__get_configuration_id()
|
76
80
|
}
|
77
81
|
)
|
78
82
|
# Check
|
@@ -84,12 +88,14 @@ class PredictionService:
|
|
84
88
|
raise RuntimeError(error)
|
85
89
|
# Parse prediction
|
86
90
|
prediction = self.__parse_prediction(prediction, raw_outputs=raw_outputs, return_binary_path=return_binary_path)
|
91
|
+
# Check edge prediction
|
92
|
+
if prediction.type != PredictorType.Edge or raw_outputs:
|
93
|
+
return prediction
|
94
|
+
# Load edge predictor
|
95
|
+
predictor = self.__load(prediction)
|
96
|
+
self.__cache[tag] = predictor
|
87
97
|
# Create edge prediction
|
88
|
-
|
89
|
-
predictor = self.__load(prediction)
|
90
|
-
self.__cache[tag] = predictor
|
91
|
-
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
92
|
-
# Return
|
98
|
+
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
93
99
|
return prediction
|
94
100
|
|
95
101
|
async def stream (
|
@@ -100,6 +106,8 @@ class PredictionService:
|
|
100
106
|
raw_outputs: bool=False,
|
101
107
|
return_binary_path: bool=True,
|
102
108
|
data_url_limit: int=None,
|
109
|
+
client_id: str=None,
|
110
|
+
configuration_id: str=None
|
103
111
|
) -> AsyncIterator[Prediction]:
|
104
112
|
"""
|
105
113
|
Create a streaming prediction.
|
@@ -112,6 +120,8 @@ class PredictionService:
|
|
112
120
|
raw_outputs (bool): Skip converting output values into Pythonic types. This only applies to `CLOUD` predictions.
|
113
121
|
return_binary_path (bool): Write binary values to file and return a `Path` instead of returning `BytesIO` instance.
|
114
122
|
data_url_limit (int): Return a data URL if a given output value is smaller than this size in bytes. This only applies to `CLOUD` predictions.
|
123
|
+
client_id (str): Function client identifier. Specify this to override the current client identifier.
|
124
|
+
configuration_id (str): Configuration identifier. Specify this to override the current client configuration identifier.
|
115
125
|
|
116
126
|
Returns:
|
117
127
|
Prediction: Created prediction.
|
@@ -122,14 +132,14 @@ class PredictionService:
|
|
122
132
|
return
|
123
133
|
# Serialize inputs
|
124
134
|
key = uuid4().hex
|
125
|
-
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() }
|
135
|
+
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() }
|
126
136
|
# Request
|
127
137
|
url = f"{self.client.api_url}/predict/{tag}?stream=true&rawOutputs=true&dataUrlLimit={data_url_limit}"
|
128
138
|
headers = {
|
129
139
|
"Content-Type": "application/json",
|
130
140
|
"Authorization": f"Bearer {self.client.access_key}",
|
131
|
-
"fxn-client": self.__get_client_id(),
|
132
|
-
"fxn-configuration-token": self.
|
141
|
+
"fxn-client": client_id if client_id is not None else self.__get_client_id(),
|
142
|
+
"fxn-configuration-token": configuration_id if configuration_id is not None else self.__get_configuration_id()
|
133
143
|
}
|
134
144
|
async with ClientSession(headers=headers) as session:
|
135
145
|
async with session.post(url, data=dumps(values)) as response:
|
@@ -143,12 +153,14 @@ class PredictionService:
|
|
143
153
|
raise RuntimeError(error)
|
144
154
|
# Parse prediction
|
145
155
|
prediction = self.__parse_prediction(prediction, raw_outputs=raw_outputs, return_binary_path=return_binary_path)
|
146
|
-
#
|
147
|
-
if prediction.type
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
156
|
+
# Check edge prediction
|
157
|
+
if prediction.type != PredictorType.Edge or raw_outputs:
|
158
|
+
return prediction
|
159
|
+
# Load edge predictor
|
160
|
+
predictor = self.__load(prediction)
|
161
|
+
self.__cache[tag] = predictor
|
162
|
+
# Create prediction
|
163
|
+
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
152
164
|
yield prediction
|
153
165
|
|
154
166
|
def to_object (
|
@@ -303,14 +315,14 @@ class PredictionService:
|
|
303
315
|
return f"windows:{machine()}"
|
304
316
|
raise RuntimeError(f"Function cannot make predictions on the {id} platform")
|
305
317
|
|
306
|
-
def
|
318
|
+
def __get_configuration_id (self) -> Optional[str]:
|
307
319
|
# Check
|
308
320
|
if not self.__fxnc:
|
309
321
|
return None
|
310
322
|
# Get
|
311
323
|
buffer = create_string_buffer(2048)
|
312
324
|
status = self.__fxnc.FXNConfigurationGetUniqueID(buffer, len(buffer))
|
313
|
-
assert status.value == FXNStatus.OK, f"Failed to create prediction configuration
|
325
|
+
assert status.value == FXNStatus.OK, f"Failed to create prediction configuration identifier with status: {status.value}"
|
314
326
|
uid = buffer.value.decode("utf-8")
|
315
327
|
# Return
|
316
328
|
return uid
|
@@ -0,0 +1,290 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: fxn
|
3
|
+
Version: 0.0.33
|
4
|
+
Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
|
5
|
+
Author-email: "NatML Inc." <hi@fxn.ai>
|
6
|
+
License: Apache License
|
7
|
+
Version 2.0, January 2004
|
8
|
+
http://www.apache.org/licenses/
|
9
|
+
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
11
|
+
|
12
|
+
1. Definitions.
|
13
|
+
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
16
|
+
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
18
|
+
the copyright owner that is granting the License.
|
19
|
+
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
21
|
+
other entities that control, are controlled by, or are under common
|
22
|
+
control with that entity. For the purposes of this definition,
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
24
|
+
direction or management of such entity, whether by contract or
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
27
|
+
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
29
|
+
exercising permissions granted by this License.
|
30
|
+
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
32
|
+
including but not limited to software source code, documentation
|
33
|
+
source, and configuration files.
|
34
|
+
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
36
|
+
transformation or translation of a Source form, including but
|
37
|
+
not limited to compiled object code, generated documentation,
|
38
|
+
and conversions to other media types.
|
39
|
+
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
41
|
+
Object form, made available under the License, as indicated by a
|
42
|
+
copyright notice that is included in or attached to the work
|
43
|
+
(an example is provided in the Appendix below).
|
44
|
+
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
51
|
+
the Work and Derivative Works thereof.
|
52
|
+
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
54
|
+
the original version of the Work and any modifications or additions
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
66
|
+
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
69
|
+
subsequently incorporated within the Work.
|
70
|
+
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
77
|
+
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
83
|
+
where such license applies only to those patent claims licensable
|
84
|
+
by such Contributor that are necessarily infringed by their
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
87
|
+
institute patent litigation against any entity (including a
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
90
|
+
or contributory patent infringement, then any patent licenses
|
91
|
+
granted to You under this License for that Work shall terminate
|
92
|
+
as of the date such litigation is filed.
|
93
|
+
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
96
|
+
modifications, and in Source or Object form, provided that You
|
97
|
+
meet the following conditions:
|
98
|
+
|
99
|
+
(a) You must give any other recipients of the Work or
|
100
|
+
Derivative Works a copy of this License; and
|
101
|
+
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
103
|
+
stating that You changed the files; and
|
104
|
+
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
107
|
+
attribution notices from the Source form of the Work,
|
108
|
+
excluding those notices that do not pertain to any part of
|
109
|
+
the Derivative Works; and
|
110
|
+
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
113
|
+
include a readable copy of the attribution notices contained
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
116
|
+
of the following places: within a NOTICE text file distributed
|
117
|
+
as part of the Derivative Works; within the Source form or
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
119
|
+
within a display generated by the Derivative Works, if and
|
120
|
+
wherever such third-party notices normally appear. The contents
|
121
|
+
of the NOTICE file are for informational purposes only and
|
122
|
+
do not modify the License. You may add Your own attribution
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
125
|
+
that such additional attribution notices cannot be construed
|
126
|
+
as modifying the License.
|
127
|
+
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
129
|
+
may provide additional or different license terms and conditions
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
133
|
+
the conditions stated in this License.
|
134
|
+
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
138
|
+
this License, without any additional terms or conditions.
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
140
|
+
the terms of any separate license agreement you may have executed
|
141
|
+
with Licensor regarding such Contributions.
|
142
|
+
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
145
|
+
except as required for reasonable and customary use in describing the
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
147
|
+
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
157
|
+
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
163
|
+
incidental, or consequential damages of any character arising as a
|
164
|
+
result of this License or out of the use or inability to use the
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
167
|
+
other commercial damages or losses), even if such Contributor
|
168
|
+
has been advised of the possibility of such damages.
|
169
|
+
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
173
|
+
or other liability obligations and/or rights consistent with this
|
174
|
+
License. However, in accepting such obligations, You may act only
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
179
|
+
of your accepting any such warranty or additional liability.
|
180
|
+
|
181
|
+
END OF TERMS AND CONDITIONS
|
182
|
+
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
184
|
+
|
185
|
+
To apply the Apache License to your work, attach the following
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
187
|
+
replaced with your own identifying information. (Don't include
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
189
|
+
comment syntax for the file format. We also recommend that a
|
190
|
+
file or class name and description of purpose be included on the
|
191
|
+
same "printed page" as the copyright notice for easier
|
192
|
+
identification within third-party archives.
|
193
|
+
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
195
|
+
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
197
|
+
you may not use this file except in compliance with the License.
|
198
|
+
You may obtain a copy of the License at
|
199
|
+
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
201
|
+
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
205
|
+
See the License for the specific language governing permissions and
|
206
|
+
limitations under the License.
|
207
|
+
Project-URL: Homepage, https://fxn.ai
|
208
|
+
Project-URL: Documentation, https://docs.fxn.ai
|
209
|
+
Project-URL: Source, https://github.com/fxnai/fxn
|
210
|
+
Project-URL: Changelog, https://github.com/fxnai/fxn/blob/main/Changelog.md
|
211
|
+
Classifier: Programming Language :: Python :: 3
|
212
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
213
|
+
Classifier: Operating System :: OS Independent
|
214
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
215
|
+
Classifier: Topic :: Software Development :: Libraries
|
216
|
+
Requires-Python: >=3.9
|
217
|
+
Description-Content-Type: text/markdown
|
218
|
+
License-File: LICENSE
|
219
|
+
Requires-Dist: aiohttp
|
220
|
+
Requires-Dist: magika
|
221
|
+
Requires-Dist: numpy
|
222
|
+
Requires-Dist: pillow
|
223
|
+
Requires-Dist: pydantic>=2.0
|
224
|
+
Requires-Dist: requests
|
225
|
+
Requires-Dist: rich
|
226
|
+
Requires-Dist: typer
|
227
|
+
|
228
|
+
# Function for Python and CLI
|
229
|
+
|
230
|
+

|
231
|
+
|
232
|
+
[](https://fxn.ai/community)
|
233
|
+
|
234
|
+
Run AI prediction functions (a.k.a "predictors") in your Python apps. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
|
235
|
+
|
236
|
+
## Installing Function
|
237
|
+
Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
|
238
|
+
```sh
|
239
|
+
pip install --upgrade fxn
|
240
|
+
```
|
241
|
+
|
242
|
+
> [!NOTE]
|
243
|
+
> Function requires Python 3.9+
|
244
|
+
|
245
|
+
## Making a Prediction
|
246
|
+
Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
|
247
|
+
|
248
|
+
### In Python
|
249
|
+
Run the following Python script:
|
250
|
+
```py
|
251
|
+
from fxn import Function
|
252
|
+
|
253
|
+
# Create the Function client
|
254
|
+
fxn = Function()
|
255
|
+
# Create a prediction
|
256
|
+
prediction = fxn.predictions.create(
|
257
|
+
tag="@samplefxn/stable-diffusion",
|
258
|
+
inputs={
|
259
|
+
"prompt": "An astronaut riding a horse on Mars"
|
260
|
+
}
|
261
|
+
)
|
262
|
+
# Show the generated image
|
263
|
+
image = prediction.results[0]
|
264
|
+
image.show()
|
265
|
+
```
|
266
|
+
|
267
|
+
### In the CLI
|
268
|
+
Open up a terminal and run the following command:
|
269
|
+
|
270
|
+
```sh
|
271
|
+
fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
|
272
|
+
```
|
273
|
+
|
274
|
+
Within a few seconds, you should see a creepy-looking image pop up 😅:
|
275
|
+
|
276
|
+

|
277
|
+
|
278
|
+
## Creating a Predictor
|
279
|
+
At some point, you might want to create your own predictor. With Function, you don't have to deal with GitHub repos, Dockerfiles, or weird YAMLs. All you need is a Jupyter Notebook with a `predict` function. See our [samples project](https://github.com/fxnai/samples) for more.
|
280
|
+
|
281
|
+
___
|
282
|
+
|
283
|
+
## Useful Links
|
284
|
+
- [Discover predictors to use in your apps](https://fxn.ai/explore).
|
285
|
+
- [Join our Discord community](https://fxn.ai/community).
|
286
|
+
- [Check out our docs](https://docs.fxn.ai).
|
287
|
+
- Learn more about us [on our blog](https://blog.fxn.ai).
|
288
|
+
- Reach out to us at [hi@fxn.ai](mailto:hi@fxn.ai).
|
289
|
+
|
290
|
+
Function is a product of [NatML Inc](https://github.com/natmlx).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
LICENSE
|
2
2
|
README.md
|
3
|
-
|
3
|
+
pyproject.toml
|
4
4
|
fxn/__init__.py
|
5
5
|
fxn/function.py
|
6
6
|
fxn/magic.py
|
@@ -21,7 +21,9 @@ fxn/graph/__init__.py
|
|
21
21
|
fxn/graph/client.py
|
22
22
|
fxn/libs/__init__.py
|
23
23
|
fxn/libs/linux/__init__.py
|
24
|
+
fxn/libs/macos/Function.dylib
|
24
25
|
fxn/libs/macos/__init__.py
|
26
|
+
fxn/libs/windows/Function.dll
|
25
27
|
fxn/libs/windows/__init__.py
|
26
28
|
fxn/services/__init__.py
|
27
29
|
fxn/services/environment.py
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
[project]
|
7
|
+
name = "fxn"
|
8
|
+
dynamic = ["version"]
|
9
|
+
description = "Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai."
|
10
|
+
readme = "README.md"
|
11
|
+
dependencies = [
|
12
|
+
"aiohttp",
|
13
|
+
"magika",
|
14
|
+
"numpy",
|
15
|
+
"pillow",
|
16
|
+
"pydantic>=2.0",
|
17
|
+
"requests",
|
18
|
+
"rich",
|
19
|
+
"typer"
|
20
|
+
]
|
21
|
+
requires-python = ">=3.9"
|
22
|
+
authors = [ { name = "NatML Inc.", email = "hi@fxn.ai" } ]
|
23
|
+
license = { file = "LICENSE" }
|
24
|
+
classifiers = [
|
25
|
+
"Programming Language :: Python :: 3",
|
26
|
+
"License :: OSI Approved :: Apache Software License",
|
27
|
+
"Operating System :: OS Independent",
|
28
|
+
"Topic :: Scientific/Engineering :: Image Recognition",
|
29
|
+
"Topic :: Software Development :: Libraries",
|
30
|
+
]
|
31
|
+
|
32
|
+
[project.urls]
|
33
|
+
Homepage = "https://fxn.ai"
|
34
|
+
Documentation = "https://docs.fxn.ai"
|
35
|
+
Source = "https://github.com/fxnai/fxn"
|
36
|
+
Changelog = "https://github.com/fxnai/fxn/blob/main/Changelog.md"
|
37
|
+
|
38
|
+
[project.optional-dependencies]
|
39
|
+
# None
|
40
|
+
|
41
|
+
[project.scripts]
|
42
|
+
fxn = "fxn.cli.__init__:app"
|
43
|
+
|
44
|
+
[build-system]
|
45
|
+
requires = ["setuptools>=42", "wheel"]
|
46
|
+
build-backend = "setuptools.build_meta"
|
47
|
+
|
48
|
+
[tool.setuptools]
|
49
|
+
include-package-data = true
|
50
|
+
|
51
|
+
[tool.setuptools.packages.find]
|
52
|
+
include = ["fxn", "fxn*"]
|
53
|
+
namespaces = false
|
54
|
+
|
55
|
+
[tool.setuptools.package-data]
|
56
|
+
"fxn.libs.macos" = ["*.dylib"]
|
57
|
+
"fxn.libs.windows" = ["*.dll"]
|
58
|
+
"fxn.libs.linux" = ["*.so"]
|
59
|
+
|
60
|
+
[tool.setuptools.dynamic]
|
61
|
+
version = { attr = "fxn.version.__version__" }
|
fxn-0.0.31/PKG-INFO
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: fxn
|
3
|
-
Version: 0.0.31
|
4
|
-
Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
|
5
|
-
Home-page: https://fxn.ai
|
6
|
-
Author: NatML Inc.
|
7
|
-
Author-email: hi@fxn.ai
|
8
|
-
License: Apache License 2.0
|
9
|
-
Project-URL: Documentation, https://docs.fxn.ai
|
10
|
-
Project-URL: Source, https://github.com/fxnai/fxn
|
11
|
-
Platform: UNKNOWN
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
14
|
-
Classifier: Operating System :: OS Independent
|
15
|
-
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
16
|
-
Classifier: Topic :: Software Development :: Libraries
|
17
|
-
Requires-Python: >=3.9
|
18
|
-
Description-Content-Type: text/markdown
|
19
|
-
License-File: LICENSE
|
20
|
-
|
21
|
-
# Function for Python and CLI
|
22
|
-
|
23
|
-

|
24
|
-
|
25
|
-
[](https://fxn.ai/community)
|
26
|
-
|
27
|
-
Run AI prediction functions (a.k.a "predictors") in your Python apps. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
|
28
|
-
|
29
|
-
## Installing Function
|
30
|
-
Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
|
31
|
-
```sh
|
32
|
-
pip install --upgrade fxn
|
33
|
-
```
|
34
|
-
|
35
|
-
> [!NOTE]
|
36
|
-
> Function requires Python 3.9+
|
37
|
-
|
38
|
-
## Making a Prediction
|
39
|
-
Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
|
40
|
-
|
41
|
-
### In Python
|
42
|
-
Run the following Python script:
|
43
|
-
```py
|
44
|
-
from fxn import Function
|
45
|
-
|
46
|
-
# Create the Function client
|
47
|
-
fxn = Function()
|
48
|
-
# Create a prediction
|
49
|
-
prediction = fxn.predictions.create(
|
50
|
-
tag="@samplefxn/stable-diffusion",
|
51
|
-
inputs={
|
52
|
-
"prompt": "An astronaut riding a horse on Mars"
|
53
|
-
}
|
54
|
-
)
|
55
|
-
# Show the generated image
|
56
|
-
image = prediction.results[0]
|
57
|
-
image.show()
|
58
|
-
```
|
59
|
-
|
60
|
-
### In the CLI
|
61
|
-
Open up a terminal and run the following command:
|
62
|
-
|
63
|
-
```sh
|
64
|
-
fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
|
65
|
-
```
|
66
|
-
|
67
|
-
Within a few seconds, you should see a creepy-looking image pop up 😅:
|
68
|
-
|
69
|
-

|
70
|
-
|
71
|
-
## Creating a Predictor
|
72
|
-
At some point, you might want to create your own predictor. With Function, you don't have to deal with GitHub repos, Dockerfiles, or weird YAMLs. All you need is a Jupyter Notebook with a `predict` function. See our [samples project](https://github.com/fxnai/samples) for more.
|
73
|
-
|
74
|
-
___
|
75
|
-
|
76
|
-
## Useful Links
|
77
|
-
- [Discover predictors to use in your apps](https://fxn.ai/explore).
|
78
|
-
- [Join our Discord community](https://fxn.ai/community).
|
79
|
-
- [Check out our docs](https://docs.fxn.ai).
|
80
|
-
- Learn more about us [on our blog](https://blog.fxn.ai).
|
81
|
-
- Reach out to us at [hi@fxn.ai](mailto:hi@fxn.ai).
|
82
|
-
|
83
|
-
Function is a product of [NatML Inc](https://github.com/natmlx).
|
84
|
-
|
85
|
-
|
fxn-0.0.31/fxn.egg-info/PKG-INFO
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: fxn
|
3
|
-
Version: 0.0.31
|
4
|
-
Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
|
5
|
-
Home-page: https://fxn.ai
|
6
|
-
Author: NatML Inc.
|
7
|
-
Author-email: hi@fxn.ai
|
8
|
-
License: Apache License 2.0
|
9
|
-
Project-URL: Documentation, https://docs.fxn.ai
|
10
|
-
Project-URL: Source, https://github.com/fxnai/fxn
|
11
|
-
Platform: UNKNOWN
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
14
|
-
Classifier: Operating System :: OS Independent
|
15
|
-
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
16
|
-
Classifier: Topic :: Software Development :: Libraries
|
17
|
-
Requires-Python: >=3.9
|
18
|
-
Description-Content-Type: text/markdown
|
19
|
-
License-File: LICENSE
|
20
|
-
|
21
|
-
# Function for Python and CLI
|
22
|
-
|
23
|
-

|
24
|
-
|
25
|
-
[](https://fxn.ai/community)
|
26
|
-
|
27
|
-
Run AI prediction functions (a.k.a "predictors") in your Python apps. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
|
28
|
-
|
29
|
-
## Installing Function
|
30
|
-
Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
|
31
|
-
```sh
|
32
|
-
pip install --upgrade fxn
|
33
|
-
```
|
34
|
-
|
35
|
-
> [!NOTE]
|
36
|
-
> Function requires Python 3.9+
|
37
|
-
|
38
|
-
## Making a Prediction
|
39
|
-
Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
|
40
|
-
|
41
|
-
### In Python
|
42
|
-
Run the following Python script:
|
43
|
-
```py
|
44
|
-
from fxn import Function
|
45
|
-
|
46
|
-
# Create the Function client
|
47
|
-
fxn = Function()
|
48
|
-
# Create a prediction
|
49
|
-
prediction = fxn.predictions.create(
|
50
|
-
tag="@samplefxn/stable-diffusion",
|
51
|
-
inputs={
|
52
|
-
"prompt": "An astronaut riding a horse on Mars"
|
53
|
-
}
|
54
|
-
)
|
55
|
-
# Show the generated image
|
56
|
-
image = prediction.results[0]
|
57
|
-
image.show()
|
58
|
-
```
|
59
|
-
|
60
|
-
### In the CLI
|
61
|
-
Open up a terminal and run the following command:
|
62
|
-
|
63
|
-
```sh
|
64
|
-
fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
|
65
|
-
```
|
66
|
-
|
67
|
-
Within a few seconds, you should see a creepy-looking image pop up 😅:
|
68
|
-
|
69
|
-

|
70
|
-
|
71
|
-
## Creating a Predictor
|
72
|
-
At some point, you might want to create your own predictor. With Function, you don't have to deal with GitHub repos, Dockerfiles, or weird YAMLs. All you need is a Jupyter Notebook with a `predict` function. See our [samples project](https://github.com/fxnai/samples) for more.
|
73
|
-
|
74
|
-
___
|
75
|
-
|
76
|
-
## Useful Links
|
77
|
-
- [Discover predictors to use in your apps](https://fxn.ai/explore).
|
78
|
-
- [Join our Discord community](https://fxn.ai/community).
|
79
|
-
- [Check out our docs](https://docs.fxn.ai).
|
80
|
-
- Learn more about us [on our blog](https://blog.fxn.ai).
|
81
|
-
- Reach out to us at [hi@fxn.ai](mailto:hi@fxn.ai).
|
82
|
-
|
83
|
-
Function is a product of [NatML Inc](https://github.com/natmlx).
|
84
|
-
|
85
|
-
|
fxn-0.0.31/setup.py
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Function
|
3
|
-
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
from setuptools import find_packages, setup
|
7
|
-
|
8
|
-
# Get readme
|
9
|
-
with open("README.md", "r") as readme:
|
10
|
-
long_description = readme.read()
|
11
|
-
|
12
|
-
# Get version
|
13
|
-
with open("fxn/version.py") as version_source:
|
14
|
-
gvars = {}
|
15
|
-
exec(version_source.read(), gvars)
|
16
|
-
version = gvars["__version__"]
|
17
|
-
|
18
|
-
# Setup
|
19
|
-
setup(
|
20
|
-
name="fxn",
|
21
|
-
version=version,
|
22
|
-
author="NatML Inc.",
|
23
|
-
author_email="hi@fxn.ai",
|
24
|
-
description="Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.",
|
25
|
-
long_description=long_description,
|
26
|
-
long_description_content_type="text/markdown",
|
27
|
-
license="Apache License 2.0",
|
28
|
-
python_requires=">=3.9",
|
29
|
-
install_requires=[
|
30
|
-
"aiohttp",
|
31
|
-
"magika",
|
32
|
-
"numpy",
|
33
|
-
"pillow",
|
34
|
-
"pydantic>=2.0",
|
35
|
-
"requests",
|
36
|
-
"rich",
|
37
|
-
"typer"
|
38
|
-
],
|
39
|
-
url="https://fxn.ai",
|
40
|
-
packages=find_packages(
|
41
|
-
include=["fxn", "fxn.*"],
|
42
|
-
exclude=["test", "examples"]
|
43
|
-
),
|
44
|
-
include_package_data=True,
|
45
|
-
package_data={
|
46
|
-
"fxn.libs.macos": ["*.dylib"],
|
47
|
-
"fxn.libs.windows": ["*.dll"],
|
48
|
-
"fxn.libs.linux": ["*.so"]
|
49
|
-
},
|
50
|
-
entry_points={
|
51
|
-
"console_scripts": [
|
52
|
-
"fxn=fxn.cli.__init__:app"
|
53
|
-
]
|
54
|
-
},
|
55
|
-
classifiers=[
|
56
|
-
"Programming Language :: Python :: 3",
|
57
|
-
"License :: OSI Approved :: Apache Software License",
|
58
|
-
"Operating System :: OS Independent",
|
59
|
-
"Topic :: Scientific/Engineering :: Image Recognition",
|
60
|
-
"Topic :: Software Development :: Libraries",
|
61
|
-
],
|
62
|
-
project_urls={
|
63
|
-
"Documentation": "https://docs.fxn.ai",
|
64
|
-
"Source": "https://github.com/fxnai/fxn"
|
65
|
-
},
|
66
|
-
)
|
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
|