Spaces:
Sleeping
Sleeping
Update app.py
#8
by
RatanPrakash
- opened
app.py
CHANGED
@@ -164,6 +164,8 @@ st.sidebar.write("DELHI TECHNOLOGICAL UNIVERSITY")
|
|
164 |
st.sidebar.title("Navigation")
|
165 |
st.sidebar.write("Team Name: sadhya")
|
166 |
app_mode = st.sidebar.selectbox("Choose the task", ["Welcome","Project Details", "Task 1","Team Details"])
|
|
|
|
|
167 |
if app_mode == "Welcome":
|
168 |
# Navigation Menu
|
169 |
st.write("# Welcome to Amazon Smbhav! π")
|
@@ -250,12 +252,12 @@ elif app_mode=="Project Details":
|
|
250 |
|
251 |
""")
|
252 |
|
253 |
-
|
254 |
elif app_mode == "Team Details":
|
255 |
st.write("## Meet Our Team:")
|
256 |
display_team_members(team_members)
|
257 |
st.write("Delhi Technological University")
|
258 |
|
|
|
259 |
elif app_mode == "Task 1":
|
260 |
st.write("## Task 1: πΌοΈ OCR to Extract Details π")
|
261 |
st.write("Using OCR to extract details from product packaging material, including brand name and pack size.")
|
@@ -271,15 +273,21 @@ elif app_mode == "Task 1":
|
|
271 |
post_url = st.text_input("Enter Instagram Post URL:")
|
272 |
|
273 |
if post_url:
|
274 |
-
|
|
|
|
|
|
|
|
|
|
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
283 |
|
284 |
# File uploader for images (supports multiple files)
|
285 |
uploaded_files = st.file_uploader("Upload images of products", type=["jpeg", "png", "jpg"], accept_multiple_files=True)
|
@@ -327,8 +335,8 @@ elif app_mode == "Task 1":
|
|
327 |
product_name = clean_text_line
|
328 |
else:
|
329 |
product_details += clean_text_line + " "
|
330 |
-
|
331 |
return product_name, product_details.strip()
|
|
|
332 |
if st.button("Start Analysis"):
|
333 |
simulate_progress()
|
334 |
# Loop through each uploaded image and process them
|
@@ -344,6 +352,10 @@ elif app_mode == "Task 1":
|
|
344 |
st.write(f"Extracting details from {uploaded_image.name}...")
|
345 |
result = ocr.ocr(img_array, cls=True)
|
346 |
|
|
|
|
|
|
|
|
|
347 |
# Process the OCR result to extract product name and properties
|
348 |
product_name, product_details = extract_product_info(result)
|
349 |
|
|
|
164 |
st.sidebar.title("Navigation")
|
165 |
st.sidebar.write("Team Name: sadhya")
|
166 |
app_mode = st.sidebar.selectbox("Choose the task", ["Welcome","Project Details", "Task 1","Team Details"])
|
167 |
+
|
168 |
+
|
169 |
if app_mode == "Welcome":
|
170 |
# Navigation Menu
|
171 |
st.write("# Welcome to Amazon Smbhav! π")
|
|
|
252 |
|
253 |
""")
|
254 |
|
|
|
255 |
elif app_mode == "Team Details":
|
256 |
st.write("## Meet Our Team:")
|
257 |
display_team_members(team_members)
|
258 |
st.write("Delhi Technological University")
|
259 |
|
260 |
+
|
261 |
elif app_mode == "Task 1":
|
262 |
st.write("## Task 1: πΌοΈ OCR to Extract Details π")
|
263 |
st.write("Using OCR to extract details from product packaging material, including brand name and pack size.")
|
|
|
273 |
post_url = st.text_input("Enter Instagram Post URL:")
|
274 |
|
275 |
if post_url:
|
276 |
+
caption, image_path = get_instagram_post_details(post_url)
|
277 |
+
|
278 |
+
if image_path and os.path.exists(image_path):
|
279 |
+
st.subheader("Caption:")
|
280 |
+
st.write(caption)
|
281 |
+
st.subheader("Image:")
|
282 |
|
283 |
+
# Load and display the image
|
284 |
+
image = Image.open(image_path)
|
285 |
+
st.image(image, use_column_width=True)
|
286 |
+
|
287 |
+
# Clean up (optional)
|
288 |
+
os.remove(image_path)
|
289 |
+
else:
|
290 |
+
st.error("Failed to retrieve the post details. Please check the URL.")
|
291 |
|
292 |
# File uploader for images (supports multiple files)
|
293 |
uploaded_files = st.file_uploader("Upload images of products", type=["jpeg", "png", "jpg"], accept_multiple_files=True)
|
|
|
335 |
product_name = clean_text_line
|
336 |
else:
|
337 |
product_details += clean_text_line + " "
|
|
|
338 |
return product_name, product_details.strip()
|
339 |
+
|
340 |
if st.button("Start Analysis"):
|
341 |
simulate_progress()
|
342 |
# Loop through each uploaded image and process them
|
|
|
352 |
st.write(f"Extracting details from {uploaded_image.name}...")
|
353 |
result = ocr.ocr(img_array, cls=True)
|
354 |
|
355 |
+
#############################
|
356 |
+
#OCR result text to be parsed here through LLM and get product listing content.
|
357 |
+
#############################
|
358 |
+
|
359 |
# Process the OCR result to extract product name and properties
|
360 |
product_name, product_details = extract_product_info(result)
|
361 |
|