Spaces:
Runtime error
Runtime error
Update app.py
Browse files69 unmodified lines7071727374759 unmodified lines85868788899091929394959697989910010110210310410510610769 unmodified linespdf.output(output_path)return output_path# Gradio UI (app launcher)def app():def process(image):9 unmodified linesheart_rate = estimate_heart_rate(frame_rgb, landmarks)spo2, rr = estimate_spo2_rr(heart_rate)results_dict = {'Hemoglobin': 12.3,'WBC Count': 6.4,'Platelets': 210,'Iron': 55,'Ferritin': 45,'TIBC': 340,'Bilirubin': 1.5,'Creatinine': 1.3,'TSH': 2.5,'Cortisol': 18,'Fasting Blood Sugar': 120,'HbA1c': 6.2,'SpO2': spo2,'Heart Rate': heart_rate,'Respiratory Rate': rr}summary_text = "<li>Your hemoglobin is a bit low...</li><li>Consider iron tests.</li>" # Placeholderpdf_path = generate_pdf_report(image, results_dict, summary_text)69 unmodified lines7071727374757677787980818283848586878889909192939495969798999 unmodified lines10911011111211311411569 unmodified linespdf.output(output_path)return output_pathdef infer_lab_results(image, landmarks):h, w, _ = image.shapeforehead = image[int(0.1*h):int(0.25*h), int(0.35*w):int(0.65*w)]mean_intensity = np.mean(cv2.cvtColor(forehead, cv2.COLOR_BGR2GRAY))skin_redness = np.mean(image[:, :, 2]) - np.mean(image[:, :, 1])return {'Hemoglobin': round(10 + (mean_intensity / 255.0) * 7, 1),'WBC Count': round(4 + (1 - mean_intensity / 255.0) * 7, 1),'Platelets': int(150 + (mean_intensity / 255.0) * 150),'Iron': round(40 + (skin_redness / 50.0) * 40, 1),'Ferritin': round(25 + (skin_redness / 50.0) * 70, 1),'TIBC': round(250 + ((255 - mean_intensity) / 255.0) * 150, 1),'Bilirubin': round(0.5 + (255 - mean_intensity) / 255.0 * 1.5, 2),'Creatinine': round(0.8 + (skin_redness / 255.0) * 0.6, 2),'TSH': round(1.0 + (skin_redness / 255.0) * 2.0, 2),'Cortisol': round(12 + (skin_redness / 255.0) * 10, 2),'Fasting Blood Sugar': int(80 + (skin_redness / 255.0) * 60),'HbA1c': round(5.0 + (skin_redness / 255.0) * 1.5, 2),'SpO2': round(97 - (255 - mean_intensity) / 255.0 * 5, 1),'Heart Rate': estimate_heart_rate(image, landmarks),'Respiratory Rate': estimate_spo2_rr(estimate_heart_rate(image, landmarks))[1]}# Gradio UI (app launcher)def app():def process(image):9 unmodified linesheart_rate = estimate_heart_rate(frame_rgb, landmarks)spo2, rr = estimate_spo2_rr(heart_rate)results_dict = infer_lab_results(frame_rgb, landmarks)summary_text = "<li>Your hemoglobin is a bit low...</li><li>Consider iron tests.</li>" # Placeholderpdf_path = generate_pdf_report(image, results_dict, summary_text)
app.py+25-17