Spaces:
Running
Running
Saurabh Kumar
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ MODEL, PROCESSOR = init_qwen_model()
|
|
15 |
|
16 |
# Streamlit app title
|
17 |
st.title("OCR Image Text Extraction")
|
18 |
-
|
19 |
# File uploader for images
|
20 |
uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
21 |
|
@@ -33,7 +33,7 @@ if uploaded_file is not None:
|
|
33 |
"type": "image",
|
34 |
"image": image,
|
35 |
},
|
36 |
-
{"type": "text", "text": "Run Optical Character recognition on the image."},
|
37 |
],
|
38 |
}
|
39 |
]
|
@@ -53,7 +53,7 @@ if uploaded_file is not None:
|
|
53 |
inputs = inputs.to("cpu")
|
54 |
|
55 |
# Inference: Generation of the output
|
56 |
-
generated_ids = MODEL.generate(**inputs, max_new_tokens=
|
57 |
generated_ids_trimmed = [
|
58 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
59 |
]
|
|
|
15 |
|
16 |
# Streamlit app title
|
17 |
st.title("OCR Image Text Extraction")
|
18 |
+
st.subheader("I used Qwen2-VL-7B-Instruct model to get better accuracy but as it is running on CPU it takes 25-30 minutes to run it. So please have patience.")
|
19 |
# File uploader for images
|
20 |
uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"])
|
21 |
|
|
|
33 |
"type": "image",
|
34 |
"image": image,
|
35 |
},
|
36 |
+
{"type": "text", "text": "Run Optical Character recognition on the image for Hindi and English."},
|
37 |
],
|
38 |
}
|
39 |
]
|
|
|
53 |
inputs = inputs.to("cpu")
|
54 |
|
55 |
# Inference: Generation of the output
|
56 |
+
generated_ids = MODEL.generate(**inputs, max_new_tokens=256)
|
57 |
generated_ids_trimmed = [
|
58 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
59 |
]
|