image stuff

This commit is contained in:
j 2026-02-03 18:13:06 +01:00
commit 00f6b9b4f4

View file

@ -492,6 +492,35 @@ def process_frame(item, prompt, character=None, position=0, seed=None):
img.update_find()
return img
def process_image(document, prompt, character=None, position=0, seed=None):
model = "seedream-4-5-251128"
if isinstance(character, Document):
character = public_document_url(character)
image = public_document_url(document)
if character is not None:
image = [image, character]
data = {
"model": model,
"prompt": prompt,
"image": image,
"size": "2560x1440",
}
if seed:
data["seed"] = seed
url = bytedance_image_generation(data)
img = add_ai_image(document, position, url)
img.refresh_from_db()
img.data["model"] = model
img.data["prompt"] = prompt
img.data["source"] = document.get_id()
if character:
img.data["source"] += " " + character.split("?")[0]
print(img, img.data)
img.save()
img.update_sort()
img.update_find()
return img
def replace_background(image, background, prompt=None, seed=None):
model = "seedream-4-5-251128"
position = 0
@ -538,6 +567,8 @@ REPLACE_CHARACTER_PROMPT = "Replace the foreground character in image 1 with the
REPLACE_CHARACTER_PROMPT = "Replace the foreground character in image 1 with the character in image 2, keep the posture, clothing, background, light, atmosphere from image 1, but take the facial features and personality from image 2. Make sure the size of the character is adjusted since the new character is a child and make sure the size of the head matches the body. The quality of the image should be the same between foreground and background, adjust the quality of the character to match the background. Use the style of image 1 for the character: if image 1 is a photo make the character a real person, if image 1 is a drawing make the character a drawn character, if image 1 is a comic use a comic character, restore any blurred out regions of the image"
REPLACE_CHARACTER_PROMPT = "Replace the main character in image 1 with the character in image 2, keep the posture, clothing, background, light, atmosphere from image 1, but take the facial features and personality from image 2. Make sure the size of the character is adjusted since the new character is a child and make sure the size of the head matches the body. The quality of the image should be the same between foreground and background, adjust the quality of the character to match the background. Use the style of image 1 for the character: if image 1 is a photo make the character a real person, if image 1 is a drawing make the character a drawn character, if image 1 is a comic use a comic character, restore any blurred out regions of the image"
def fal_replace_character(item, character, position=0):
if isinstance(item, str):