Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from groq import Groq
|
3 |
+
|
4 |
+
def extract_id_details(image_url):
|
5 |
+
client = Groq()
|
6 |
+
completion = client.chat.completions.create(
|
7 |
+
model="llama-3.2-90b-vision-preview",
|
8 |
+
messages=[
|
9 |
+
{
|
10 |
+
"role": "user",
|
11 |
+
"content": [
|
12 |
+
{"type": "text", "text": "List all the details from the provided image of an ID card."},
|
13 |
+
{"type": "image_url", "image_url": {"url": image_url}}
|
14 |
+
]
|
15 |
+
}
|
16 |
+
],
|
17 |
+
temperature=0.2,
|
18 |
+
max_completion_tokens=200,
|
19 |
+
top_p=1,
|
20 |
+
stream=False,
|
21 |
+
stop=None,
|
22 |
+
)
|
23 |
+
return completion.choices[0].message.content
|
24 |
+
|
25 |
+
st.title("ID Card OCR Extractor")
|
26 |
+
|
27 |
+
image_url = st.text_input("Enter the image URL:")
|
28 |
+
|
29 |
+
if st.button("Extract Details"):
|
30 |
+
if image_url:
|
31 |
+
with st.spinner("Extracting details..."):
|
32 |
+
details = extract_id_details(image_url)
|
33 |
+
st.subheader("Extracted Details:")
|
34 |
+
st.write(details)
|
35 |
+
else:
|
36 |
+
st.warning("Please enter a valid image URL.")
|