File size: 815 Bytes
179c606
ece1c0c
 
 
 
 
 
 
 
179c606
ece1c0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
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)