Spaces:
Running
on
Zero
Running
on
Zero
Session and tmp clean up changes
Browse files- app.py +5 -3
- utils/file_utils.py +1 -0
app.py
CHANGED
@@ -128,18 +128,20 @@ depth_model: Optional[DPTForDepthEstimation] = None
|
|
128 |
TRELLIS_PIPELINE: Optional[TrellisImageTo3DPipeline] = None
|
129 |
pipe: Optional[Union[FluxPipeline, FluxImg2ImgPipeline, FluxControlPipeline]] = None
|
130 |
|
131 |
-
# Register the cleanup function
|
132 |
-
atexit.register(cleanup_temp_files)
|
133 |
-
|
134 |
def start_session(req: gr.Request):
|
|
|
135 |
user_dir = os.path.join(constants.TMPDIR, str(req.session_hash))
|
136 |
os.makedirs(user_dir, exist_ok=True)
|
137 |
|
138 |
|
139 |
def end_session(req: gr.Request):
|
|
|
140 |
user_dir = os.path.join(constants.TMPDIR, str(req.session_hash))
|
141 |
shutil.rmtree(user_dir)
|
142 |
|
|
|
|
|
|
|
143 |
def hex_create(hex_size, border_size, input_image_path, start_x, start_y, end_x, end_y, rotation, background_color_hex, background_opacity, border_color_hex, border_opacity, fill_hex, excluded_colors_var, filter_color, x_spacing, y_spacing, add_hex_text_option=None, custom_text_list=None, custom_text_color_list=None):
|
144 |
global input_image_palette
|
145 |
|
|
|
128 |
TRELLIS_PIPELINE: Optional[TrellisImageTo3DPipeline] = None
|
129 |
pipe: Optional[Union[FluxPipeline, FluxImg2ImgPipeline, FluxControlPipeline]] = None
|
130 |
|
|
|
|
|
|
|
131 |
def start_session(req: gr.Request):
|
132 |
+
print(f"Starting session with hash: {req.session_hash}")
|
133 |
user_dir = os.path.join(constants.TMPDIR, str(req.session_hash))
|
134 |
os.makedirs(user_dir, exist_ok=True)
|
135 |
|
136 |
|
137 |
def end_session(req: gr.Request):
|
138 |
+
print(f"Ending session with hash: {req.session_hash}")
|
139 |
user_dir = os.path.join(constants.TMPDIR, str(req.session_hash))
|
140 |
shutil.rmtree(user_dir)
|
141 |
|
142 |
+
# Register the cleanup function
|
143 |
+
atexit.register(end_session)
|
144 |
+
|
145 |
def hex_create(hex_size, border_size, input_image_path, start_x, start_y, end_x, end_y, rotation, background_color_hex, background_opacity, border_color_hex, border_opacity, fill_hex, excluded_colors_var, filter_color, x_spacing, y_spacing, add_hex_text_option=None, custom_text_list=None, custom_text_color_list=None):
|
146 |
global input_image_palette
|
147 |
|
utils/file_utils.py
CHANGED
@@ -10,6 +10,7 @@ def cleanup_temp_files():
|
|
10 |
os.remove(file_path)
|
11 |
except Exception as e:
|
12 |
print(f"Failed to delete temp file {file_path}: {e}")
|
|
|
13 |
|
14 |
def rename_file_to_lowercase_extension(file_path: str) -> str:
|
15 |
"""
|
|
|
10 |
os.remove(file_path)
|
11 |
except Exception as e:
|
12 |
print(f"Failed to delete temp file {file_path}: {e}")
|
13 |
+
print("Temp files cleaned up. Goodbye")
|
14 |
|
15 |
def rename_file_to_lowercase_extension(file_path: str) -> str:
|
16 |
"""
|