A close up of a cell phone with multiple colors of stars
![import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
# Función para cargar y preprocesar la imagen de entrada
def load_image(image_path):
img = tf.io.read_file(image_path)
img = tf.image.decode_image(img, channels=3)
img = tf.image.convert_image_dtype(img, tf.float32)
img = tf.image.resize(img, (256, 256)) # Ajustar al tamaño adecuado para el modelo
img = img[tf.newaxis, :] # Añadir dimensión del lote
return img
# Función para preprocesar la imagen generada por el modelo
def preprocess_image(image):
image = image.numpy().squeeze()
image = np.clip(image, 0, 1)
return image
# Función para visualizar la imagen generada
def visualize_image(image):
plt.figure(figsize=(8, 8))
plt.imshow(image)
plt.axis('off')
plt.show()
# Cargar el modelo de estilo (puedes elegir un modelo que imite el estilo de Van Gogh)
hub_module = hub.load('https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2')
# Cargar la imagen de la noche estrellada de Van Gogh
input_image = load_image('night_starry.jpg') # Reemplaza con la ruta de la imagen de la noche estrellada
# Generar la imagen en el estilo abstracto
stylized_image = hub_module(tf.constant(input_image), tf.constant(input_image))[0]
# Preprocesar y visualizar la imagen generada
stylized_image = preprocess_image(stylized_image)
visualize_image(stylized_image)](https://image.cdn2.seaart.me/2024-07-03/cq2bh3le878c73aipbo0/2527744854e505b00ca48da2dc74fa932c08d341_high.webp)
Prompts
Copier les Paramètres
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import matplotlib
.
pyplot as plt
from PIL import Image
# Función para cargar y preprocesar la imagen de entrada
def load_image(image_path):
img = tf
.
io
.
read_file(image_path)
img = tf
.
image
.
decode_image(img
,
channels=3)
img = tf
.
image
.
convert_image_dtype(img
,
tf
.
float32)
img = tf
.
image
.
resize(img
,
(256
,
256)) # Ajustar al tamaño adecuado para el modelo
img = img[tf
.
newaxis
,
:] # Añadir dimensión del lote
return img
# Función para preprocesar la imagen generada por el modelo
def preprocess_image(image):
image = image
.
numpy()
.
squeeze()
image = np
.
clip(image
,
0
,
1)
return image
# Función para visualizar la imagen generada
def visualize_image(image):
plt
.
figure(figsize=(8
,
8))
plt
.
imshow(image)
plt
.
axis('off')
plt
.
show()
# Cargar el modelo de estilo (puedes elegir un modelo que imite el estilo de Van Gogh)
hub_module = hub
.
load('https://tfhub
.
dev/google/magenta/arbitrary-image-stylization-v1-256/2')
# Cargar la imagen de la noche estrellada de Van Gogh
input_image = load_image('night_starry
.
jpg') # Reemplaza con la ruta de la imagen de la noche estrellada
# Generar la imagen en el estilo abstracto
stylized_image = hub_module(tf
.
constant(input_image)
,
tf
.
constant(input_image))[0]
# Preprocesar y visualizar la imagen generada
stylized_image = preprocess_image(stylized_image)
visualize_image(stylized_image)
Info
Checkpoint & LoRA

Checkpoint
CyberRealistic
#Paysage
#Conception d'Article
0 commentaire(s)
0
0
0