-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-1 loading ARW images included into script
- Loading branch information
1 parent
0d0469c
commit f70008a
Showing
2 changed files
with
43 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os.path | ||
from pathlib import Path | ||
import rawpy | ||
import numpy as np | ||
from PIL import Image | ||
|
||
def find_model_files(dir : str) -> list: | ||
p = Path(dir) | ||
return list(p.glob("*.pt")) | ||
|
||
def load_arw(fpath : str) -> np.ndarray: | ||
""" | ||
Loading an ARW image. Thanks to Rob | ||
""" | ||
raw = rawpy.imread(fpath) | ||
return raw.postprocess(use_camera_wb=True, output_bps=8) | ||
|
||
def read_arw_as_pil(fpath : str) -> Image.Image: | ||
""" | ||
function to return an ARW image in PIL format for SAHI | ||
""" | ||
np_arr = load_arw(fpath) | ||
return Image.fromarray(np_arr) |