Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -52,25 +52,6 @@ def apply_displacement_map(text_img, clothing_img, strength=20):
|
|
52 |
|
53 |
return text_warped
|
54 |
|
55 |
-
def apply_displacement_map(text_img, clothing_img, strength=20):
|
56 |
-
"""Apply displacement map to blend text onto clothing."""
|
57 |
-
gray = cv2.cvtColor(clothing_img, cv2.COLOR_BGR2GRAY)
|
58 |
-
grad_x = cv2.Sobel(gray, cv2.CV_32F, 1, 0, ksize=5)
|
59 |
-
grad_y = cv2.Sobel(gray, cv2.CV_32F, 0, 1, ksize=5)
|
60 |
-
|
61 |
-
grad_x = cv2.normalize(grad_x, None, 0, 1, cv2.NORM_MINMAX)
|
62 |
-
grad_y = cv2.normalize(grad_y, None, 0, 1, cv2.NORM_MINMAX)
|
63 |
-
|
64 |
-
displacement_map = np.zeros_like(clothing_img, dtype=np.float32)
|
65 |
-
displacement_map[:, :, 0] = grad_x * strength
|
66 |
-
displacement_map[:, :, 1] = grad_y * strength
|
67 |
-
|
68 |
-
text_warped = cv2.remap(text_img,
|
69 |
-
displacement_map[:, :, 0].astype(np.float32),
|
70 |
-
displacement_map[:, :, 1].astype(np.float32),
|
71 |
-
interpolation=cv2.INTER_LINEAR)
|
72 |
-
|
73 |
-
return text_warped
|
74 |
|
75 |
def overlay_text_on_clothing(clothing_image, text_input, style, strength=20, alpha=0.7, photo=None, blend_alpha=0.5):
|
76 |
"""Blend generated text and optional photo onto the clothing image."""
|
|
|
52 |
|
53 |
return text_warped
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
def overlay_text_on_clothing(clothing_image, text_input, style, strength=20, alpha=0.7, photo=None, blend_alpha=0.5):
|
57 |
"""Blend generated text and optional photo onto the clothing image."""
|