JeffreyXiang commited on
Commit
edf8619
1 Parent(s): 977dc2e

Add tmp cleaning code

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -246,6 +246,23 @@ with gr.Blocks() as demo:
246
  )
247
 
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  # Launch the Gradio app
250
  if __name__ == "__main__":
251
  pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
 
246
  )
247
 
248
 
249
+ # Cleans up the temporary directory every 10 minutes
250
+ import threading
251
+ import time
252
+
253
+ def cleanup_tmp_dir():
254
+ while True:
255
+ if os.path.exists(TMP_DIR):
256
+ for file in os.listdir(TMP_DIR):
257
+ # remove files older than 10 minutes
258
+ if time.time() - os.path.getmtime(os.path.join(TMP_DIR, file)) > 600:
259
+ os.remove(os.path.join(TMP_DIR, file))
260
+ time.sleep(600)
261
+
262
+ cleanup_thread = threading.Thread(target=cleanup_tmp_dir)
263
+ cleanup_thread.start()
264
+
265
+
266
  # Launch the Gradio app
267
  if __name__ == "__main__":
268
  pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")