Update app.py
Browse files
app.py
CHANGED
@@ -43,8 +43,6 @@ ART_STYLES = {
|
|
43 |
"prompt_prefix": "surrealist art, dreamlike imagery, symbolic elements, dali inspired, metaphysical art",
|
44 |
"negative_prompt": "realistic, conventional, ordinary, literal"
|
45 |
},
|
46 |
-
|
47 |
-
# Styles Modernes
|
48 |
"Art Moderne": {
|
49 |
"prompt_prefix": "modern art style poster, professional design, contemporary aesthetic",
|
50 |
"negative_prompt": "traditional, cluttered, busy design, vintage"
|
@@ -65,8 +63,6 @@ ART_STYLES = {
|
|
65 |
"prompt_prefix": "futuristic art style, dynamic movement, technological elements, speed and motion",
|
66 |
"negative_prompt": "static, traditional, classical, historical"
|
67 |
},
|
68 |
-
|
69 |
-
# Styles Spéciaux
|
70 |
"Neo Vintage": {
|
71 |
"prompt_prefix": "vintage style advertising poster, retro design, classic aesthetic",
|
72 |
"negative_prompt": "modern, digital, contemporary style"
|
@@ -112,7 +108,7 @@ COMPOSITION_PARAMS = {
|
|
112 |
"Terre": "earthy color palette, natural tones",
|
113 |
"Néon": "neon color palette, vibrant glowing colors"
|
114 |
}
|
115 |
-
}class ImageGenerator:
|
116 |
def __init__(self):
|
117 |
self.API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
118 |
token = os.getenv('HUGGINGFACE_TOKEN')
|
@@ -136,9 +132,7 @@ COMPOSITION_PARAMS = {
|
|
136 |
"layout": COMPOSITION_PARAMS['Layouts'][params['layout']],
|
137 |
"ambiance": COMPOSITION_PARAMS['Ambiances'][params['ambiance']],
|
138 |
"palette": COMPOSITION_PARAMS['Palette'][params['palette']]
|
139 |
-
}
|
140 |
-
|
141 |
-
# Préparation du prompt initial
|
142 |
base_prompt = f"{params['subject']}"
|
143 |
if params.get('title'):
|
144 |
base_prompt += f", with text '{params['title']}'"
|
@@ -175,9 +169,7 @@ COMPOSITION_PARAMS = {
|
|
175 |
"width": 768,
|
176 |
"height": 768 if params["orientation"] == "Portrait" else 512
|
177 |
}
|
178 |
-
}
|
179 |
-
|
180 |
-
logger.debug(f"Payload: {json.dumps(payload, indent=2)}")
|
181 |
|
182 |
response = requests.post(
|
183 |
self.API_URL,
|
@@ -212,7 +204,6 @@ def create_interface():
|
|
212 |
"""
|
213 |
|
214 |
generator = ImageGenerator()
|
215 |
-
|
216 |
with gr.Blocks(css=css) as app:
|
217 |
gr.HTML("""
|
218 |
<div class="welcome">
|
@@ -260,9 +251,7 @@ def create_interface():
|
|
260 |
choices=list(COMPOSITION_PARAMS["Palette"].keys()),
|
261 |
value="Contrasté",
|
262 |
label="Palette"
|
263 |
-
)
|
264 |
-
|
265 |
-
with gr.Group(elem_classes="controls-group"):
|
266 |
gr.Markdown("### 📝 Contenu")
|
267 |
subject = gr.Textbox(
|
268 |
label="Description",
|
@@ -319,8 +308,7 @@ def create_interface():
|
|
319 |
|
320 |
image_output = gr.Image(label="Aperçu")
|
321 |
status = gr.Textbox(label="Statut", interactive=False)
|
322 |
-
|
323 |
-
def generate(*args):
|
324 |
logger.info("Démarrage d'une nouvelle génération")
|
325 |
params = {
|
326 |
"format_size": args[0],
|
@@ -372,4 +360,5 @@ def create_interface():
|
|
372 |
if __name__ == "__main__":
|
373 |
app = create_interface()
|
374 |
logger.info("Démarrage de l'application")
|
375 |
-
app.launch()
|
|
|
|
43 |
"prompt_prefix": "surrealist art, dreamlike imagery, symbolic elements, dali inspired, metaphysical art",
|
44 |
"negative_prompt": "realistic, conventional, ordinary, literal"
|
45 |
},
|
|
|
|
|
46 |
"Art Moderne": {
|
47 |
"prompt_prefix": "modern art style poster, professional design, contemporary aesthetic",
|
48 |
"negative_prompt": "traditional, cluttered, busy design, vintage"
|
|
|
63 |
"prompt_prefix": "futuristic art style, dynamic movement, technological elements, speed and motion",
|
64 |
"negative_prompt": "static, traditional, classical, historical"
|
65 |
},
|
|
|
|
|
66 |
"Neo Vintage": {
|
67 |
"prompt_prefix": "vintage style advertising poster, retro design, classic aesthetic",
|
68 |
"negative_prompt": "modern, digital, contemporary style"
|
|
|
108 |
"Terre": "earthy color palette, natural tones",
|
109 |
"Néon": "neon color palette, vibrant glowing colors"
|
110 |
}
|
111 |
+
}class ImageGenerator:
|
112 |
def __init__(self):
|
113 |
self.API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
114 |
token = os.getenv('HUGGINGFACE_TOKEN')
|
|
|
132 |
"layout": COMPOSITION_PARAMS['Layouts'][params['layout']],
|
133 |
"ambiance": COMPOSITION_PARAMS['Ambiances'][params['ambiance']],
|
134 |
"palette": COMPOSITION_PARAMS['Palette'][params['palette']]
|
135 |
+
}# Préparation du prompt initial
|
|
|
|
|
136 |
base_prompt = f"{params['subject']}"
|
137 |
if params.get('title'):
|
138 |
base_prompt += f", with text '{params['title']}'"
|
|
|
169 |
"width": 768,
|
170 |
"height": 768 if params["orientation"] == "Portrait" else 512
|
171 |
}
|
172 |
+
}logger.debug(f"Payload: {json.dumps(payload, indent=2)}")
|
|
|
|
|
173 |
|
174 |
response = requests.post(
|
175 |
self.API_URL,
|
|
|
204 |
"""
|
205 |
|
206 |
generator = ImageGenerator()
|
|
|
207 |
with gr.Blocks(css=css) as app:
|
208 |
gr.HTML("""
|
209 |
<div class="welcome">
|
|
|
251 |
choices=list(COMPOSITION_PARAMS["Palette"].keys()),
|
252 |
value="Contrasté",
|
253 |
label="Palette"
|
254 |
+
)with gr.Group(elem_classes="controls-group"):
|
|
|
|
|
255 |
gr.Markdown("### 📝 Contenu")
|
256 |
subject = gr.Textbox(
|
257 |
label="Description",
|
|
|
308 |
|
309 |
image_output = gr.Image(label="Aperçu")
|
310 |
status = gr.Textbox(label="Statut", interactive=False)
|
311 |
+
def generate(*args):
|
|
|
312 |
logger.info("Démarrage d'une nouvelle génération")
|
313 |
params = {
|
314 |
"format_size": args[0],
|
|
|
360 |
if __name__ == "__main__":
|
361 |
app = create_interface()
|
362 |
logger.info("Démarrage de l'application")
|
363 |
+
app.launch()
|
364 |
+
|