Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import os
|
|
5 |
|
6 |
def call_predict_api(image, private_key=None):
|
7 |
if private_key != os.environ["api_key"]:
|
8 |
-
return "Invalid API key. Please check your key and try again."
|
9 |
# Convert PIL images to base64 string
|
10 |
src_buffer = BytesIO()
|
11 |
image.save(src_buffer, format='PNG')
|
@@ -20,7 +20,7 @@ def call_predict_api(image, private_key=None):
|
|
20 |
if response.status_code != 200:
|
21 |
raise Exception(f"API Error: {response.text}")
|
22 |
result = response.json()["result"]
|
23 |
-
return result.replace("\n", "\n\n")
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
iface = gr.Interface(
|
@@ -40,7 +40,8 @@ if __name__ == "__main__":
|
|
40 |
lines=1,
|
41 |
),
|
42 |
],
|
43 |
-
outputs=[gr.Markdown(label="Result")
|
|
|
44 |
title="BBC-OCR",
|
45 |
description="A simple OCR tool to extract text from images.",
|
46 |
)
|
|
|
5 |
|
6 |
def call_predict_api(image, private_key=None):
|
7 |
if private_key != os.environ["api_key"]:
|
8 |
+
return "Invalid API key. Please check your key and try again.", "Invalid API key"
|
9 |
# Convert PIL images to base64 string
|
10 |
src_buffer = BytesIO()
|
11 |
image.save(src_buffer, format='PNG')
|
|
|
20 |
if response.status_code != 200:
|
21 |
raise Exception(f"API Error: {response.text}")
|
22 |
result = response.json()["result"]
|
23 |
+
return result.replace("\n", "\n\n"), "Success"
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
iface = gr.Interface(
|
|
|
40 |
lines=1,
|
41 |
),
|
42 |
],
|
43 |
+
outputs=[gr.Markdown(label="Result"),
|
44 |
+
gr.Textbox(label="Status", type="text", visible=False)],
|
45 |
title="BBC-OCR",
|
46 |
description="A simple OCR tool to extract text from images.",
|
47 |
)
|