clean up code + prompt engineering for image generation

This commit is contained in:
henrisel 2025-11-21 11:39:36 +02:00
parent 191c9e66fe
commit 34a6c50598
2 changed files with 6 additions and 20 deletions

View File

@ -1,8 +1,5 @@
PIPELINE_FOLDER=
REFINE_PROMPT=0
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_API_TOKEN=
3D_GENERATION_URL= 3D_GENERATION_URL=
MODEL_FOLDER= MODEL_FOLDER=
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_API_TOKEN=

View File

@ -1,4 +1,3 @@
import os
import argparse import argparse
import asyncio import asyncio
import logging import logging
@ -8,14 +7,11 @@ from pathlib import Path
from datetime import datetime from datetime import datetime
from dotenv import load_dotenv from dotenv import load_dotenv
from cloudflare_api import text_to_image_cloudflare, refine_text_prompt
from generate_image_local import text_to_image_invoke_ai from generate_image_local import text_to_image_invoke_ai
from generate_model_local import image_to_3d_api, image_to_3d_subprocess from generate_model_local import image_to_3d_api
load_dotenv() load_dotenv()
PIPELINE_FOLDER = os.environ["PIPELINE_FOLDER"]
def get_timestamp(): def get_timestamp():
return datetime.now().strftime("%Y-%m-%d-%H-%M-%S") return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
@ -26,7 +22,6 @@ def setup_logger(base_folder, timestamp):
logging.basicConfig( logging.basicConfig(
filename=log_dir / f"{timestamp}.log", filename=log_dir / f"{timestamp}.log",
level=logging.INFO, level=logging.INFO,
#format='%(asctime)s - %(message)s'
force=True force=True
) )
@ -38,15 +33,9 @@ async def main():
input_prompt = args.prompt input_prompt = args.prompt
print(f"Input prompt: {input_prompt}") print(f"Input prompt: {input_prompt}")
image_generation_prompt = input_prompt + ", single object, plain neutral background, high-resolution, sharp details, soft studio lighting, front and side visible, realistic style, true-to-scale"
refine_prompt = os.environ["REFINE_PROMPT"] == "1"
if refine_prompt:
image_generation_prompt = refine_text_prompt(input_prompt)
print(f"Refined prompt: {image_generation_prompt}")
else:
image_generation_prompt = input_prompt
pipeline_folder = Path(PIPELINE_FOLDER) pipeline_folder = Path(__file__).resolve().parent
timestamp = get_timestamp() timestamp = get_timestamp()
setup_logger(pipeline_folder, timestamp) setup_logger(pipeline_folder, timestamp)
time_checkpoint = time.time() time_checkpoint = time.time()