mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-06-08 19:35:07 +01:00
code updates for date, fix update flux guff, new prompt logic
This commit is contained in:
parent
2a9a226dd1
commit
4b52e5c713
@ -60,7 +60,8 @@ def image_details(filename):
|
|||||||
details = get_details_from_png(path)
|
details = get_details_from_png(path)
|
||||||
return {
|
return {
|
||||||
"prompt": details["p"],
|
"prompt": details["p"],
|
||||||
"model": details["m"]
|
"model": details["m"],
|
||||||
|
"date": details["d"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ def create_image(prompt: str | None = None, model: str = "Random") -> None:
|
|||||||
seed_param="seed",
|
seed_param="seed",
|
||||||
save_node="CivitAI Image Saver",
|
save_node="CivitAI Image Saver",
|
||||||
save_param="filename",
|
save_param="filename",
|
||||||
model_node="CivitAI Image Saver",
|
model_node="Unet Loader (GGUF)",
|
||||||
model_param="modelname",
|
model_param="unet_name",
|
||||||
model=model
|
model=model
|
||||||
)
|
)
|
||||||
else: # SDXL
|
else: # SDXL
|
||||||
|
@ -66,6 +66,7 @@ def rename_image() -> str | None:
|
|||||||
|
|
||||||
def get_details_from_png(path):
|
def get_details_from_png(path):
|
||||||
try:
|
try:
|
||||||
|
date = datetime.fromtimestamp(os.path.getctime(path)).strftime("%d-%m-%Y")
|
||||||
with Image.open(path) as img:
|
with Image.open(path) as img:
|
||||||
try:
|
try:
|
||||||
# Flux workflow
|
# Flux workflow
|
||||||
@ -77,7 +78,7 @@ def get_details_from_png(path):
|
|||||||
data = json.loads(img.info["prompt"])
|
data = json.loads(img.info["prompt"])
|
||||||
prompt = data['6']['inputs']['text']
|
prompt = data['6']['inputs']['text']
|
||||||
model = data['4']['inputs']['ckpt_name']
|
model = data['4']['inputs']['ckpt_name']
|
||||||
return {"p":prompt,"m":model} or {"p":"","m":""}
|
return {"p":prompt,"m":model,"d":date} or {"p":"","m":"","c":""}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error reading metadata from {path}: {e}")
|
print(f"Error reading metadata from {path}: {e}")
|
||||||
return ""
|
return ""
|
||||||
|
@ -24,13 +24,13 @@ def create_prompt_on_openwebui(prompt: str) -> str:
|
|||||||
topic_instruction = f" Incorporate the theme of '{selected_topic}' into the new prompt."
|
topic_instruction = f" Incorporate the theme of '{selected_topic}' into the new prompt."
|
||||||
|
|
||||||
user_content = (
|
user_content = (
|
||||||
"Here are the prompts from the last 7 days:\n\n"
|
"Can you generate me a really random image idea, Do not exceed 10 words. Use clear language, not poetic metaphors.”"
|
||||||
+ "\n".join(f"{i+1}. {p}" for i, p in enumerate(recent_prompts))
|
|
||||||
+ "\n\nDo not repeat ideas, themes, or settings from the above. "
|
|
||||||
"Now generate a new, completely original Stable Diffusion prompt that hasn't been done yet."
|
|
||||||
+ topic_instruction
|
+ topic_instruction
|
||||||
|
+ "Avoid prompts similar to the following:"
|
||||||
|
+ "\n".join(f"{i+1}. {p}" for i, p in enumerate(recent_prompts))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
model = random.choice(user_config["openwebui"]["models"].split(","))
|
model = random.choice(user_config["openwebui"]["models"].split(","))
|
||||||
response = litellm.completion(
|
response = litellm.completion(
|
||||||
api_base=user_config["openwebui"]["base_url"],
|
api_base=user_config["openwebui"]["base_url"],
|
||||||
|
@ -263,7 +263,7 @@
|
|||||||
|
|
||||||
if (detailsCache[filename]) {
|
if (detailsCache[filename]) {
|
||||||
document.getElementById("lightbox-prompt").textContent =
|
document.getElementById("lightbox-prompt").textContent =
|
||||||
`Model: ${detailsCache[filename].model}\n\n${detailsCache[filename].prompt}`;
|
`Created On: ${detailsCache[filename].date}\n\n Model: ${detailsCache[filename].model}\n\n${detailsCache[filename].prompt}`;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("lightbox-prompt").textContent = "Loading…";
|
document.getElementById("lightbox-prompt").textContent = "Loading…";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user