Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,6 @@ def infer(color_prompt, phone_type_prompt, design_prompt):
|
|
43 |
else:
|
44 |
raise Exception(f"API Error: {response.status_code}")
|
45 |
|
46 |
-
# Function to save the design with a caption
|
47 |
def save_design(image, color_prompt, phone_type_prompt, design_prompt):
|
48 |
# Convert NumPy array to PIL Image
|
49 |
if isinstance(image, np.ndarray):
|
@@ -61,7 +60,7 @@ def save_design(image, color_prompt, phone_type_prompt, design_prompt):
|
|
61 |
font = ImageFont.load_default()
|
62 |
|
63 |
# Calculate position for text
|
64 |
-
text_width, text_height =
|
65 |
position = (10, image.height - text_height - 10) # Bottom-left corner with padding
|
66 |
|
67 |
# Add caption to the image
|
@@ -72,6 +71,7 @@ def save_design(image, color_prompt, phone_type_prompt, design_prompt):
|
|
72 |
image.save(file_path)
|
73 |
return f"Design saved as {file_path}!"
|
74 |
|
|
|
75 |
# HTML-based carousel content
|
76 |
carousel_html = """
|
77 |
<div class="carousel">
|
|
|
43 |
else:
|
44 |
raise Exception(f"API Error: {response.status_code}")
|
45 |
|
|
|
46 |
def save_design(image, color_prompt, phone_type_prompt, design_prompt):
|
47 |
# Convert NumPy array to PIL Image
|
48 |
if isinstance(image, np.ndarray):
|
|
|
60 |
font = ImageFont.load_default()
|
61 |
|
62 |
# Calculate position for text
|
63 |
+
text_width, text_height = font.getsize_multiline(caption) # Updated function
|
64 |
position = (10, image.height - text_height - 10) # Bottom-left corner with padding
|
65 |
|
66 |
# Add caption to the image
|
|
|
71 |
image.save(file_path)
|
72 |
return f"Design saved as {file_path}!"
|
73 |
|
74 |
+
|
75 |
# HTML-based carousel content
|
76 |
carousel_html = """
|
77 |
<div class="carousel">
|