Skip to content

Commit

Permalink
adsfa
Browse files Browse the repository at this point in the history
  • Loading branch information
WillReynolds5 committed Sep 16, 2024
1 parent 5538f5b commit bd66e87
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions meeca/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import json
import os
from PIL import Image
import base64

# Set the server address for your API
server_address = "https://1314-2601-681-8700-b290-7300-d115-8289-9b9c.ngrok-free.app"


def gen_prompt(pos_prompt, neg_prompt, background_prompt, face_image, pose_image, seed=None):
def gen_prompt(pos_prompt, neg_prompt, background_prompt, face_image_data, pose_image_data, seed=None):
if seed is None:
seed = random.randint(0, 1_000_000)

Expand All @@ -21,17 +22,17 @@ def gen_prompt(pos_prompt, neg_prompt, background_prompt, face_image, pose_image
# Modify the positive, negative, and background prompts
character_gen_data["17"]["inputs"]["text"] = pos_prompt
character_gen_data["18"]["inputs"]["text"] = neg_prompt
character_gen_data["86"]["inputs"]["text"] = background_prompt # Added background prompt
character_gen_data["86"]["inputs"]["text"] = background_prompt

# Set the seed
character_gen_data["19"]["inputs"]["seed"] = seed

# Set the grounding dino prompt to 'women'
character_gen_data["14"]["inputs"]["prompt"] = "women"

# Set the image paths for face and pose images
character_gen_data["11"]["inputs"]["image"] = pose_image
character_gen_data["29"]["inputs"]["image"] = face_image
# Include the image data
character_gen_data["11"]["inputs"]["image_data"] = pose_image_data
character_gen_data["29"]["inputs"]["image_data"] = face_image_data

return character_gen_data

Expand Down Expand Up @@ -81,22 +82,20 @@ def generate_tab():
# Generate button
if st.button("Generate"):
if face_image_file is not None and pose_image_file is not None:
# Save the uploaded files to temporary paths
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as tmp_face:
tmp_face.write(face_image_file.read())
face_image_path = tmp_face.name
# Read and encode the uploaded images
face_image_bytes = face_image_file.read()
face_image_b64 = base64.b64encode(face_image_bytes).decode('utf-8')

with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as tmp_pose:
tmp_pose.write(pose_image_file.read())
pose_image_path = tmp_pose.name
pose_image_bytes = pose_image_file.read()
pose_image_b64 = base64.b64encode(pose_image_bytes).decode('utf-8')

# Generate the prompt
prompt = gen_prompt(
positive_prompt,
negative_prompt,
background_prompt,
face_image_path,
pose_image_path,
face_image_b64,
pose_image_b64,
seed
)

Expand Down

0 comments on commit bd66e87

Please sign in to comment.