Skip to content

Commit b567703

Browse files
committed
implement frontend app
1 parent 6cce686 commit b567703

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

frontend/entrypoint.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from frontend.solutions import azure_storage, document_intelligence, sandbox, transcription
3+
from frontend.solutions import azure_ai_vision, azure_storage, document_intelligence, sandbox, transcription
44
from frontend.solutions.types import SolutionType
55

66
logger = logging.getLogger(__name__)
@@ -31,3 +31,8 @@ def start(
3131
backend_url=backend_url,
3232
log_level=log_level,
3333
)
34+
if solution_type == SolutionType.AZURE_AI_VISION:
35+
return azure_ai_vision.start(
36+
backend_url=backend_url,
37+
log_level=log_level,
38+
)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import asyncio
2+
import logging
3+
from io import BytesIO
4+
from urllib.parse import urljoin
5+
6+
import streamlit as st
7+
8+
from frontend.solutions.utilities import http_post_file
9+
10+
logger = logging.getLogger(__name__)
11+
12+
13+
def start(
14+
backend_url: str,
15+
log_level: int,
16+
):
17+
logger.setLevel(log_level)
18+
logger.debug(f"set log level to {log_level}")
19+
20+
st.header("Azure AI Vision")
21+
22+
file_uploader = st.file_uploader(
23+
label="Choose a file",
24+
key="file_uploader",
25+
)
26+
27+
analyze_button = st.button(
28+
label="Analyze",
29+
key="analyze_button",
30+
)
31+
32+
if file_uploader is not None:
33+
st.image(file_uploader, caption="Uploaded image")
34+
if analyze_button:
35+
with st.spinner("Analyzing..."):
36+
bytes_data = file_uploader.getvalue()
37+
response = asyncio.run(
38+
http_post_file(
39+
url=urljoin(base=backend_url, url="/azure_ai_vision/image/analyze/"),
40+
data_bytes_io=BytesIO(bytes_data),
41+
)
42+
)
43+
st.write(response)
44+
else:
45+
st.warning("Please upload a file first")

frontend/solutions/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ class SolutionType(Enum):
66
TRANSCRIPTION = "TRANSCRIPTION"
77
DOCUMENT_INTELLIGENCE = "DOCUMENT_INTELLIGENCE"
88
AZURE_STORAGE = "AZURE_STORAGE"
9+
AZURE_AI_VISION = "AZURE_AI_VISION"

0 commit comments

Comments
 (0)