Equityone commited on
Commit
f183b5a
·
verified ·
1 Parent(s): bf34d04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -108,7 +108,9 @@ COMPOSITION_PARAMS = {
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,7 +134,9 @@ COMPOSITION_PARAMS = {
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,7 +173,9 @@ COMPOSITION_PARAMS = {
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,6 +210,7 @@ def create_interface():
204
  """
205
 
206
  generator = ImageGenerator()
 
207
  with gr.Blocks(css=css) as app:
208
  gr.HTML("""
209
  <div class="welcome">
@@ -251,7 +258,9 @@ def create_interface():
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,7 +317,8 @@ def create_interface():
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,5 +370,4 @@ def create_interface():
360
  if __name__ == "__main__":
361
  app = create_interface()
362
  logger.info("Démarrage de l'application")
363
- app.launch()
364
-
 
108
  "Terre": "earthy color palette, natural tones",
109
  "Néon": "neon color palette, vibrant glowing colors"
110
  }
111
+ }
112
+
113
+ class ImageGenerator:
114
  def __init__(self):
115
  self.API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
116
  token = os.getenv('HUGGINGFACE_TOKEN')
 
134
  "layout": COMPOSITION_PARAMS['Layouts'][params['layout']],
135
  "ambiance": COMPOSITION_PARAMS['Ambiances'][params['ambiance']],
136
  "palette": COMPOSITION_PARAMS['Palette'][params['palette']]
137
+ }
138
+
139
+ # Préparation du prompt initial
140
  base_prompt = f"{params['subject']}"
141
  if params.get('title'):
142
  base_prompt += f", with text '{params['title']}'"
 
173
  "width": 768,
174
  "height": 768 if params["orientation"] == "Portrait" else 512
175
  }
176
+ }
177
+
178
+ logger.debug(f"Payload: {json.dumps(payload, indent=2)}")
179
 
180
  response = requests.post(
181
  self.API_URL,
 
210
  """
211
 
212
  generator = ImageGenerator()
213
+
214
  with gr.Blocks(css=css) as app:
215
  gr.HTML("""
216
  <div class="welcome">
 
258
  choices=list(COMPOSITION_PARAMS["Palette"].keys()),
259
  value="Contrasté",
260
  label="Palette"
261
+ )
262
+
263
+ with gr.Group(elem_classes="controls-group"):
264
  gr.Markdown("### 📝 Contenu")
265
  subject = gr.Textbox(
266
  label="Description",
 
317
 
318
  image_output = gr.Image(label="Aperçu")
319
  status = gr.Textbox(label="Statut", interactive=False)
320
+
321
+ def generate(*args):
322
  logger.info("Démarrage d'une nouvelle génération")
323
  params = {
324
  "format_size": args[0],
 
370
  if __name__ == "__main__":
371
  app = create_interface()
372
  logger.info("Démarrage de l'application")
373
+ app.launch()