File size: 1,063 Bytes
c06f9a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
from groq import Groq

def extract_id_details(image_url):
    client = Groq()
    completion = client.chat.completions.create(
        model="llama-3.2-90b-vision-preview",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "List all the details from the provided image of an ID card."},
                    {"type": "image_url", "image_url": {"url": image_url}}
                ]
            }
        ],
        temperature=0.2,
        max_completion_tokens=200,
        top_p=1,
        stream=False,
        stop=None,
    )
    return completion.choices[0].message.content

st.title("ID Card OCR Extractor")

image_url = st.text_input("Enter the image URL:")

if st.button("Extract Details"):
    if image_url:
        with st.spinner("Extracting details..."):
            details = extract_id_details(image_url)
        st.subheader("Extracted Details:")
        st.write(details)
    else:
        st.warning("Please enter a valid image URL.")