Spaces:
No application file

CreaIA-CONGO / README.md
Dango45's picture
Update README.md
2ebcd04 verified
|
Raw History Blame Contribute Delete
1.64 kB

A newer version of the Gradio SDK is available: 6.33.0

Upgrade
metadata
title: CreaIA CONGO
emoji: 💻
colorFrom: pink
colorTo: pink
sdk: gradio
sdk_version: 6.30.0
python_version: '3.12'
app_file: app.py
pinned: false
license: mit
short_description: Une ville moderne de Kinshasa, avec des gratte-ciel futurist

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference import os import gradio as gr from huggingface_hub import InferenceClient

MODEL = "black-forest-labs/FLUX.1-schnell"

def generer_image(prompt): if not prompt or not prompt.strip(): raise gr.Error("Décris l'image que tu veux créer.")

token = os.environ.get("HF_TOKEN")
if not token:
    raise gr.Error(
        "Le secret HF_TOKEN doit être configuré "
        "dans les paramètres du Space."
    )

try:
    client = InferenceClient(api_key=token)

    image = client.text_to_image(
        prompt.strip(),
        model=MODEL
    )

    return image

except Exception as e:
    raise gr.Error(
        f"Échec de génération : {str(e)[:300]}"
    )

with gr.Blocks(title="CréaIA Congo") as demo: gr.Markdown( "# CréaIA Congo 🇨🇩\n" "### Transforme tes idées en images avec l'IA." )

prompt = gr.Textbox(
    label="Décris ton image",
    placeholder="Une ville futuriste à Kinshasa au coucher du soleil...",
    lines=3
)

bouton = gr.Button("Générer mon image", variant="primary")
image = gr.Image(label="Résultat", type="pil")

bouton.click(
    fn=generer_image,
    inputs=prompt,
    outputs=image
)

demo.launch()