Spaces:
Runtime error
Runtime error
Commit
Β·
4c8dced
1
Parent(s):
4dbb263
update
Browse files
app.py
CHANGED
|
@@ -25,6 +25,8 @@ from preprocess.openpose.run_openpose import OpenPose
|
|
| 25 |
from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_orientation
|
| 26 |
from torchvision.transforms.functional import to_pil_image
|
| 27 |
|
|
|
|
|
|
|
| 28 |
|
| 29 |
def pil_to_binary_mask(pil_image, threshold=0):
|
| 30 |
np_image = np.array(pil_image)
|
|
@@ -123,7 +125,8 @@ pipe.unet_encoder = UNet_Encoder
|
|
| 123 |
|
| 124 |
@spaces.GPU
|
| 125 |
def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_steps,seed):
|
| 126 |
-
device = "cuda"
|
|
|
|
| 127 |
|
| 128 |
openpose_model.preprocessor.body_estimation.model.to(device)
|
| 129 |
pipe.to(device)
|
|
@@ -165,7 +168,8 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
-
args = apply_net.create_argument_parser().parse_args(('show', './configs/densepose_rcnn_R_50_FPN_s1x.yaml', './ckpt/densepose/model_final_162be9.pkl', 'dp_segm', '-v', '--opts', 'MODEL.DEVICE', 'cuda'))
|
|
|
|
| 169 |
# verbosity = getattr(args, "verbosity", None)
|
| 170 |
pose_img = args.func(args,human_img_arg)
|
| 171 |
pose_img = pose_img[:,:,::-1]
|
|
@@ -173,7 +177,8 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
| 173 |
|
| 174 |
with torch.no_grad():
|
| 175 |
# Extract the images
|
| 176 |
-
with torch.
|
|
|
|
| 177 |
with torch.no_grad():
|
| 178 |
prompt = "model is wearing " + garment_des
|
| 179 |
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
|
|
|
|
| 25 |
from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_orientation
|
| 26 |
from torchvision.transforms.functional import to_pil_image
|
| 27 |
|
| 28 |
+
import devicetorch
|
| 29 |
+
|
| 30 |
|
| 31 |
def pil_to_binary_mask(pil_image, threshold=0):
|
| 32 |
np_image = np.array(pil_image)
|
|
|
|
| 125 |
|
| 126 |
@spaces.GPU
|
| 127 |
def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_steps,seed):
|
| 128 |
+
#device = "cuda"
|
| 129 |
+
device = devicetorch.get(torch)
|
| 130 |
|
| 131 |
openpose_model.preprocessor.body_estimation.model.to(device)
|
| 132 |
pipe.to(device)
|
|
|
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
+
#args = apply_net.create_argument_parser().parse_args(('show', './configs/densepose_rcnn_R_50_FPN_s1x.yaml', './ckpt/densepose/model_final_162be9.pkl', 'dp_segm', '-v', '--opts', 'MODEL.DEVICE', 'cuda'))
|
| 172 |
+
args = apply_net.create_argument_parser().parse_args(('show', './configs/densepose_rcnn_R_50_FPN_s1x.yaml', './ckpt/densepose/model_final_162be9.pkl', 'dp_segm', '-v', '--opts', 'MODEL.DEVICE', device))
|
| 173 |
# verbosity = getattr(args, "verbosity", None)
|
| 174 |
pose_img = args.func(args,human_img_arg)
|
| 175 |
pose_img = pose_img[:,:,::-1]
|
|
|
|
| 177 |
|
| 178 |
with torch.no_grad():
|
| 179 |
# Extract the images
|
| 180 |
+
with torch.autocast(device_type=device):
|
| 181 |
+
#with torch.cuda.amp.autocast():
|
| 182 |
with torch.no_grad():
|
| 183 |
prompt = "model is wearing " + garment_des
|
| 184 |
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality"
|