Spaces:
Paused
Paused
Update app.py
Browse files8 unmodified lines9101112131415161718192021222324252627282930313233126 unmodified lines1601611621631641651661671681691701711728 unmodified linesclient = Client("ysharma/BiRefNet_for_text_writing")def remove_background(image):# Convert NumPy array to PIL Image#image = Image.fromarray(image_array)# Save the image to a specific locationfilename = f"image_{uuid.uuid4()}.png" # Generates a universally unique identifier (UUID) for the filenameimage.save(filename)result = client.predict(images=handle_file(filename), api_name="/image")return Image.open(result[0])def superimpose(image_with_text, overlay_image):# Open both images as RGBA to handle transparency#background = image_with_text #Image.open("/content/out2.png").convert("RGBA")overlay_image = overlay_image.convert("RGBA")# Paste overlay on the backgroundimage_with_text.paste(overlay_image, (0, 0), overlay_image)# Display or save the final image#background.show()# background.save("output_image.png")return image_with_text126 unmodified linesgr.Examples(examples=[["sample.jpg", # Replace with actual example image path"SAMPLE TEXT",400,"White",255,50,50]],inputs=[8 unmodified lines910111213141516171819202122232425262728126 unmodified lines1551561571581591601611621631641651661678 unmodified linesclient = Client("ysharma/BiRefNet_for_text_writing")def remove_background(image):# Save the image to a specific locationfilename = f"image_{uuid.uuid4()}.png" # Generates a universally unique identifier (UUID) for the filenameimage.save(filename)# Call gradio client for background removalresult = client.predict(images=handle_file(filename), api_name="/image")return Image.open(result[0])def superimpose(image_with_text, overlay_image):# Open image as RGBA to handle transparencyoverlay_image = overlay_image.convert("RGBA")# Paste overlay on the backgroundimage_with_text.paste(overlay_image, (0, 0), overlay_image)# Save the final image# image_with_text.save("output_image.png")return image_with_text126 unmodified linesgr.Examples(examples=[["pink_convertible.webp","EPIC",420,"Purple",150,50,21]],inputs=[
app.py+10-15