Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files63 unmodified lines646566676869318 unmodified lines38838939039139239339439539663 unmodified linesEntry point called by Gradio.Returns: (annotated_image, gender_html, age_html, emotion_html, aged_image)"""if image is None:empty = _blank("No image received")return empty, "–", "–", "–", empty318 unmodified linesoutputs = [annotated_out, gender_out, age_out, emotion_out, aged_out],)# Also run on webcam stream changes (live mode)image_input.change(fn = analyze,inputs = [image_input],outputs = [annotated_out, gender_out, age_out, emotion_out, aged_out],)63 unmodified lines6465666768697071727374757677787980318 unmodified lines39940040140240340440540640763 unmodified linesEntry point called by Gradio.Returns: (annotated_image, gender_html, age_html, emotion_html, aged_image)"""try:return _analyze_inner(image)except Exception as exc:import tracebacktraceback.print_exc()err = _card(f"Error: {exc}", "Check Space logs for details")blank = _blank("Error")return blank, err, err, err, blankdef _analyze_inner(image: np.ndarray):if image is None:empty = _blank("No image received")return empty, "–", "–", "–", empty318 unmodified linesoutputs = [annotated_out, gender_out, age_out, emotion_out, aged_out],)# Run on webcam changes only when image is not Noneimage_input.change(fn = lambda img: analyze(img) if img is not None else (None,)*5,inputs = [image_input],outputs = [annotated_out, gender_out, age_out, emotion_out, aged_out],)
app.py+13-2