Spaces:
Sleeping
Sleeping
Update app.py (#12)
Browse files- Update app.py (64e97d704ad8c7733e9185560e207c7dcc0c68b5)
Co-authored-by: Ratan Prakash Mishra <[email protected]>
app.py
CHANGED
@@ -54,8 +54,6 @@ team_members = [
|
|
54 |
]
|
55 |
|
56 |
# Function to preprocess the images for the model
|
57 |
-
from PIL import Image
|
58 |
-
import numpy as np
|
59 |
|
60 |
def preprocess_image(image):
|
61 |
"""
|
@@ -298,6 +296,24 @@ elif app_mode == "Task 1":
|
|
298 |
# Load and display the image
|
299 |
image = Image.open(image_path)
|
300 |
st.image(image, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
# Clean up (optional)
|
303 |
os.remove(image_path)
|
|
|
54 |
]
|
55 |
|
56 |
# Function to preprocess the images for the model
|
|
|
|
|
57 |
|
58 |
def preprocess_image(image):
|
59 |
"""
|
|
|
296 |
# Load and display the image
|
297 |
image = Image.open(image_path)
|
298 |
st.image(image, use_column_width=True)
|
299 |
+
|
300 |
+
# Convert image to numpy array for OCR processing
|
301 |
+
img_array = np.array(image)
|
302 |
+
|
303 |
+
# Perform OCR on the image
|
304 |
+
st.write(f"Extracting details from {uploaded_image.name}...")
|
305 |
+
result = ocr.ocr(img_array, cls=True)
|
306 |
+
|
307 |
+
#############################
|
308 |
+
#OCR result text to be parsed here through LLM and get product listing content.
|
309 |
+
messages.append({"role": "user", "content": ""})
|
310 |
+
outputs = pipe(
|
311 |
+
messages,
|
312 |
+
max_new_tokens=256,
|
313 |
+
)
|
314 |
+
productListingContent = outputs[0]["generated_text"][-1]
|
315 |
+
st.markdown(productListingContent)
|
316 |
+
#############################
|
317 |
|
318 |
# Clean up (optional)
|
319 |
os.remove(image_path)
|