Spaces:
Sleeping
Sleeping
Update api_server.py
Browse files- api_server.py +18 -0
api_server.py
CHANGED
@@ -75,12 +75,30 @@ def get_jpg_files(path):
|
|
75 |
# image_folder = '/content/drive/MyDrive/chiikawa' # 替換成你的目錄路徑
|
76 |
# jpg_files = get_jpg_files(image_folder)
|
77 |
|
|
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
# Initialize the Flask application
|
80 |
app = Flask(__name__)
|
81 |
# Initialize the ClipModel at the start
|
82 |
clip_model = ClipModel()
|
83 |
|
|
|
84 |
|
85 |
# API route for prediction(YOLO)
|
86 |
@app.route('/predict', methods=['POST'])
|
|
|
75 |
# image_folder = '/content/drive/MyDrive/chiikawa' # 替換成你的目錄路徑
|
76 |
# jpg_files = get_jpg_files(image_folder)
|
77 |
|
78 |
+
import psutil
|
79 |
|
80 |
+
def check_memory_usage():
|
81 |
+
# Get memory details
|
82 |
+
memory_info = psutil.virtual_memory()
|
83 |
+
|
84 |
+
total_memory = memory_info.total / (1024 * 1024) # Convert bytes to MB
|
85 |
+
available_memory = memory_info.available / (1024 * 1024)
|
86 |
+
used_memory = memory_info.used / (1024 * 1024)
|
87 |
+
memory_usage_percent = memory_info.percent
|
88 |
+
|
89 |
+
print(f"Total Memory: {total_memory:.2f} MB")
|
90 |
+
print(f"Available Memory: {available_memory:.2f} MB")
|
91 |
+
print(f"Used Memory: {used_memory:.2f} MB")
|
92 |
+
print(f"Memory Usage (%): {memory_usage_percent}%")
|
93 |
+
|
94 |
+
# Run the function
|
95 |
+
check_memory_usage()
|
96 |
# Initialize the Flask application
|
97 |
app = Flask(__name__)
|
98 |
# Initialize the ClipModel at the start
|
99 |
clip_model = ClipModel()
|
100 |
|
101 |
+
check_memory_usage()
|
102 |
|
103 |
# API route for prediction(YOLO)
|
104 |
@app.route('/predict', methods=['POST'])
|