h2oai / wave-image-styling-playground

A interactive playground to style and edit images, generate art and have fun.
MIT License
13 stars 2 forks source link

Incorrect photo upload throws a value error #4

Closed pramitchoudhary closed 1 year ago

pramitchoudhary commented 2 years ago
  File "./img_styler/ui/handlers.py", line 215, in image_upload
    facial_feature_analysis(q, _img, "Uploaded Image")
  File "./img_styler/ui/handlers.py", line 263, in facial_feature_analysis
    obj = DeepFace.analyze(img_path=_img, models=models, actions=['emotion'])
  File "/wave-image-styler/.venv/lib/python3.7/site-packages/deepface/DeepFace.py", line 391, in analyze
    img, region = functions.preprocess_face(img = img_path, target_size = (48, 48), grayscale = True, enforce_detection = enforce_detection, detector_backend = detector_backend, return_region = True)
  File "/wave-image-styler/.venv/lib/python3.7/site-packages/deepface/commons/functions.py", line 178, in preprocess_face
    img, region = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = enforce_detection, align = align)
  File "/wave-image-styler/.venv/lib/python3.7/site-packages/deepface/commons/functions.py", line 124, in detect_face
    raise ValueError("Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.")
ValueError: Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.
pramitchoudhary commented 1 year ago

Another one,

Traceback (most recent call last):
  File "/resources/venv/lib/python3.7/site-packages/h2o_wave/server.py", line 320, in _process
    await self._handle(q)
  File "./img_styler/ui/app.py", line 34, in serve
    await handle_on(q)
  File "./img_styler/ui/wave_next.py", line 72, in handle_on
    if await _match_predicate(predicate, func, arity, q, arg_value):
  File "./img_styler/ui/wave_next.py", line 22, in _match_predicate
    await _invoke_handler(func, arity, q, arg)
  File "/resources/venv/lib/python3.7/site-packages/h2o_wave/routing.py", line 117, in _invoke_handler
    await func(q)
  File "./img_styler/ui/handlers.py", line 160, in on_task_selection
    await process(q)
  File "./img_styler/ui/handlers.py", line 80, in process
    await apply(q)
  File "./img_styler/ui/handlers.py", line 383, in apply
    generate_projection(source_face, PRE_COMPUTED_PROJECTION_PATH)
  File "./img_styler/caller.py", line 178, in generate_projection
    target_pil = align_face(input_img)
  File "./img_styler/face_aligner.py", line 46, in align_face
    lm = get_landmark(filepath)
  File "./img_styler/face_aligner.py", line 31, in get_landmark
    t = list(shape.parts())
UnboundLocalError: local variable 'shape' referenced before assignment
pramitchoudhary commented 1 year ago

Fixed.