Spaces:
Sleeping
Sleeping
File size: 1,954 Bytes
634a903 1fe8eb4 39c0dd2 1fe8eb4 66e7106 1fe8eb4 66e7106 3e1061a 66e7106 a65b3e1 66e7106 3e1061a 66e7106 |
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 32 33 34 35 36 37 38 39 |
import gradio as gr
import requests
import io
from PIL import Image
API_URL = "https://api-inference.huggingface.co/models/ZB-Tech/Text-to-Image"
headers = {"Authorization": "Bearer HF_API_KEY"}
def generate_image(prompt):
payload = {"inputs": prompt}
response = requests.post(API_URL, headers=headers, json=payload)
image_bytes = response.content
image = Image.open(io.BytesIO(image_bytes))
return image
iface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(lines=5, label="Descripción de la imagen", placeholder="Introduce el texto aquí..."),
outputs=gr.Image(type="pil", label="Imagen generada"),
title="Generador de Imágenes a partir de Texto",
description="Ingrese un texto y obtenga una imagen generada por IA.",
examples=[
["A picturesque view of a local market. The first light of day illuminates the stone facades and worn tiles of the houses and buildings, some of which date back centuries. At the center of the scene, a cobblestone square leads to an open-air market that begins to come to life, with vendors setting up their stalls selling fruits, vegetables, flowers, and local crafts. The narrow, winding streets are lined with old lanterns, now unlit, while lazy cats lounge on the stone steps. In one corner, an ancient fountain, adorned with weathered carvings, murmurs softly, adding to the tranquil atmosphere. In the background, the towers of an ancient cathedral rise, capturing the first rays of sunlight that paint the sky in soft pinks and oranges. This image should convey a sense of tranquility, beauty, and a deep connection to the past, celebrating the rich history and timeless charm of the ancient village or town."]
],
live=True,
css="""
.gradio-container {
background-color: #f9f9f9;
color: #333;
font-family: Arial, sans-serif;
}
.gradio-container h1 {
color: #4CAF50;
}
"""
)
iface.launch()
|