|
|
--- |
|
|
license: creativeml-openrail-m |
|
|
datasets: |
|
|
- Nerfgun3/bad_prompt |
|
|
metrics: |
|
|
- bleu |
|
|
library_name: diffusers |
|
|
tags: |
|
|
- art |
|
|
--- |
|
|
from transformers import AutoTokenizer, AutoModel |
|
|
|
|
|
# Cargar el tokenizador y el modelo pre-entrenado |
|
|
tokenizer = AutoTokenizer.from_pretrained("image-tokenizers/dall-e-2") |
|
|
model = AutoModel.from_pretrained("image-generation/dall-e-2") |
|
|
|
|
|
# texto previo y objetos de imagen para alimentar al modelo |
|
|
text = "Crea una imagen de un perro en una bicicleta" |
|
|
image = "https://miweb.com/imagenes/perro-bicicleta.png" |
|
|
|
|
|
#Encodear el texto y la imagen |
|
|
inputs = tokenizer(text, image, return_tensors='pt') |
|
|
|
|
|
#Generar la imagen |
|
|
output = model.generate(**inputs) |
|
|
|
|
|
#Decodificar la imagen generada |
|
|
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True) |
|
|
|
|
|
#Imprimir la imagen |
|
|
print(decoded_output) |