andresampa commited on
Commit
7cfcb45
·
verified ·
1 Parent(s): 40c2c05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -6,11 +6,11 @@ import gradio as gr
6
  from datetime import datetime
7
 
8
  # Retrieve the Hugging Face token from environment variables
9
- api_token = os.getenv("HF_CTB_TOKEN")
10
 
11
  # Debugging: Check if the Hugging Face token is available
12
  if not api_token:
13
- print("ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable.")
14
  else:
15
  print("Hugging Face token loaded successfully.")
16
 
@@ -65,11 +65,15 @@ prompts = [
65
  }
66
  ]
67
 
 
 
 
 
68
  # Function to generate images
69
  def generate_image(prompt_alias, team, model_alias, height, width, num_inference_steps, guidance_scale, seed):
70
  # Debugging: Check if the token is available
71
  if not api_token:
72
- return None, "ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable."
73
 
74
  # Find the selected prompt and model
75
  try:
@@ -124,9 +128,10 @@ def generate_image(prompt_alias, team, model_alias, height, width, num_inference
124
  with gr.Blocks() as demo:
125
  gr.Markdown("# CtB AI Image Generator")
126
  with gr.Row():
127
- prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Prompt")
128
- team_dropdown = gr.Dropdown(choices=["Red", "Blue"], label="Select Team")
129
- model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model")
 
130
  with gr.Row():
131
  height_input = gr.Number(value=360, label="Height")
132
  width_input = gr.Number(value=640, label="Width")
 
6
  from datetime import datetime
7
 
8
  # Retrieve the Hugging Face token from environment variables
9
+ api_token = os.getenv("HF_TOKEN")
10
 
11
  # Debugging: Check if the Hugging Face token is available
12
  if not api_token:
13
+ print("ERROR: Hugging Face token (HF_TOKEN) is missing. Please set it as an environment variable.")
14
  else:
15
  print("Hugging Face token loaded successfully.")
16
 
 
65
  }
66
  ]
67
 
68
+ # Debugging: Print prompt and model options
69
+ print("Prompt Options:", [p["alias"] for p in prompts])
70
+ print("Model Options:", [m["alias"] for m in models])
71
+
72
  # Function to generate images
73
  def generate_image(prompt_alias, team, model_alias, height, width, num_inference_steps, guidance_scale, seed):
74
  # Debugging: Check if the token is available
75
  if not api_token:
76
+ return None, "ERROR: Hugging Face token (HF_TOKEN) is missing. Please set it as an environment variable."
77
 
78
  # Find the selected prompt and model
79
  try:
 
128
  with gr.Blocks() as demo:
129
  gr.Markdown("# CtB AI Image Generator")
130
  with gr.Row():
131
+ # Set default values for dropdowns
132
+ prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Prompt", value=prompts[0]["alias"])
133
+ team_dropdown = gr.Dropdown(choices=["Red", "Blue"], label="Select Team", value="Red")
134
+ model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
135
  with gr.Row():
136
  height_input = gr.Number(value=360, label="Height")
137
  width_input = gr.Number(value=640, label="Width")