Update app.py
Browse files
app.py
CHANGED
@@ -253,13 +253,13 @@
|
|
253 |
import logging
|
254 |
import random
|
255 |
import warnings
|
256 |
-
import os
|
257 |
import torch
|
258 |
import numpy as np
|
259 |
from diffusers import FluxControlNetModel
|
260 |
from diffusers.pipelines import FluxControlNetPipeline
|
261 |
from PIL import Image
|
262 |
-
from huggingface_hub import snapshot_download,login
|
263 |
import io
|
264 |
import base64
|
265 |
from flask import Flask, request, jsonify
|
@@ -269,9 +269,25 @@ from flask_cors import CORS
|
|
269 |
app = Flask(__name__)
|
270 |
CORS(app)
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
|
273 |
# Clear Hugging Face cache
|
274 |
-
|
275 |
|
276 |
# Add config to store base64 images
|
277 |
app.config['image_outputs'] = {}
|
|
|
253 |
import logging
|
254 |
import random
|
255 |
import warnings
|
256 |
+
import os,shutil,subprocess
|
257 |
import torch
|
258 |
import numpy as np
|
259 |
from diffusers import FluxControlNetModel
|
260 |
from diffusers.pipelines import FluxControlNetPipeline
|
261 |
from PIL import Image
|
262 |
+
from huggingface_hub import snapshot_download,login
|
263 |
import io
|
264 |
import base64
|
265 |
from flask import Flask, request, jsonify
|
|
|
269 |
app = Flask(__name__)
|
270 |
CORS(app)
|
271 |
|
272 |
+
# Function to check disk usage
|
273 |
+
def check_disk_space():
|
274 |
+
result = subprocess.run(['df', '-h'], capture_output=True, text=True)
|
275 |
+
print(result.stdout)
|
276 |
+
|
277 |
+
# Function to clear Hugging Face cache
|
278 |
+
def clear_huggingface_cache():
|
279 |
+
cache_dir = os.path.expanduser('~/.cache/huggingface')
|
280 |
+
if os.path.exists(cache_dir):
|
281 |
+
shutil.rmtree(cache_dir) # Removes the entire cache directory
|
282 |
+
print(f"Cleared Hugging Face cache at: {cache_dir}")
|
283 |
+
else:
|
284 |
+
print("No Hugging Face cache found.")
|
285 |
+
|
286 |
+
# Check disk space
|
287 |
+
check_disk_space()
|
288 |
|
289 |
# Clear Hugging Face cache
|
290 |
+
clear_huggingface_cache()
|
291 |
|
292 |
# Add config to store base64 images
|
293 |
app.config['image_outputs'] = {}
|