fxn 0.0.14__py3-none-any.whl → 0.0.16__py3-none-any.whl
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/api/predictor.py +8 -8
- fxn/cli/predict.py +15 -8
- fxn/version.py +1 -1
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/METADATA +20 -18
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/RECORD +9 -9
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/LICENSE +0 -0
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/WHEEL +0 -0
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/entry_points.txt +0 -0
- {fxn-0.0.14.dist-info → fxn-0.0.16.dist-info}/top_level.txt +0 -0
fxn/api/predictor.py
CHANGED
@@ -9,7 +9,7 @@ from enum import Enum
|
|
9
9
|
from pathlib import Path
|
10
10
|
from typing import Dict, List, Optional, Tuple, Union
|
11
11
|
|
12
|
-
from .api import query
|
12
|
+
from .api import query as queryfxn
|
13
13
|
from .dtype import Dtype
|
14
14
|
from .profile import Profile
|
15
15
|
from .storage import Storage, UploadType
|
@@ -111,7 +111,7 @@ class Predictor:
|
|
111
111
|
Predictor: Predictor.
|
112
112
|
"""
|
113
113
|
# Query
|
114
|
-
response =
|
114
|
+
response = queryfxn(f"""
|
115
115
|
query ($input: PredictorInput!) {{
|
116
116
|
predictor (input: $input) {{
|
117
117
|
{cls.FIELDS}
|
@@ -150,7 +150,7 @@ class Predictor:
|
|
150
150
|
list: User predictors.
|
151
151
|
"""
|
152
152
|
# Query
|
153
|
-
response =
|
153
|
+
response = queryfxn(f"""
|
154
154
|
query ($user: UserInput, $predictors: UserPredictorsInput) {{
|
155
155
|
user (input: $user) {{
|
156
156
|
predictors (input: $predictors) {{
|
@@ -187,7 +187,7 @@ class Predictor:
|
|
187
187
|
Search predictors.
|
188
188
|
|
189
189
|
Parameters:
|
190
|
-
|
190
|
+
q (str): Search query.
|
191
191
|
offset (int): Pagination offset.
|
192
192
|
count (int): Pagination count.
|
193
193
|
access_key (str): Function access key.
|
@@ -196,7 +196,7 @@ class Predictor:
|
|
196
196
|
list: Relevant predictors.
|
197
197
|
"""
|
198
198
|
# Query
|
199
|
-
response =
|
199
|
+
response = queryfxn(f"""
|
200
200
|
query ($input: PredictorsInput!) {{
|
201
201
|
predictors (input: $input) {{
|
202
202
|
{cls.FIELDS}
|
@@ -251,7 +251,7 @@ class Predictor:
|
|
251
251
|
notebook = Storage.upload(notebook, UploadType.Notebook) if isinstance(notebook, Path) else notebook
|
252
252
|
media = Storage.upload(media, UploadType.Media) if isinstance(media, Path) else media
|
253
253
|
# Query
|
254
|
-
response =
|
254
|
+
response = queryfxn(f"""
|
255
255
|
mutation ($input: CreatePredictorInput!) {{
|
256
256
|
createPredictor (input: $input) {{
|
257
257
|
{cls.FIELDS}
|
@@ -297,7 +297,7 @@ class Predictor:
|
|
297
297
|
bool: Whether the predictor was successfully deleted.
|
298
298
|
"""
|
299
299
|
# Query
|
300
|
-
response =
|
300
|
+
response = queryfxn(f"""
|
301
301
|
mutation ($input: DeletePredictorInput!) {{
|
302
302
|
deletePredictor (input: $input)
|
303
303
|
}}
|
@@ -326,7 +326,7 @@ class Predictor:
|
|
326
326
|
Predictor: Archived predictor.
|
327
327
|
"""
|
328
328
|
# Query
|
329
|
-
response =
|
329
|
+
response = queryfxn(f"""
|
330
330
|
mutation ($input: ArchivePredictorInput!) {{
|
331
331
|
archivePredictor (input: $input) {{
|
332
332
|
{cls.FIELDS}
|
fxn/cli/predict.py
CHANGED
@@ -9,6 +9,7 @@ from numpy import ndarray
|
|
9
9
|
from pathlib import Path, PurePath
|
10
10
|
from PIL import Image
|
11
11
|
from rich import print_json
|
12
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
12
13
|
from tempfile import mkstemp
|
13
14
|
from typer import Argument, Context, Option
|
14
15
|
|
@@ -21,14 +22,20 @@ def predict (
|
|
21
22
|
context: Context = 0
|
22
23
|
):
|
23
24
|
# Predict
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
with Progress(
|
26
|
+
SpinnerColumn(spinner_name="point"),
|
27
|
+
TextColumn("[progress.description]{task.description}"),
|
28
|
+
transient=True
|
29
|
+
) as progress:
|
30
|
+
progress.add_task(description="Making prediction...", total=None)
|
31
|
+
inputs = { context.args[i].replace("-", ""): _parse_value(context.args[i+1]) for i in range(0, len(context.args), 2) }
|
32
|
+
prediction = Prediction.create(
|
33
|
+
tag=tag,
|
34
|
+
**inputs,
|
35
|
+
raw_outputs=raw_outputs,
|
36
|
+
return_binary_path=True,
|
37
|
+
access_key=get_access_key()
|
38
|
+
)
|
32
39
|
# Parse results
|
33
40
|
images = []
|
34
41
|
if hasattr(prediction, "results") and prediction.results is not None:
|
fxn/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fxn
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.16
|
4
4
|
Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
|
5
5
|
Home-page: https://fxn.ai
|
6
6
|
Author: NatML Inc.
|
@@ -33,33 +33,35 @@ Run AI prediction functions (a.k.a "predictors") in your Python apps. With Funct
|
|
33
33
|
## Installing Function
|
34
34
|
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:
|
35
35
|
```sh
|
36
|
-
pip install fxn
|
36
|
+
pip install --upgrade fxn
|
37
37
|
```
|
38
38
|
|
39
39
|
> Note that Function requires Python 3.9+
|
40
40
|
|
41
|
-
##
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
## Making a Prediction
|
42
|
+
Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
|
43
|
+
|
44
|
+
### In Python
|
45
|
+
Run the following Python script:
|
46
|
+
```py
|
47
|
+
import fxn
|
48
|
+
|
49
|
+
prediction = fxn.Prediction.create(
|
50
|
+
tag="@samplefxn/stable-diffusion",
|
51
|
+
prompt="An astronaut riding a horse on Mars"
|
52
|
+
)
|
53
|
+
image = prediction.results[0]
|
54
|
+
image.show()
|
49
55
|
```
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-

|
54
|
-
|
55
|
-
## Making a Prediction
|
56
|
-
You can start off by running an existing predictor [on Function](https://fxn.ai/explore). Let's run the [`@natml/stable-diffusion`](https://fxn.ai/@natml/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image. In terminal, run the following command:
|
57
|
+
### In the CLI
|
58
|
+
Open up a terminal and run the following command:
|
57
59
|
|
58
60
|
```sh
|
59
|
-
fxn predict @
|
61
|
+
fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
|
60
62
|
```
|
61
63
|
|
62
|
-
|
64
|
+
Within a few seconds, you should see a creepy-looking image pop up 😅:
|
63
65
|
|
64
66
|

|
65
67
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
fxn/__init__.py,sha256=0NzZl5hRQ0MPNN4Wp9-ghqak2NJzhfHvVyBGX-IntKs,320
|
2
2
|
fxn/magic.py,sha256=TRgE68OAo1djmeQRiqxnSJqa72td6zxnwo0s0bkdUKM,1041
|
3
|
-
fxn/version.py,sha256=
|
3
|
+
fxn/version.py,sha256=PVMyxP-O98TEP8WlKBEi04kzavQs4NlWxAjlIIBJ86w,95
|
4
4
|
fxn/api/__init__.py,sha256=UcCERjadfSbqnt7urXYbrdRRFwA0QwpC9uBQYPJC5rE,460
|
5
5
|
fxn/api/api.py,sha256=X2LRjer0s7ifecYsZmdqv5txEwPjA2ekdSCGUaQJ5So,927
|
6
6
|
fxn/api/dtype.py,sha256=z9zjjsOk8X8LTCEpwLuWOTUys6nP_3L6VmZXLt0ilAY,617
|
7
7
|
fxn/api/environment.py,sha256=qZObVWl2UneTy9iYm4b1KRHiapW1qafvVp4P6s5KBCc,3874
|
8
8
|
fxn/api/prediction.py,sha256=IKyFZ593FvlVVF0sljPR8S3m7JSX0TSOAK_9s24I5eU,4140
|
9
|
-
fxn/api/predictor.py,sha256=
|
9
|
+
fxn/api/predictor.py,sha256=T0ywK1rjeqwwxhJXiDukQb35Jm63Fk5TiseR94q-O38,13009
|
10
10
|
fxn/api/profile.py,sha256=76RVnP0wF9eT5kefqbRVj2T7e-6yZbK4bzggDS1CYjY,876
|
11
11
|
fxn/api/storage.py,sha256=GxSwYN5xOWovVJh1WfkVkwkWdCoBkeNP9OHTX8KgEiQ,4560
|
12
12
|
fxn/api/tag.py,sha256=g7HuRv5ZCYYDy4iV8P0hR1tEQ1pZjv-HeqbE0-Li1Bs,832
|
@@ -16,11 +16,11 @@ fxn/cli/__init__.py,sha256=5-yqKCUJCiNTA_7EHfCj5GZKthIQSdbPcVAdMnzYNLg,1492
|
|
16
16
|
fxn/cli/auth.py,sha256=_5rZ9L-blD39U6-SgHV9V2ltyjJ7k32NY3bLvoGsaNc,1659
|
17
17
|
fxn/cli/env.py,sha256=mnyaL27n59pCU-p2Jm1fo03se7btMV2zdoJWWVshF_M,1658
|
18
18
|
fxn/cli/misc.py,sha256=gLEGGWyawUQaLOuy8bfS2wrJuS-tN-bleOrv5A07xck,690
|
19
|
-
fxn/cli/predict.py,sha256=
|
19
|
+
fxn/cli/predict.py,sha256=QPNmwLAF8KndaVSS2vt0OBB-UoRn0VHgM2CNmIN6EEw,3180
|
20
20
|
fxn/cli/predictors.py,sha256=vAL1FioQSseEiu7jbXY0DRiHnnMmThK2csJLThizS7A,3481
|
21
|
-
fxn-0.0.
|
22
|
-
fxn-0.0.
|
23
|
-
fxn-0.0.
|
24
|
-
fxn-0.0.
|
25
|
-
fxn-0.0.
|
26
|
-
fxn-0.0.
|
21
|
+
fxn-0.0.16.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
22
|
+
fxn-0.0.16.dist-info/METADATA,sha256=guWZoXVbaAkQGXgtuCLx6UJ5tL4wCf4kzMpQDPs3GYo,2887
|
23
|
+
fxn-0.0.16.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
24
|
+
fxn-0.0.16.dist-info/entry_points.txt,sha256=QBwKIRed76CRY98VYQYrQDVEBZtJugxJJmBpilxuios,46
|
25
|
+
fxn-0.0.16.dist-info/top_level.txt,sha256=1ULIEGrnMlhId8nYAkjmRn9g3KEFuHKboq193SEKQkA,4
|
26
|
+
fxn-0.0.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|