-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
job_step_preview
field to Query Job
api
- Loading branch information
1 parent
0a1c4e7
commit 8aec8db
Showing
7 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '0.3.12' | ||
version = '0.3.13' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import base64 | ||
from io import BytesIO | ||
import numpy as np | ||
from fastapi import Response, UploadFile | ||
from PIL import Image | ||
|
||
|
||
def narray_to_base64img(narray: np.ndarray) -> str: | ||
if narray is None: | ||
return None | ||
|
||
img = Image.fromarray(narray) | ||
output_buffer = BytesIO() | ||
img.save(output_buffer, format='PNG') | ||
byte_data = output_buffer.getvalue() | ||
base64_str = base64.b64encode(byte_data) | ||
return base64_str | ||
|
||
|
||
def narray_to_bytesimg(narray) -> bytes: | ||
if narray is None: | ||
return None | ||
|
||
img = Image.fromarray(narray) | ||
output_buffer = BytesIO() | ||
img.save(output_buffer, format='PNG') | ||
byte_data = output_buffer.getvalue() | ||
return byte_data | ||
|
||
|
||
def read_input_image(input_image: UploadFile) -> np.ndarray: | ||
input_image_bytes = input_image.file.read() | ||
pil_image = Image.open(BytesIO(input_image_bytes)) | ||
image = np.array(pil_image) | ||
return image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters