Update app.py
Browse files
app.py
CHANGED
|
@@ -16,11 +16,17 @@ def call_predict_api(image, private_key=None):
|
|
| 16 |
"image": ("src_image.png", src_buffer, "image/png"),
|
| 17 |
}
|
| 18 |
headers = {"X-API-Key": os.environ["api_key"]}
|
| 19 |
-
response = requests.
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
iface = gr.Interface(
|
|
@@ -41,7 +47,6 @@ if __name__ == "__main__":
|
|
| 41 |
),
|
| 42 |
],
|
| 43 |
outputs=[
|
| 44 |
-
gr.Textbox(label="Status", type="text", visible=False),
|
| 45 |
gr.Markdown(label="Result")
|
| 46 |
],
|
| 47 |
title="BBC-OCR",
|
|
|
|
| 16 |
"image": ("src_image.png", src_buffer, "image/png"),
|
| 17 |
}
|
| 18 |
headers = {"X-API-Key": os.environ["api_key"]}
|
| 19 |
+
response = requests.get(os.environ["endpoint"],
|
| 20 |
+
files=files,
|
| 21 |
+
headers=headers,
|
| 22 |
+
stream=True
|
| 23 |
+
)
|
| 24 |
+
accumulated = ""
|
| 25 |
+
for line in response:
|
| 26 |
+
if line:
|
| 27 |
+
accumulated += line.decode("utf-8").replace("\n", "\n\n")
|
| 28 |
+
yield accumulated
|
| 29 |
+
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|
| 32 |
iface = gr.Interface(
|
|
|
|
| 47 |
),
|
| 48 |
],
|
| 49 |
outputs=[
|
|
|
|
| 50 |
gr.Markdown(label="Result")
|
| 51 |
],
|
| 52 |
title="BBC-OCR",
|