Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,25 +9,20 @@ import uuid
|
|
9 |
client = Client("ysharma/BiRefNet_for_text_writing")
|
10 |
|
11 |
def remove_background(image):
|
12 |
-
# Convert NumPy array to PIL Image
|
13 |
-
#image = Image.fromarray(image_array)
|
14 |
# Save the image to a specific location
|
15 |
filename = f"image_{uuid.uuid4()}.png" # Generates a universally unique identifier (UUID) for the filename
|
16 |
image.save(filename)
|
17 |
-
|
18 |
result = client.predict(images=handle_file(filename), api_name="/image")
|
19 |
return Image.open(result[0])
|
20 |
|
21 |
def superimpose(image_with_text, overlay_image):
|
22 |
-
# Open
|
23 |
-
#background = image_with_text #Image.open("/content/out2.png").convert("RGBA")
|
24 |
overlay_image = overlay_image.convert("RGBA")
|
25 |
# Paste overlay on the background
|
26 |
image_with_text.paste(overlay_image, (0, 0), overlay_image)
|
27 |
-
|
28 |
-
#
|
29 |
-
#background.show()
|
30 |
-
# background.save("output_image.png")
|
31 |
return image_with_text
|
32 |
|
33 |
|
@@ -160,13 +155,13 @@ def create_interface():
|
|
160 |
gr.Examples(
|
161 |
examples=[
|
162 |
[
|
163 |
-
"
|
164 |
-
"
|
165 |
-
|
166 |
-
"
|
167 |
-
|
168 |
50,
|
169 |
-
|
170 |
]
|
171 |
],
|
172 |
inputs=[
|
|
|
9 |
client = Client("ysharma/BiRefNet_for_text_writing")
|
10 |
|
11 |
def remove_background(image):
|
|
|
|
|
12 |
# Save the image to a specific location
|
13 |
filename = f"image_{uuid.uuid4()}.png" # Generates a universally unique identifier (UUID) for the filename
|
14 |
image.save(filename)
|
15 |
+
# Call gradio client for background removal
|
16 |
result = client.predict(images=handle_file(filename), api_name="/image")
|
17 |
return Image.open(result[0])
|
18 |
|
19 |
def superimpose(image_with_text, overlay_image):
|
20 |
+
# Open image as RGBA to handle transparency
|
|
|
21 |
overlay_image = overlay_image.convert("RGBA")
|
22 |
# Paste overlay on the background
|
23 |
image_with_text.paste(overlay_image, (0, 0), overlay_image)
|
24 |
+
# Save the final image
|
25 |
+
# image_with_text.save("output_image.png")
|
|
|
|
|
26 |
return image_with_text
|
27 |
|
28 |
|
|
|
155 |
gr.Examples(
|
156 |
examples=[
|
157 |
[
|
158 |
+
"pink_convertible.webp",
|
159 |
+
"EPIC",
|
160 |
+
420,
|
161 |
+
"Purple",
|
162 |
+
150,
|
163 |
50,
|
164 |
+
21
|
165 |
]
|
166 |
],
|
167 |
inputs=[
|