Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
import time
|
4 |
+
|
5 |
+
# Styles disponibles
|
6 |
+
STYLES = {
|
7 |
+
"signage": "Signalétique Professionnelle",
|
8 |
+
"poster": "Affiche Artistique",
|
9 |
+
"silhouette": "Silhouette Décorative"
|
10 |
+
}
|
11 |
+
|
12 |
+
# Formats disponibles
|
13 |
+
FORMATS = ["A4", "A3", "A2", "A1"]
|
14 |
+
|
15 |
+
# Matériaux disponibles
|
16 |
+
MATERIALS = ["Lisse", "Ondulé", "Kraft"]
|
17 |
+
|
18 |
+
# Suggestions de prompts par style
|
19 |
+
PROMPT_SUGGESTIONS = {
|
20 |
+
"signage": [
|
21 |
+
"Panneau directionnel moderne en carton recyclé, style minimaliste",
|
22 |
+
"Présentoir écologique pour boutique, motifs naturels",
|
23 |
+
"Signalétique murale en carton kraft, design épuré"
|
24 |
+
],
|
25 |
+
"poster": [
|
26 |
+
"Affiche artistique sur carton texturé, thème environnemental",
|
27 |
+
"Poster graphique moderne, motifs géométriques en relief",
|
28 |
+
"Design abstrait sur carton ondulé, couleurs naturelles"
|
29 |
+
],
|
30 |
+
"silhouette": [
|
31 |
+
"Découpe décorative florale en carton, style organique",
|
32 |
+
"Silhouette architecturale moderne en carton recyclé",
|
33 |
+
"Motif géométrique découpé, effet d'ombre et lumière"
|
34 |
+
]
|
35 |
+
}
|
36 |
+
|
37 |
+
def generate_image(prompt, style, format_size, material):
|
38 |
+
"""
|
39 |
+
Fonction de génération d'image (simulation pour le moment)
|
40 |
+
"""
|
41 |
+
# Simuler le temps de génération
|
42 |
+
time.sleep(2)
|
43 |
+
|
44 |
+
# Pour le moment, retourner un message de confirmation
|
45 |
+
return f"Image générée avec les paramètres :\nPrompt : {prompt}\nStyle : {style}\nFormat : {format_size}\nMatériau : {material}"
|
46 |
+
|
47 |
+
def update_suggestions(style):
|
48 |
+
"""
|
49 |
+
Mise à jour des suggestions de prompts selon le style
|
50 |
+
"""
|
51 |
+
return gr.Dropdown(choices=PROMPT_SUGGESTIONS.get(style, []))
|
52 |
+
|
53 |
+
def get_example_prompt(style):
|
54 |
+
"""
|
55 |
+
Obtenir un prompt exemple du style sélectionné
|
56 |
+
"""
|
57 |
+
suggestions = PROMPT_SUGGESTIONS.get(style, [])
|
58 |
+
return random.choice(suggestions) if suggestions else ""
|
59 |
+
|
60 |
+
with gr.Blocks(css="footer {display: none}") as demo:
|
61 |
+
gr.Markdown(
|
62 |
+
"""
|
63 |
+
# 🎨 Equity Creation Studio
|
64 |
+
### Studio de Design Éco-responsable
|
65 |
+
Transformez vos idées en créations durables avec notre générateur d'images IA
|
66 |
+
"""
|
67 |
+
)
|
68 |
+
|
69 |
+
with gr.Row():
|
70 |
+
# Panneau de gauche - Contrôles
|
71 |
+
with gr.Column(scale=1):
|
72 |
+
# Section Style
|
73 |
+
style = gr.Radio(
|
74 |
+
choices=list(STYLES.keys()),
|
75 |
+
value="signage",
|
76 |
+
label="Style de Création",
|
77 |
+
info="Choisissez le type de design souhaité"
|
78 |
+
)
|
79 |
+
|
80 |
+
# Section Format
|
81 |
+
format_size = gr.Radio(
|
82 |
+
choices=FORMATS,
|
83 |
+
value="A4",
|
84 |
+
label="Format",
|
85 |
+
info="Sélectionnez la taille de votre création"
|
86 |
+
)
|
87 |
+
|
88 |
+
# Section Matériau
|
89 |
+
material = gr.Radio(
|
90 |
+
choices=MATERIALS,
|
91 |
+
value="Lisse",
|
92 |
+
label="Type de Carton",
|
93 |
+
info="Choisissez votre matériau"
|
94 |
+
)
|
95 |
+
|
96 |
+
# Section Prompt
|
97 |
+
prompt = gr.Textbox(
|
98 |
+
lines=3,
|
99 |
+
label="Description",
|
100 |
+
placeholder="Décrivez votre vision..."
|
101 |
+
)
|
102 |
+
|
103 |
+
# Suggestions de prompts
|
104 |
+
suggestions = gr.Dropdown(
|
105 |
+
choices=PROMPT_SUGGESTIONS["signage"],
|
106 |
+
label="Suggestions de prompts",
|
107 |
+
info="Sélectionnez une suggestion ou écrivez votre propre description"
|
108 |
+
)
|
109 |
+
|
110 |
+
# Bouton de génération
|
111 |
+
generate_btn = gr.Button("🪄 Générer", variant="primary")
|
112 |
+
|
113 |
+
# Panneau de droite - Prévisualisation
|
114 |
+
with gr.Column(scale=2):
|
115 |
+
output = gr.Textbox(label="Résultat")
|
116 |
+
|
117 |
+
# Interactions
|
118 |
+
style.change(
|
119 |
+
fn=update_suggestions,
|
120 |
+
inputs=[style],
|
121 |
+
outputs=[suggestions]
|
122 |
+
)
|
123 |
+
|
124 |
+
suggestions.change(
|
125 |
+
fn=lambda x: x,
|
126 |
+
inputs=[suggestions],
|
127 |
+
outputs=[prompt]
|
128 |
+
)
|
129 |
+
|
130 |
+
generate_btn.click(
|
131 |
+
fn=generate_image,
|
132 |
+
inputs=[prompt, style, format_size, material],
|
133 |
+
outputs=[output]
|
134 |
+
)
|
135 |
+
|
136 |
+
gr.Markdown(
|
137 |
+
"""
|
138 |
+
### 🌿 Design Éco-responsable
|
139 |
+
Equity Creation Studio transforme vos déchets carton en œuvres d'art
|
140 |
+
"""
|
141 |
+
)
|
142 |
+
|
143 |
+
# Lancement de l'interface
|
144 |
+
demo.launch()
|