Spaces:
No application file
No application file
Update README.md
Browse files12 unmodified lines13141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686912 unmodified lines---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-referenceimport osimport gradio as grfrom 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()README.md+54