@@ -212,22 +212,33 @@ def analyze_images(images):
212212 # feedback_items.append((f'Feedback Image [{idx}]', f'{upload_image(img, "eduvision")} <br>'))
213213 # except ImageUploadError as e:
214214 # print(f"Failed to upload image feedback {idx}", e)
215+
216+ #for idx, (img, detections, best_idx) in enumerate(annotated_images):
217+ # try:
218+ # img_url = upload_image(img, "eduvision")
219+ # # Extract original filename from the user's uploaded image URL (from response)
220+ # from urllib.parse import urlparse, unquote
221+ # original_url = response[idx]["url"] if idx < len(response) and "url" in response[idx] else None
222+ # if original_url:
223+ # parsed_orig = urlparse(original_url)
224+ # orig_filename = os.path.basename(parsed_orig.path)
225+ # orig_filename = unquote(orig_filename) if orig_filename else f"image_{idx}.jpg"
226+ # else:
227+ # orig_filename = f"image_{idx}.jpg"
228+ # link_html = f'<a href="{img_url}" target="_blank">{orig_filename}</a>'
229+ # feedback_items.append((f'Feedback Image [{idx}]', link_html))
230+ # except ImageUploadError as e:
231+ # print(f"Failed to upload image feedback {idx}", e)
232+
233+
234+
235+
215236 for idx , (img , detections , best_idx ) in enumerate (annotated_images ):
216237 try :
217- img_url = upload_image (img , "eduvision" )
218- # Extract original filename from the user's uploaded image URL (from response)
219- from urllib .parse import urlparse , unquote
220- original_url = response [idx ]["url" ] if idx < len (response ) and "url" in response [idx ] else None
221- if original_url :
222- parsed_orig = urlparse (original_url )
223- orig_filename = os .path .basename (parsed_orig .path )
224- orig_filename = unquote (orig_filename ) if orig_filename else f"image_{ idx } .jpg"
225- else :
226- orig_filename = f"image_{ idx } .jpg"
227- link_html = f'<a href="{ img_url } " target="_blank">{ orig_filename } </a>'
228- feedback_items .append ((f'Feedback Image [{ idx } ]' , link_html ))
238+ # Upload the processed (annotated) image and append as feedback
239+ feedback_items .append ((f'Feedback Image [{ idx } ]' , f"{ upload_image (img , 'eduvision' )} <br>" ))
229240 except ImageUploadError as e :
230- print (f "Failed to upload image feedback { idx } " , e )
241+ print ("Failed to upload image feedback" , e )
231242
232243
233244 show_target = params .get ("show_target" , True )
0 commit comments