Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,7 +129,14 @@ Elaborate on each core requirement to create a rich description.
|
|
| 129 |
model_inputs = QWEN_TOKENIZER([text], return_tensors="pt").to(QWEN_MODEL.device)
|
| 130 |
|
| 131 |
with torch.no_grad():
|
| 132 |
-
generated_ids = QWEN_MODEL.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
| 135 |
full_response = QWEN_TOKENIZER.decode(output_ids, skip_special_tokens=True)
|
|
@@ -254,11 +261,14 @@ def create_interface():
|
|
| 254 |
)
|
| 255 |
|
| 256 |
with gr.Row():
|
| 257 |
-
|
| 258 |
-
|
|
|
|
| 259 |
|
| 260 |
-
|
| 261 |
-
|
|
|
|
|
|
|
| 262 |
seed_number_input = gr.Number(label="种子 (-1 随机)", value=-1, minimum=-1, step=1)
|
| 263 |
generate_button = gr.Button("🎨 生成海报", variant="primary", size="lg")
|
| 264 |
|
|
|
|
| 129 |
model_inputs = QWEN_TOKENIZER([text], return_tensors="pt").to(QWEN_MODEL.device)
|
| 130 |
|
| 131 |
with torch.no_grad():
|
| 132 |
+
generated_ids = QWEN_MODEL.generate(
|
| 133 |
+
**model_inputs,
|
| 134 |
+
max_new_tokens=512, # ← 从 4096 改成 512 够用
|
| 135 |
+
temperature=0.6,
|
| 136 |
+
top_p=0.9,
|
| 137 |
+
do_sample=True,
|
| 138 |
+
eos_token_id=QWEN_TOKENIZER.eos_token_id,
|
| 139 |
+
)
|
| 140 |
|
| 141 |
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
| 142 |
full_response = QWEN_TOKENIZER.decode(output_ids, skip_special_tokens=True)
|
|
|
|
| 261 |
)
|
| 262 |
|
| 263 |
with gr.Row():
|
| 264 |
+
# 默认宽度 832,高度 1216
|
| 265 |
+
width_input = gr.Slider(label="宽度", minimum=256, maximum=MAX_IMAGE_SIZE, value=832, step=32)
|
| 266 |
+
height_input = gr.Slider(label="高度", minimum=256, maximum=MAX_IMAGE_SIZE, value=1216, step=32)
|
| 267 |
|
| 268 |
+
# 默认步数 28
|
| 269 |
+
num_inference_steps_input = gr.Slider(label="推理步数", minimum=1, maximum=100, value=28, step=1)
|
| 270 |
+
# 默认 CFG 28,为了能取到 28,将最大值提高到 40
|
| 271 |
+
guidance_scale_input = gr.Slider(label="引导强度", minimum=0.0, maximum=40.0, value=28, step=0.1)
|
| 272 |
seed_number_input = gr.Number(label="种子 (-1 随机)", value=-1, minimum=-1, step=1)
|
| 273 |
generate_button = gr.Button("🎨 生成海报", variant="primary", size="lg")
|
| 274 |
|