Andre commited on
Commit
1b4b7ae
·
1 Parent(s): f2cb5dd
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: purple
5
  colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.0.1
8
- app_file: app2.py
9
  pinned: false
10
  ---
11
 
 
5
  colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.0.1
8
+ app_file: app.py
9
  pinned: false
10
  ---
11
 
app.py CHANGED
@@ -1,172 +1,10 @@
1
- import os
2
- import random
3
- from huggingface_hub import InferenceClient
4
- from PIL import Image
5
- 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
-
17
- # List of models with aliases
18
- models = [
19
- {"alias": "FLUX.1-dev", "name": "black-forest-labs/FLUX.1-dev"},
20
- {"alias": "Midjourney", "name": "strangerzonehf/Flux-Midjourney-Mix2-LoRA"}
21
- ]
22
-
23
- # List of prompts with intense combat
24
- prompts = [
25
- {
26
- "alias": "Castle Siege",
27
- "text": "A medieval castle under siege, with archers firing arrows from the walls, knights charging on horses, and catapults launching fireballs. The enemy army, dressed in {enemy_color} armor, is fiercely attacking the castle, with soldiers scaling ladders and clashing swords with the defenders. Arrows fly through the air, explosions light up the battlefield, and injured knights lie on the ground. Fire engulfs parts of the castle, and the air is thick with smoke and chaos. Unreal Engine render style, photorealistic, realistic fantasy style."
28
- },
29
- {
30
- "alias": "Forest Battle",
31
- "text": "A fierce battle between two armies in a dense forest, with knights wielding swords and axes, horses rearing, and the ground covered in mud and blood. The enemy army, dressed in {enemy_color} armor, is locked in brutal combat, with soldiers fighting hand-to-hand amidst the trees. Arrows whiz past, and the sounds of clashing steel echo through the forest. Injured soldiers scream in pain, and the forest is littered with broken weapons and shields. Unreal Engine render style, photorealistic, realistic fantasy style."
32
- },
33
- {
34
- "alias": "Boiling Oil Defense",
35
- "text": "A dramatic moment in a medieval siege, with a knight leading a charge against a castle gate, while defenders pour boiling oil from the walls. The enemy army, dressed in {enemy_color} armor, is relentlessly attacking, with soldiers screaming as they are hit by the oil. Knights clash swords at the gate, and arrows rain down from above. The ground is littered with the bodies of fallen soldiers, and the air is filled with the smell of burning flesh. Unreal Engine render style, photorealistic, realistic fantasy style."
36
- },
37
- {
38
- "alias": "Burning Castle Battle",
39
- "text": "A chaotic battlefield with knights on horseback clashing with infantry, archers firing volleys of arrows, and a castle burning in the background. The enemy army, dressed in {enemy_color} armor, is fighting fiercely, with soldiers engaging in brutal melee combat. Flames light up the scene as knights charge through the chaos. Injured soldiers crawl on the ground, and the air is filled with the sounds of clashing steel and screams of pain. Unreal Engine render style, photorealistic, realistic fantasy style."
40
- },
41
- {
42
- "alias": "Heroic Last Stand",
43
- "text": "A heroic last stand of a small group of knights defending a bridge against a massive army, with arrows flying and swords clashing. The enemy army, dressed in {enemy_color} armor, is overwhelming the defenders, but the knights fight bravely, cutting down enemy soldiers as they advance. The bridge is littered with bodies and broken weapons. Blood stains the ground, and the air is thick with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
44
- },
45
- {
46
- "alias": "Siege Tower Attack",
47
- "text": "A medieval siege tower approaching a castle wall, with knights scaling ladders and defenders throwing rocks and shooting arrows. The enemy army, dressed in {enemy_color} armor, is fighting desperately to breach the walls, with soldiers clashing swords on the battlements. Arrows fly in all directions, and the siege tower is engulfed in flames. Injured soldiers fall from the ladders, and the ground is littered with the bodies of the fallen. Unreal Engine render style, photorealistic, realistic fantasy style."
48
- },
49
- {
50
- "alias": "Knight Duel",
51
- "text": "A dramatic duel between two knights in the middle of a battlefield, with their armies watching and the castle in the background. The enemy army, dressed in {enemy_color} armor, is engaged in fierce combat all around, with soldiers clashing swords and firing arrows. The duelists fight with skill and determination, their blades flashing in the sunlight. Injured soldiers lie on the ground, and the air is filled with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
52
- },
53
- {
54
- "alias": "Night Battle",
55
- "text": "A night battle during a medieval siege, with torches lighting the scene, knights fighting in the shadows, and the castle walls looming in the background. The enemy army, dressed in {enemy_color} armor, is locked in brutal combat, with soldiers clashing swords and firing arrows in the dim light. Flames from burning siege equipment illuminate the chaos. Injured soldiers scream in pain, and the ground is littered with the bodies of the fallen. Unreal Engine render style, photorealistic, realistic fantasy style."
56
- },
57
- {
58
- "alias": "Marching Army",
59
- "text": "A massive army of knights and infantry marching towards a distant castle, with banners flying and the sun setting behind them. The enemy army, dressed in {enemy_color} armor, is engaging in skirmishes along the way, with soldiers clashing swords and firing arrows. The battlefield is alive with the sounds of combat and the clash of steel. Injured soldiers lie on the ground, and the air is thick with the smell of blood and smoke. Unreal Engine render style, photorealistic, realistic fantasy style."
60
- },
61
- {
62
- "alias": "Snowy Battlefield",
63
- "text": "A medieval battle in a snowy landscape, with knights in heavy armor fighting on a frozen lake, and the castle visible in the distance. The enemy army, dressed in {enemy_color} armor, is locked in fierce combat, with soldiers slipping on the ice as they clash swords. Arrows fly through the air, and the snow is stained red with blood. Injured soldiers crawl on the ground, and the air is filled with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
64
- }
65
- ]
66
-
67
- # Debugging: Print prompt and model options
68
- print("Prompt Options:", [p["alias"] for p in prompts])
69
- print("Model Options:", [m["alias"] for m in models])
70
-
71
- # Function to generate images
72
- def generate_image(prompt_alias, team, model_alias, custom_prompt, height, width, num_inference_steps, guidance_scale, seed):
73
- # Debugging: Check if the token is available
74
- if not api_token:
75
- return None, "ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable."
76
-
77
- # Find the selected prompt and model
78
- try:
79
- prompt = next(p for p in prompts if p["alias"] == prompt_alias)["text"]
80
- model_name = next(m for m in models if m["alias"] == model_alias)["name"]
81
- except StopIteration:
82
- return None, "ERROR: Invalid prompt or model selected."
83
-
84
- # Determine the enemy color
85
- enemy_color = "blue" if team.lower() == "red" else "red"
86
- prompt = prompt.format(enemy_color=enemy_color)
87
-
88
- if team.lower() == "red":
89
- prompt += " The winning army is dressed in red armor and banners."
90
- elif team.lower() == "blue":
91
- prompt += " The winning army is dressed in blue armor and banners."
92
-
93
- # Append the custom prompt (if provided)
94
- if custom_prompt and len(custom_prompt.strip()) > 0:
95
- prompt += " " + custom_prompt.strip()
96
-
97
- # Randomize the seed if needed
98
- if seed == -1:
99
- seed = random.randint(0, 1000000)
100
-
101
- # Initialize the InferenceClient
102
- try:
103
- client = InferenceClient(model_name, token=api_token)
104
- except Exception as e:
105
- return None, f"ERROR: Failed to initialize InferenceClient. Details: {e}"
106
-
107
- # Generate the image
108
- try:
109
- image = client.text_to_image(
110
- prompt,
111
- guidance_scale=guidance_scale,
112
- num_inference_steps=num_inference_steps,
113
- width=width,
114
- height=height,
115
- seed=seed
116
- )
117
- except Exception as e:
118
- return None, f"ERROR: Failed to generate image. Details: {e}"
119
-
120
- # Save the image with a timestamped filename
121
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
122
- output_filename = f"{timestamp}_{model_alias.replace(' ', '_').lower()}_{prompt_alias.replace(' ', '_').lower()}_{team.lower()}.png"
123
- try:
124
- image.save(output_filename)
125
- except Exception as e:
126
- return None, f"ERROR: Failed to save image. Details: {e}"
127
-
128
- return output_filename, "Image generated successfully!"
129
-
130
- # Gradio Interface
131
- with gr.Blocks() as demo:
132
- gr.Markdown("# CtB AI Image Generator")
133
- with gr.Row():
134
- # Set default values for dropdowns
135
- prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Prompt", value=prompts[0]["alias"])
136
- team_dropdown = gr.Dropdown(choices=["Red", "Blue"], label="Select Team", value="Red")
137
- model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
138
- with gr.Row():
139
- # Add a text box for custom user input (max 200 characters)
140
- custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
141
- #with gr.Row():
142
- # Commented-out dialog boxes (can be re-enabled later)
143
- # height_input = gr.Number(value=360, label="Height")
144
- # width_input = gr.Number(value=640, label="Width")
145
- # num_inference_steps_input = gr.Slider(minimum=10, maximum=100, value=20, label="Inference Steps")
146
- # guidance_scale_input = gr.Slider(minimum=1.0, maximum=20.0, value=2.0, step=0.5, label="Guidance Scale")
147
- # seed_input = gr.Number(value=-1, label="Seed (-1 for random)")
148
- with gr.Row():
149
- generate_button = gr.Button("Generate Image")
150
- with gr.Row():
151
- output_image = gr.Image(label="Generated Image")
152
- with gr.Row():
153
- status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
154
-
155
- # Function to handle button click
156
- def generate(prompt_alias, team, model_alias, custom_prompt, height=360, width=640, num_inference_steps=20, guidance_scale=2.0, seed=-1):
157
- try:
158
- # Generate the image
159
- image_path, message = generate_image(prompt_alias, team, model_alias, custom_prompt, height, width, num_inference_steps, guidance_scale, seed)
160
- return image_path, message
161
- except Exception as e:
162
- return None, f"An error occurred: {e}"
163
-
164
- # Connect the button to the function
165
- generate_button.click(
166
- generate,
167
- inputs=[prompt_dropdown, team_dropdown, model_dropdown, custom_prompt_input], # Added custom_prompt_input
168
- outputs=[output_image, status_text]
169
- )
170
-
171
- # Launch the Gradio app
172
- demo.launch()
 
