Skip to content

Commit 038505b

Browse files
committed
feat: add automatic prompt enhancer for extreme photorealism
1 parent e1b4cab commit 038505b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

app.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def read_root():
4040
@app.post("/api/generate")
4141
async def generate_image(req: GenerateRequest):
4242
try:
43+
# Secretly enhance prompts for extreme photorealism
44+
enhanced_prompt = f"RAW photo, highly detailed, photorealistic, 8k resolution, ultra-realistic, DSLR, cinematic lighting, masterpiece. {req.prompt}"
45+
enhanced_negative = f"cartoon, 3d render, anime, illustration, painting, low quality, worst quality, deformed, ugly, blurry, {req.negative_prompt}"
46+
4347
# Branch 1: Face Swap using InstantID (Gradio API Hack)
4448
if req.face_image_base64:
4549
base64_data = req.face_image_base64
@@ -55,8 +59,8 @@ async def generate_image(req: GenerateRequest):
5559
result = gradio_client.predict(
5660
face_image_path=handle_file(tmp_path),
5761
pose_image_path=None,
58-
prompt=req.prompt,
59-
negative_prompt=req.negative_prompt,
62+
prompt=enhanced_prompt,
63+
negative_prompt=enhanced_negative,
6064
style_name="(No style)",
6165
num_steps=30,
6266
identitynet_strength_ratio=0.8,
@@ -87,13 +91,12 @@ async def generate_image(req: GenerateRequest):
8791

8892
# Branch 2: Blazing Fast Text-to-Image (FLUX.1-schnell)
8993
parameters = {}
90-
if req.negative_prompt:
91-
parameters["negative_prompt"] = req.negative_prompt
94+
parameters["negative_prompt"] = enhanced_negative
9295
if req.seed is not None:
9396
parameters["seed"] = req.seed
9497

9598
image = hf_client.text_to_image(
96-
req.prompt,
99+
enhanced_prompt,
97100
model="black-forest-labs/FLUX.1-schnell",
98101
parameters=parameters
99102
)

0 commit comments

Comments
 (0)