Commit
·
509507f
1
Parent(s):
40bdd20
´´ver3´´
Browse files
app.py
CHANGED
@@ -13,14 +13,18 @@ style_transfer_model = hub.load('https://tfhub.dev/google/magenta/arbitrary-imag
|
|
13 |
def load_image(image):
|
14 |
# Redimensiona a imagem para o tamanho padrão
|
15 |
image = cv2.resize(image, IMAGE_SIZE, interpolation=cv2.INTER_AREA)
|
16 |
-
|
17 |
# Processa a imagem para o modelo
|
18 |
image = image.astype(np.float32)[np.newaxis, ...] / 255.
|
19 |
if image.shape[-1] == 4:
|
20 |
image = image[..., :3]
|
21 |
return image
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
def style_transfer(content_image, style_image, style_density, content_sharpness):
|
26 |
# Processa as imagens
|
@@ -34,7 +38,7 @@ def style_transfer(content_image, style_image, style_density, content_sharpness)
|
|
34 |
# Executa a transferência de estilo
|
35 |
stylized_image = style_transfer_model(tf.constant(content_image_sharp), tf.constant(style_image))[0]
|
36 |
|
37 |
-
|
38 |
# Interpola entre a imagem de conteúdo e a imagem estilizada para densidade de estilo
|
39 |
stylized_image = interpolate_images(
|
40 |
baseline=content_image[0],
|
|
|
13 |
def load_image(image):
|
14 |
# Redimensiona a imagem para o tamanho padrão
|
15 |
image = cv2.resize(image, IMAGE_SIZE, interpolation=cv2.INTER_AREA)
|
|
|
16 |
# Processa a imagem para o modelo
|
17 |
image = image.astype(np.float32)[np.newaxis, ...] / 255.
|
18 |
if image.shape[-1] == 4:
|
19 |
image = image[..., :3]
|
20 |
return image
|
21 |
|
22 |
+
def apply_sharpness(image, intensity):
|
23 |
+
kernel = np.array([[0, -intensity, 0],
|
24 |
+
[-intensity, 1 + 4 * intensity, -intensity],
|
25 |
+
[0, -intensity, 0]])
|
26 |
+
sharp_image = cv2.filter2D(image, -1, kernel)
|
27 |
+
return np.clip(sharp_image, 0, 255)
|
28 |
|
29 |
def style_transfer(content_image, style_image, style_density, content_sharpness):
|
30 |
# Processa as imagens
|
|
|
38 |
# Executa a transferência de estilo
|
39 |
stylized_image = style_transfer_model(tf.constant(content_image_sharp), tf.constant(style_image))[0]
|
40 |
|
41 |
+
|
42 |
# Interpola entre a imagem de conteúdo e a imagem estilizada para densidade de estilo
|
43 |
stylized_image = interpolate_images(
|
44 |
baseline=content_image[0],
|