Abid Ali Awan Codex commited on
Commit ·
429a368
1
Parent(s): c6454a8
Catch ZeroGPU quota errors and reduce GPU duration to 45s
Browse filesDistinguish ZeroGPU quota exhaustion from model parsing failures
so users see a clear 'GPU quota exceeded' message instead of the
misleading 'incomplete response' error. Reduce @spaces.GPU
duration from 60s to 45s to conserve quota.
Co-authored-by: Codex <codex@openai.com>
- app/model_endpoint.py +1 -1
- app/service.py +7 -2
- static/app.js +2 -0
app/model_endpoint.py
CHANGED
|
@@ -293,7 +293,7 @@ def _run_transformers_completion(
|
|
| 293 |
return _parse_model_json(repaired)
|
| 294 |
|
| 295 |
|
| 296 |
-
@spaces.GPU(duration=
|
| 297 |
def call_model(
|
| 298 |
text: str,
|
| 299 |
image_data_url: str = "",
|
|
|
|
| 293 |
return _parse_model_json(repaired)
|
| 294 |
|
| 295 |
|
| 296 |
+
@spaces.GPU(duration=45)
|
| 297 |
def call_model(
|
| 298 |
text: str,
|
| 299 |
image_data_url: str = "",
|
app/service.py
CHANGED
|
@@ -194,9 +194,14 @@ def analyze_notice(
|
|
| 194 |
message = "The local model is unavailable or could not be loaded."
|
| 195 |
error_code = "modelUnavailableError"
|
| 196 |
except (RuntimeError, ValueError) as exc:
|
|
|
|
| 197 |
logger.error("Model returned invalid response: %s: %s", type(exc).__name__, exc)
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
return finish(
|
| 202 |
{
|
|
|
|
| 194 |
message = "The local model is unavailable or could not be loaded."
|
| 195 |
error_code = "modelUnavailableError"
|
| 196 |
except (RuntimeError, ValueError) as exc:
|
| 197 |
+
exc_text = str(exc)
|
| 198 |
logger.error("Model returned invalid response: %s: %s", type(exc).__name__, exc)
|
| 199 |
+
if "ZeroGPU quota" in exc_text or "exceeded your ZeroGPU" in exc_text:
|
| 200 |
+
message = "GPU quota exceeded. Please try again later or authenticate with a Hugging Face token for more quota."
|
| 201 |
+
error_code = "gpuQuotaError"
|
| 202 |
+
else:
|
| 203 |
+
message = "The local model returned an invalid response. Please try again."
|
| 204 |
+
error_code = "modelInvalidError"
|
| 205 |
|
| 206 |
return finish(
|
| 207 |
{
|
static/app.js
CHANGED
|
@@ -87,6 +87,7 @@ const translations = {
|
|
| 87 |
modelConfigurationError: "The local model runtime is not configured.",
|
| 88 |
modelUnavailableError: "The model is unavailable or still starting. Please try again.",
|
| 89 |
modelInvalidError: "The model returned an incomplete response. Please try again.",
|
|
|
|
| 90 |
ocrUnavailableError: "Nemotron OCR is unavailable. Paste the notice text instead.",
|
| 91 |
ocrNoTextError: "No readable text was found in the screenshot.",
|
| 92 |
ocrLanguageError: "Urdu-script screenshots are not supported yet. Paste an English transcription instead.",
|
|
@@ -168,6 +169,7 @@ const translations = {
|
|
| 168 |
modelConfigurationError: "مقامی ماڈل درست طریقے سے ترتیب نہیں دیا گیا۔",
|
| 169 |
modelUnavailableError: "ماڈل دستیاب نہیں یا ابھی شروع ہو رہا ہے۔ براہ کرم دوبارہ کوشش کریں۔",
|
| 170 |
modelInvalidError: "ماڈل کا جواب مکمل نہیں تھا۔ براہ کرم دوبارہ کوشش کریں۔",
|
|
|
|
| 171 |
ocrUnavailableError: "Nemotron OCR دستیاب نہیں۔ نوٹس کا متن پیسٹ کریں۔",
|
| 172 |
ocrNoTextError: "اسکرین شاٹ میں پڑھنے کے قابل متن نہیں ملا۔",
|
| 173 |
ocrLanguageError: "اردو رسم الخط کے اسکرین شاٹس ابھی معاون نہیں ہیں۔ انگریزی متن پیسٹ کریں۔",
|
|
|
|
| 87 |
modelConfigurationError: "The local model runtime is not configured.",
|
| 88 |
modelUnavailableError: "The model is unavailable or still starting. Please try again.",
|
| 89 |
modelInvalidError: "The model returned an incomplete response. Please try again.",
|
| 90 |
+
gpuQuotaError: "GPU quota exceeded. Please try again later or authenticate with a Hugging Face token for more quota.",
|
| 91 |
ocrUnavailableError: "Nemotron OCR is unavailable. Paste the notice text instead.",
|
| 92 |
ocrNoTextError: "No readable text was found in the screenshot.",
|
| 93 |
ocrLanguageError: "Urdu-script screenshots are not supported yet. Paste an English transcription instead.",
|
|
|
|
| 169 |
modelConfigurationError: "مقامی ماڈل درست طریقے سے ترتیب نہیں دیا گیا۔",
|
| 170 |
modelUnavailableError: "ماڈل دستیاب نہیں یا ابھی شروع ہو رہا ہے۔ براہ کرم دوبارہ کوشش کریں۔",
|
| 171 |
modelInvalidError: "ماڈل کا جواب مکمل نہیں تھا۔ براہ کرم دوبارہ کوشش کریں۔",
|
| 172 |
+
gpuQuotaError: "GPU کوٹہ ختم ہو گیا۔ براہ کرم بعد میں دوبارہ کوشش کریں یا مزید کوٹہ کے لیے Hugging Face ٹوکن سے تصدیق کریں۔",
|
| 173 |
ocrUnavailableError: "Nemotron OCR دستیاب نہیں۔ نوٹس کا متن پیسٹ کریں۔",
|
| 174 |
ocrNoTextError: "اسکرین شاٹ میں پڑھنے کے قابل متن نہیں ملا۔",
|
| 175 |
ocrLanguageError: "اردو رسم الخط کے اسکرین شاٹس ابھی معاون نہیں ہیں۔ انگریزی متن پیسٹ کریں۔",
|