add timestamp to file name
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
from rembg import remove, new_session
|
| 3 |
from PIL import Image
|
| 4 |
import logging
|
|
|
|
| 5 |
|
| 6 |
# Set up logging
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -52,7 +53,9 @@ def remove_background(input_image, bg_color, model_name, alpha_matting, post_pro
|
|
| 52 |
logging.info("Converted to RGB mode")
|
| 53 |
|
| 54 |
# Save the output image to a temporary file
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
output_image.save(output_path)
|
| 57 |
logging.info(f"Saved output image {output_path}")
|
| 58 |
|
|
|
|
| 2 |
from rembg import remove, new_session
|
| 3 |
from PIL import Image
|
| 4 |
import logging
|
| 5 |
+
import time
|
| 6 |
|
| 7 |
# Set up logging
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 53 |
logging.info("Converted to RGB mode")
|
| 54 |
|
| 55 |
# Save the output image to a temporary file
|
| 56 |
+
# Generate a unique timestamp for the output file name
|
| 57 |
+
timestamp = time.strftime("%Y%m%d-%H%M%S")
|
| 58 |
+
output_path = f"output_remove_background_s{timestamp}.png"
|
| 59 |
output_image.save(output_path)
|
| 60 |
logging.info(f"Saved output image {output_path}")
|
| 61 |
|