root
commited on
Commit
·
f9aef00
1
Parent(s):
d0e0f83
add timecompute
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import io
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
from typing import Dict, List, Tuple, Any, Optional
|
| 6 |
-
|
| 7 |
import requests
|
| 8 |
from PIL import Image
|
| 9 |
import gradio as gr
|
|
@@ -105,7 +105,11 @@ def _call_api(api_url: str, file_path: str, use_layout_detection: bool,
|
|
| 105 |
|
| 106 |
try:
|
| 107 |
# 关键改动:带上 headers
|
|
|
|
| 108 |
resp = requests.post(api_url, json=payload, headers=JSON_HEADERS, timeout=600)
|
|
|
|
|
|
|
|
|
|
| 109 |
resp.raise_for_status()
|
| 110 |
data = resp.json()
|
| 111 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
from typing import Dict, List, Tuple, Any, Optional
|
| 6 |
+
import time
|
| 7 |
import requests
|
| 8 |
from PIL import Image
|
| 9 |
import gradio as gr
|
|
|
|
| 105 |
|
| 106 |
try:
|
| 107 |
# 关键改动:带上 headers
|
| 108 |
+
start_time = time.time()
|
| 109 |
resp = requests.post(api_url, json=payload, headers=JSON_HEADERS, timeout=600)
|
| 110 |
+
end_time = time.time()
|
| 111 |
+
duration = end_time - start_time # 新增: 计算耗时
|
| 112 |
+
print(f"Received API response in {duration:.2f} seconds.") # 新增: 打印耗时
|
| 113 |
resp.raise_for_status()
|
| 114 |
data = resp.json()
|
| 115 |
except requests.exceptions.RequestException as e:
|