1
+ # app2.py
2
+ from gradio_interface import demo # Direct import
 
 
 
 
3
 
4
+ if __name__ == "__main__":
5
+ # Launch the Gradio app
6
+ demo.launch()
7
 
8
+ if __name__ == "__main__":
9
+ # Launch the Gradio app
10
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app2.py DELETED
@@ -1,10 +0,0 @@
1
- # app2.py
2
- from gradio_interface import demo # Direct import
3
-
4
- if __name__ == "__main__":
5
- # Launch the Gradio app
6
- demo.launch()
7
-
8
- if __name__ == "__main__":
9
- # Launch the Gradio app
10
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
colab/.DS_Store CHANGED
Binary files a/colab/.DS_Store and b/colab/.DS_Store differ
 
colab/old/.DS_Store ADDED
Binary file (6.15 kB). View file
 
colab/old/CtB-AI-img-gen-1.0 copy 2.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
old/app copy3.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ from huggingface_hub import InferenceClient
4
+ from PIL import Image
5
+ 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
+
17
+ # List of models with aliases
18
+ models = [
19
+ {"alias": "FLUX.1-dev", "name": "black-forest-labs/FLUX.1-dev"},
20
+ {"alias": "Midjourney", "name": "strangerzonehf/Flux-Midjourney-Mix2-LoRA"}
21
+ ]
22
+
23
+ # List of prompts with intense combat
24
+ prompts = [
25
+ {
26
+ "alias": "Castle Siege",
27
+ "text": "A medieval castle under siege, with archers firing arrows from the walls, knights charging on horses, and catapults launching fireballs. The enemy army, dressed in {enemy_color} armor, is fiercely attacking the castle, with soldiers scaling ladders and clashing swords with the defenders. Arrows fly through the air, explosions light up the battlefield, and injured knights lie on the ground. Fire engulfs parts of the castle, and the air is thick with smoke and chaos. Unreal Engine render style, photorealistic, realistic fantasy style."
28
+ },
29
+ {
30
+ "alias": "Forest Battle",
31
+ "text": "A fierce battle between two armies in a dense forest, with knights wielding swords and axes, horses rearing, and the ground covered in mud and blood. The enemy army, dressed in {enemy_color} armor, is locked in brutal combat, with soldiers fighting hand-to-hand amidst the trees. Arrows whiz past, and the sounds of clashing steel echo through the forest. Injured soldiers scream in pain, and the forest is littered with broken weapons and shields. Unreal Engine render style, photorealistic, realistic fantasy style."
32
+ },
33
+ {
34
+ "alias": "Boiling Oil Defense",
35
+ "text": "A dramatic moment in a medieval siege, with a knight leading a charge against a castle gate, while defenders pour boiling oil from the walls. The enemy army, dressed in {enemy_color} armor, is relentlessly attacking, with soldiers screaming as they are hit by the oil. Knights clash swords at the gate, and arrows rain down from above. The ground is littered with the bodies of fallen soldiers, and the air is filled with the smell of burning flesh. Unreal Engine render style, photorealistic, realistic fantasy style."
36
+ },
37
+ {
38
+ "alias": "Burning Castle Battle",
39
+ "text": "A chaotic battlefield with knights on horseback clashing with infantry, archers firing volleys of arrows, and a castle burning in the background. The enemy army, dressed in {enemy_color} armor, is fighting fiercely, with soldiers engaging in brutal melee combat. Flames light up the scene as knights charge through the chaos. Injured soldiers crawl on the ground, and the air is filled with the sounds of clashing steel and screams of pain. Unreal Engine render style, photorealistic, realistic fantasy style."
40
+ },
41
+ {
42
+ "alias": "Heroic Last Stand",
43
+ "text": "A heroic last stand of a small group of knights defending a bridge against a massive army, with arrows flying and swords clashing. The enemy army, dressed in {enemy_color} armor, is overwhelming the defenders, but the knights fight bravely, cutting down enemy soldiers as they advance. The bridge is littered with bodies and broken weapons. Blood stains the ground, and the air is thick with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
44
+ },
45
+ {
46
+ "alias": "Siege Tower Attack",
47
+ "text": "A medieval siege tower approaching a castle wall, with knights scaling ladders and defenders throwing rocks and shooting arrows. The enemy army, dressed in {enemy_color} armor, is fighting desperately to breach the walls, with soldiers clashing swords on the battlements. Arrows fly in all directions, and the siege tower is engulfed in flames. Injured soldiers fall from the ladders, and the ground is littered with the bodies of the fallen. Unreal Engine render style, photorealistic, realistic fantasy style."
48
+ },
49
+ {
50
+ "alias": "Knight Duel",
51
+ "text": "A dramatic duel between two knights in the middle of a battlefield, with their armies watching and the castle in the background. The enemy army, dressed in {enemy_color} armor, is engaged in fierce combat all around, with soldiers clashing swords and firing arrows. The duelists fight with skill and determination, their blades flashing in the sunlight. Injured soldiers lie on the ground, and the air is filled with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
52
+ },
53
+ {
54
+ "alias": "Night Battle",
55
+ "text": "A night battle during a medieval siege, with torches lighting the scene, knights fighting in the shadows, and the castle walls looming in the background. The enemy army, dressed in {enemy_color} armor, is locked in brutal combat, with soldiers clashing swords and firing arrows in the dim light. Flames from burning siege equipment illuminate the chaos. Injured soldiers scream in pain, and the ground is littered with the bodies of the fallen. Unreal Engine render style, photorealistic, realistic fantasy style."
56
+ },
57
+ {
58
+ "alias": "Marching Army",
59
+ "text": "A massive army of knights and infantry marching towards a distant castle, with banners flying and the sun setting behind them. The enemy army, dressed in {enemy_color} armor, is engaging in skirmishes along the way, with soldiers clashing swords and firing arrows. The battlefield is alive with the sounds of combat and the clash of steel. Injured soldiers lie on the ground, and the air is thick with the smell of blood and smoke. Unreal Engine render style, photorealistic, realistic fantasy style."
60
+ },
61
+ {
62
+ "alias": "Snowy Battlefield",
63
+ "text": "A medieval battle in a snowy landscape, with knights in heavy armor fighting on a frozen lake, and the castle visible in the distance. The enemy army, dressed in {enemy_color} armor, is locked in fierce combat, with soldiers slipping on the ice as they clash swords. Arrows fly through the air, and the snow is stained red with blood. Injured soldiers crawl on the ground, and the air is filled with the sounds of battle. Unreal Engine render style, photorealistic, realistic fantasy style."
64
+ }
65
+ ]
66
+
67
+ # Debugging: Print prompt and model options
68
+ print("Prompt Options:", [p["alias"] for p in prompts])
69
+ print("Model Options:", [m["alias"] for m in models])
70
+
71
+ # Function to generate images
72
+ def generate_image(prompt_alias, team, model_alias, custom_prompt, height, width, num_inference_steps, guidance_scale, seed):
73
+ # Debugging: Check if the token is available
74
+ if not api_token:
75
+ return None, "ERROR: Hugging Face token (HF_CTB_TOKEN) is missing. Please set it as an environment variable."
76
+
77
+ # Find the selected prompt and model
78
+ try:
79
+ prompt = next(p for p in prompts if p["alias"] == prompt_alias)["text"]
80
+ model_name = next(m for m in models if m["alias"] == model_alias)["name"]
81
+ except StopIteration:
82
+ return None, "ERROR: Invalid prompt or model selected."
83
+
84
+ # Determine the enemy color
85
+ enemy_color = "blue" if team.lower() == "red" else "red"
86
+ prompt = prompt.format(enemy_color=enemy_color)
87
+
88
+ if team.lower() == "red":
89
+ prompt += " The winning army is dressed in red armor and banners."
90
+ elif team.lower() == "blue":
91
+ prompt += " The winning army is dressed in blue armor and banners."
92
+
93
+ # Append the custom prompt (if provided)
94
+ if custom_prompt and len(custom_prompt.strip()) > 0:
95
+ prompt += " " + custom_prompt.strip()
96
+
97
+ # Randomize the seed if needed
98
+ if seed == -1:
99
+ seed = random.randint(0, 1000000)
100
+
101
+ # Initialize the InferenceClient
102
+ try:
103
+ client = InferenceClient(model_name, token=api_token)
104
+ except Exception as e:
105
+ return None, f"ERROR: Failed to initialize InferenceClient. Details: {e}"
106
+
107
+ # Generate the image
108
+ try:
109
+ image = client.text_to_image(
110
+ prompt,
111
+ guidance_scale=guidance_scale,
112
+ num_inference_steps=num_inference_steps,
113
+ width=width,
114
+ height=height,
115
+ seed=seed
116
+ )
117
+ except Exception as e:
118
+ return None, f"ERROR: Failed to generate image. Details: {e}"
119
+
120
+ # Save the image with a timestamped filename
121
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
122
+ output_filename = f"{timestamp}_{model_alias.replace(' ', '_').lower()}_{prompt_alias.replace(' ', '_').lower()}_{team.lower()}.png"
123
+ try:
124
+ image.save(output_filename)
125
+ except Exception as e:
126
+ return None, f"ERROR: Failed to save image. Details: {e}"
127
+
128
+ return output_filename, "Image generated successfully!"
129
+
130
+ # Gradio Interface
131
+ with gr.Blocks() as demo:
132
+ gr.Markdown("# CtB AI Image Generator")
133
+ with gr.Row():
134
+ # Set default values for dropdowns
135
+ prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Prompt", value=prompts[0]["alias"])
136
+ team_dropdown = gr.Dropdown(choices=["Red", "Blue"], label="Select Team", value="Red")
137
+ model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
138
+ with gr.Row():
139
+ # Add a text box for custom user input (max 200 characters)
140
+ custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
141
+ #with gr.Row():
142
+ # Commented-out dialog boxes (can be re-enabled later)
143
+ # height_input = gr.Number(value=360, label="Height")
144
+ # width_input = gr.Number(value=640, label="Width")
145
+ # num_inference_steps_input = gr.Slider(minimum=10, maximum=100, value=20, label="Inference Steps")
146
+ # guidance_scale_input = gr.Slider(minimum=1.0, maximum=20.0, value=2.0, step=0.5, label="Guidance Scale")
147
+ # seed_input = gr.Number(value=-1, label="Seed (-1 for random)")
148
+ with gr.Row():
149
+ generate_button = gr.Button("Generate Image")
150
+ with gr.Row():
151
+ output_image = gr.Image(label="Generated Image")
152
+ with gr.Row():
153
+ status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
154
+
155
+ # Function to handle button click
156
+ def generate(prompt_alias, team, model_alias, custom_prompt, height=360, width=640, num_inference_steps=20, guidance_scale=2.0, seed=-1):
157
+ try:
158
+ # Generate the image
159
+ image_path, message = generate_image(prompt_alias, team, model_alias, custom_prompt, height, width, num_inference_steps, guidance_scale, seed)
160
+ return image_path, message
161
+ except Exception as e:
162
+ return None, f"An error occurred: {e}"
163
+
164
+ # Connect the button to the function
165
+ generate_button.click(
166
+ generate,
167
+ inputs=[prompt_dropdown, team_dropdown, model_dropdown, custom_prompt_input], # Added custom_prompt_input
168
+ outputs=[output_image, status_text]
169
+ )
170
+
171
+ # Launch the Gradio app
172
+ demo.launch()