Sebastiankay commited on
Commit
856cb99
1 Parent(s): 76710ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -61,6 +61,15 @@ theme = gr.themes.Soft(
61
  title = "Bilder Builder"
62
 
63
 
 
 
 
 
 
 
 
 
 
64
  # MARK: GET PREV. IMAGES
65
  def get_gallery_images(dirpath):
66
  gallery_images = [dirpath + "/" + s for s in os.listdir(dirpath) if os.path.isfile(os.path.join(dirpath, s))]
@@ -222,8 +231,14 @@ with gr.Blocks(theme=theme, head=custom_head, css=custom_css, js=custom_js, titl
222
  with gr.Row(elem_classes="image_size_selctor_wrapper"):
223
  with gr.Column(scale=1):
224
  with gr.Row():
225
- inference_models = ["FLUX-API-OLD", "FLUX", "FLUX-Realism", "FLUX-Pixel", "FLUX-Anime", "FLUX-3D", "FLUX-Disney", "ANY-DARK", "Stable-Diffusion-XL-Base", "Stable-Diffusion-XL-Lightning"]
226
- select_model = gr.Dropdown(choices=inference_models, value="FLUX", label="Model", elem_id="select_model", elem_classes="select-model")
 
 
 
 
 
 
227
  # with gr.Row():
228
  image_width = gr.Number(label="Breite", minimum=256, maximum=MAX_IMAGE_SIZE, value=576, step=32, elem_id="image_width_selector", elem_classes="image-width-selector", scale=1, visible=False)
229
  image_height = gr.Number(label="Höhe", minimum=256, maximum=MAX_IMAGE_SIZE, value=1024, step=32, elem_id="image_height_selector", elem_classes="image-height-selector", scale=1, visible=False)
 
61
  title = "Bilder Builder"
62
 
63
 
64
+ def check_api(url):
65
+ try:
66
+ response = requests.get(url, timeout=2)
67
+ return response.status_code
68
+ except requests.exceptions.RequestException as e:
69
+ print(f"An error occurred: {e}")
70
+ return None
71
+
72
+
73
  # MARK: GET PREV. IMAGES
74
  def get_gallery_images(dirpath):
75
  gallery_images = [dirpath + "/" + s for s in os.listdir(dirpath) if os.path.isfile(os.path.join(dirpath, s))]
 
231
  with gr.Row(elem_classes="image_size_selctor_wrapper"):
232
  with gr.Column(scale=1):
233
  with gr.Row():
234
+ inference_models = ["FLUX-API-OLD"]
235
+ selected_model = "FLUX-API-OLD"
236
+ models_new_api = ["FLUX", "FLUX-Realism", "FLUX-Pixel", "FLUX-Anime", "FLUX-3D", "FLUX-Disney", "ANY-DARK", "Stable-Diffusion-XL-Base", "Stable-Diffusion-XL-Lightning"]
237
+ if check_api(API_V1) == 200:
238
+ selected_model = "FLUX"
239
+ for model in models_new_api:
240
+ inference_models.append(model)
241
+ select_model = gr.Dropdown(choices=inference_models, value=selected_model", label="Model", elem_id="select_model", elem_classes="select-model")
242
  # with gr.Row():
243
  image_width = gr.Number(label="Breite", minimum=256, maximum=MAX_IMAGE_SIZE, value=576, step=32, elem_id="image_width_selector", elem_classes="image-width-selector", scale=1, visible=False)
244
  image_height = gr.Number(label="Höhe", minimum=256, maximum=MAX_IMAGE_SIZE, value=1024, step=32, elem_id="image_height_selector", elem_classes="image-height-selector", scale=1, visible=False)