Update README.md
#2
by
BAKULODid
- opened
README.md
CHANGED
|
@@ -1,4 +1,21 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModel
|
| 2 |
+
|
| 3 |
+
# Cargar el tokenizador y el modelo pre-entrenado
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("image-tokenizers/dall-e-2")
|
| 5 |
+
model = AutoModel.from_pretrained("image-generation/dall-e-2")
|
| 6 |
+
|
| 7 |
+
# texto previo y objetos de imagen para alimentar al modelo
|
| 8 |
+
text = "Crea una imagen de un perro en una bicicleta"
|
| 9 |
+
image = "https://miweb.com/imagenes/perro-bicicleta.png"
|
| 10 |
+
|
| 11 |
+
#Encodear el texto y la imagen
|
| 12 |
+
inputs = tokenizer(text, image, return_tensors='pt')
|
| 13 |
+
|
| 14 |
+
#Generar la imagen
|
| 15 |
+
output = model.generate(**inputs)
|
| 16 |
+
|
| 17 |
+
#Decodificar la imagen generada
|
| 18 |
+
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 19 |
+
|
| 20 |
+
#Imprimir la imagen
|
| 21 |
+
print(decoded_output)
|