Spaces:
Sleeping
Sleeping
Andre
commited on
Commit
·
c3e503f
1
Parent(s):
82a3ace
“Update”
Browse files- src/img_gen.py +9 -9
src/img_gen.py
CHANGED
@@ -6,16 +6,16 @@ from huggingface_hub import InferenceClient
|
|
6 |
from datetime import datetime
|
7 |
from config.config import models, prompts, api_token # Direct import
|
8 |
|
9 |
-
def generate(prompt_alias,
|
10 |
try:
|
11 |
# Generate the image
|
12 |
-
image_path, message = generate_image(prompt_alias,
|
13 |
return image_path, message
|
14 |
except Exception as e:
|
15 |
return None, f"An error occurred: {e}"
|
16 |
|
17 |
|
18 |
-
def generate_image(prompt_alias,
|
19 |
# Find the selected prompt and model
|
20 |
try:
|
21 |
prompt = next(p for p in prompts if p["alias"] == prompt_alias)["text"]
|
@@ -26,18 +26,18 @@ def generate_image(prompt_alias, team, winning_team_text, model_alias, custom_pr
|
|
26 |
# Determine the enemy color
|
27 |
enemy_color = "blue" if team.lower() == "red" else "red"
|
28 |
|
29 |
-
if team.lower() == "red":
|
30 |
-
|
31 |
-
elif team.lower() == "blue":
|
32 |
-
|
33 |
|
34 |
# Print the original prompt and dynamic values for debugging
|
35 |
print("Original Prompt:")
|
36 |
print(prompt)
|
37 |
print(f"Enemy Color: {enemy_color}")
|
38 |
-
print(f"
|
39 |
|
40 |
-
prompt = prompt.format(
|
41 |
|
42 |
# Print the formatted prompt for debugging
|
43 |
print("\nFormatted Prompt:")
|
|
|
6 |
from datetime import datetime
|
7 |
from config.config import models, prompts, api_token # Direct import
|
8 |
|
9 |
+
def generate(prompt_alias, team_color, model_alias, custom_prompt, height=360, width=640, num_inference_steps=20, guidance_scale=2.0, seed=-1):
|
10 |
try:
|
11 |
# Generate the image
|
12 |
+
image_path, message = generate_image(prompt_alias, team_color, model_alias, custom_prompt, height, width, num_inference_steps, guidance_scale, seed)
|
13 |
return image_path, message
|
14 |
except Exception as e:
|
15 |
return None, f"An error occurred: {e}"
|
16 |
|
17 |
|
18 |
+
def generate_image(prompt_alias, team_color, model_alias, custom_prompt, height=360, width=640, num_inference_steps=20, guidance_scale=2.0, seed=-1):
|
19 |
# Find the selected prompt and model
|
20 |
try:
|
21 |
prompt = next(p for p in prompts if p["alias"] == prompt_alias)["text"]
|
|
|
26 |
# Determine the enemy color
|
27 |
enemy_color = "blue" if team.lower() == "red" else "red"
|
28 |
|
29 |
+
# if team.lower() == "red":
|
30 |
+
# winning_team_text = " The winning army is dressed in red armor and banners."
|
31 |
+
# elif team.lower() == "blue":
|
32 |
+
# winning_team_text = " The winning army is dressed in blue armor and banners."
|
33 |
|
34 |
# Print the original prompt and dynamic values for debugging
|
35 |
print("Original Prompt:")
|
36 |
print(prompt)
|
37 |
print(f"Enemy Color: {enemy_color}")
|
38 |
+
print(f"Team Color: {team_color.lower()}")
|
39 |
|
40 |
+
prompt = prompt.format(team_color=team_color.lower(), enemy_color=enemy_color)
|
41 |
|
42 |
# Print the formatted prompt for debugging
|
43 |
print("\nFormatted Prompt:")
|