Spaces:
Running
Running
Update app_pages/text_image_generation.py
Browse files
app_pages/text_image_generation.py
CHANGED
|
@@ -14,12 +14,61 @@ def render_multimodel_ad_generator(prefix: str = "img_text"):
|
|
| 14 |
colA, colB = st.columns([1, 1])
|
| 15 |
|
| 16 |
with colA:
|
| 17 |
-
model_key = st.selectbox("Model",
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
category = st.text_input("Category", key=f"{prefix}_cat", placeholder="e.g. skincare, supplements")
|
| 23 |
platform = st.selectbox(
|
| 24 |
"Platform",
|
| 25 |
["Facebook", "Instagram", "TikTok", "Google", "Newsbreak"],
|
|
@@ -38,6 +87,15 @@ def render_multimodel_ad_generator(prefix: str = "img_text"):
|
|
| 38 |
if not uid:
|
| 39 |
st.error("Please log in to generate images.")
|
| 40 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
handle_image_generation_optimized(
|
| 42 |
uid=uid,
|
| 43 |
model_key=model_key,
|
|
@@ -47,4 +105,5 @@ def render_multimodel_ad_generator(prefix: str = "img_text"):
|
|
| 47 |
category=(category.strip() or None),
|
| 48 |
platform=platform or None,
|
| 49 |
private_mode=private_mode,
|
|
|
|
| 50 |
)
|
|
|
|
| 14 |
colA, colB = st.columns([1, 1])
|
| 15 |
|
| 16 |
with colA:
|
| 17 |
+
model_key = st.selectbox("Model",list(MODEL_REGISTRY.keys()),index=0, key=f"{prefix}_model")
|
| 18 |
+
cfg = get_model_config(model_key)
|
| 19 |
+
if model_key == "z-image-turbo":
|
| 20 |
+
width = st.slider(
|
| 21 |
+
"Width",
|
| 22 |
+
min_value=256,
|
| 23 |
+
max_value=2048,
|
| 24 |
+
value=1024,
|
| 25 |
+
step=64,
|
| 26 |
+
key=f"{prefix}_width",
|
| 27 |
+
)
|
| 28 |
+
height = st.slider(
|
| 29 |
+
"Height",
|
| 30 |
+
min_value=256,
|
| 31 |
+
max_value=2048,
|
| 32 |
+
value=1024,
|
| 33 |
+
step=64,
|
| 34 |
+
key=f"{prefix}_height",
|
| 35 |
+
)
|
| 36 |
+
output_quality = st.slider(
|
| 37 |
+
"Output Quality",
|
| 38 |
+
min_value=50,
|
| 39 |
+
max_value=100,
|
| 40 |
+
value=90,
|
| 41 |
+
step=1,
|
| 42 |
+
key=f"{prefix}_quality",
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
aspect_ratio = "" # not used for z-turbo
|
| 46 |
+
else:
|
| 47 |
+
aspect_options = cfg.get("aspect_ratios", ["1:1"]) if cfg else ["1:1"]
|
| 48 |
+
|
| 49 |
+
aspect_ratio = st.selectbox(
|
| 50 |
+
"Aspect Ratio",
|
| 51 |
+
aspect_options,
|
| 52 |
+
index=0,
|
| 53 |
+
key=f"{prefix}_ar",
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
width = height = output_quality = None
|
| 57 |
+
|
| 58 |
+
num_images = st.slider(
|
| 59 |
+
"Number of images",
|
| 60 |
+
1,
|
| 61 |
+
10,
|
| 62 |
+
1,
|
| 63 |
+
key=f"{prefix}_count",
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
category = st.text_input(
|
| 67 |
+
"Category",
|
| 68 |
+
key=f"{prefix}_cat",
|
| 69 |
+
placeholder="e.g. skincare, supplements",
|
| 70 |
+
)
|
| 71 |
|
|
|
|
| 72 |
platform = st.selectbox(
|
| 73 |
"Platform",
|
| 74 |
["Facebook", "Instagram", "TikTok", "Google", "Newsbreak"],
|
|
|
|
| 87 |
if not uid:
|
| 88 |
st.error("Please log in to generate images.")
|
| 89 |
return
|
| 90 |
+
params = {}
|
| 91 |
+
|
| 92 |
+
if model_key == "z-image-turbo":
|
| 93 |
+
params = {
|
| 94 |
+
"width": width,
|
| 95 |
+
"height": height,
|
| 96 |
+
"output_quality": output_quality,
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
handle_image_generation_optimized(
|
| 100 |
uid=uid,
|
| 101 |
model_key=model_key,
|
|
|
|
| 105 |
category=(category.strip() or None),
|
| 106 |
platform=platform or None,
|
| 107 |
private_mode=private_mode,
|
| 108 |
+
params=params,
|
| 109 |
)
|