forked from mattyamonaca/PBRemTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue mattyamonaca#36 caused by double running code due to import. mattyamonaca#36
- Loading branch information
Showing
3 changed files
with
26 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import cv2 | ||
|
||
from scripts.td_abg import get_foreground | ||
from scripts.convertor import pil2cv | ||
|
||
try: | ||
from modules.paths_internal import extensions_dir | ||
except Exception: | ||
from modules.extensions import extensions_dir | ||
|
||
from collections import OrderedDict | ||
|
||
model_cache = OrderedDict() | ||
sam_model_dir = os.path.join( | ||
extensions_dir, "PBRemTools/models/") | ||
model_list = [f for f in os.listdir(sam_model_dir) if os.path.isfile( | ||
os.path.join(sam_model_dir, f)) and f.split('.')[-1] != 'txt'] | ||
|
||
def process_image(target_image, *rem_args): | ||
image = pil2cv(target_image) | ||
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | ||
mask, image = get_foreground(image, *rem_args) | ||
return image, mask |