Update app.py
Browse files
app.py
CHANGED
|
@@ -59,16 +59,14 @@ def process_image(input_image):
|
|
| 59 |
|
| 60 |
# --- 3.取得系統狀態的函數 ---
|
| 61 |
def get_system_stats():
|
| 62 |
-
|
| 63 |
-
cpu = psutil.cpu_percent(interval=None)
|
| 64 |
-
# 取得 RAM 使用率
|
| 65 |
-
ram = psutil.virtual_memory().percent
|
| 66 |
-
return {"cpu": cpu, "ram": ram}
|
| 67 |
|
| 68 |
# --- 4. 介面 ---
|
| 69 |
-
with gr.Blocks(title="
|
| 70 |
gr.Markdown("## ✂️ 去背服務測試")
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
with gr.Row():
|
| 73 |
input_img = gr.Image(type="pil", label="Input")
|
| 74 |
output_img = gr.Image(type="pil", label="Output", format="png") # 確保輸出 PNG 才有透明度
|
|
|
|
| 59 |
|
| 60 |
# --- 3.取得系統狀態的函數 ---
|
| 61 |
def get_system_stats():
|
| 62 |
+
return {"cpu": psutil.cpu_percent(), "ram": psutil.virtual_memory().percent}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# --- 4. 介面 ---
|
| 65 |
+
with gr.Blocks(title="去背服務測試") as app:
|
| 66 |
gr.Markdown("## ✂️ 去背服務測試")
|
| 67 |
+
status_output = gr.JSON()
|
| 68 |
+
status_btn = gr.Button("Status", visible=False)
|
| 69 |
+
status_btn.click(get_system_stats, inputs=None, outputs=status_output, api_name="status")
|
| 70 |
with gr.Row():
|
| 71 |
input_img = gr.Image(type="pil", label="Input")
|
| 72 |
output_img = gr.Image(type="pil", label="Output", format="png") # 確保輸出 PNG 才有透明度
|