Commit
·
8d575db
1
Parent(s):
65fdeb0
Enable GPU auto-selection (CUDA if available) with DEVICE override; load TorchScript model on selected device. Reference: https://huggingface.co/spaces/LogicGoInfotechSpaces/Hair_stable_new/tree/main
Browse files- src/core.py +3 -2
src/core.py
CHANGED
|
@@ -64,9 +64,10 @@ ENERGY_MASK_CONST = 100000.0 # large energy value for protective ma
|
|
| 64 |
MASK_THRESHOLD = 10 # minimum pixel intensity for binary mask
|
| 65 |
USE_FORWARD_ENERGY = True # if True, use forward energy algorithm
|
| 66 |
|
| 67 |
-
|
|
|
|
| 68 |
model_path = "./assets/big-lama.pt"
|
| 69 |
-
model = torch.jit.load(model_path, map_location=
|
| 70 |
model = model.to(device)
|
| 71 |
model.eval()
|
| 72 |
|
|
|
|
| 64 |
MASK_THRESHOLD = 10 # minimum pixel intensity for binary mask
|
| 65 |
USE_FORWARD_ENERGY = True # if True, use forward energy algorithm
|
| 66 |
|
| 67 |
+
device_str = os.environ.get("DEVICE", "cuda" if torch.cuda.is_available() else "cpu")
|
| 68 |
+
device = torch.device(device_str)
|
| 69 |
model_path = "./assets/big-lama.pt"
|
| 70 |
+
model = torch.jit.load(model_path, map_location=device)
|
| 71 |
model = model.to(device)
|
| 72 |
model.eval()
|
| 73 |
|