Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ except:
|
|
49 |
medical_model = clip_model
|
50 |
MEDICAL_MODEL_AVAILABLE = False
|
51 |
|
52 |
-
# Stanford Dogs & lifespans
|
53 |
STANFORD_BREEDS = [
|
54 |
"afghan hound", "african hunting dog", "airedale", "american staffordshire terrier",
|
55 |
"appenzeller", "australian terrier", "basenji", "basset", "beagle",
|
@@ -120,43 +120,21 @@ BREED_LIFESPAN = {
|
|
120 |
"wire-haired fox terrier": 13.5, "yorkshire terrier": 13.3
|
121 |
}
|
122 |
|
123 |
-
# HRQOL Questionnaire
|
124 |
HRQOL_QUESTIONNAIRE = {
|
125 |
"vitality": {
|
126 |
"title": "π Vitality & Energy Assessment",
|
127 |
-
"description": "Evaluate your dog's energy
|
128 |
"questions": [
|
129 |
{
|
130 |
-
"id": "
|
131 |
-
"text": "How would you rate your dog's energy
|
132 |
"options": [
|
133 |
-
"Excellent - Very energetic,
|
134 |
-
"Very Good - Generally energetic
|
135 |
-
"Good - Moderate energy,
|
136 |
-
"Fair - Lower energy,
|
137 |
-
"Poor - Very low energy,
|
138 |
-
]
|
139 |
-
},
|
140 |
-
{
|
141 |
-
"id": "vitality_play",
|
142 |
-
"text": "How often does your dog seek out play or interaction?",
|
143 |
-
"options": [
|
144 |
-
"Always seeks play/interaction",
|
145 |
-
"Often seeks play/interaction",
|
146 |
-
"Sometimes seeks play/interaction",
|
147 |
-
"Rarely seeks play/interaction",
|
148 |
-
"Never seeks play/interaction"
|
149 |
-
]
|
150 |
-
},
|
151 |
-
{
|
152 |
-
"id": "vitality_response",
|
153 |
-
"text": "How quickly does your dog respond to exciting stimuli (treats, walks, visitors)?",
|
154 |
-
"options": [
|
155 |
-
"Immediate enthusiastic response",
|
156 |
-
"Quick positive response",
|
157 |
-
"Moderate response time",
|
158 |
-
"Slow or delayed response",
|
159 |
-
"No response or negative reaction"
|
160 |
]
|
161 |
}
|
162 |
],
|
@@ -164,39 +142,17 @@ HRQOL_QUESTIONNAIRE = {
|
|
164 |
},
|
165 |
"comfort": {
|
166 |
"title": "π Comfort & Pain Management",
|
167 |
-
"description": "Assess
|
168 |
"questions": [
|
169 |
{
|
170 |
-
"id": "
|
171 |
-
"text": "How
|
172 |
-
"options": [
|
173 |
-
"Completely comfortable during all activities",
|
174 |
-
"Mostly comfortable with minor adjustments",
|
175 |
-
"Some discomfort during certain activities",
|
176 |
-
"Frequently uncomfortable, avoids some activities",
|
177 |
-
"Severe discomfort, avoids most activities"
|
178 |
-
]
|
179 |
-
},
|
180 |
-
{
|
181 |
-
"id": "comfort_pain_frequency",
|
182 |
-
"text": "How often do you notice signs of pain or discomfort?",
|
183 |
-
"options": [
|
184 |
-
"Never shows pain signs",
|
185 |
-
"Rarely shows pain signs (< 1 day/week)",
|
186 |
-
"Sometimes shows pain signs (2-3 days/week)",
|
187 |
-
"Often shows pain signs (4-5 days/week)",
|
188 |
-
"Always shows pain signs (daily)"
|
189 |
-
]
|
190 |
-
},
|
191 |
-
{
|
192 |
-
"id": "comfort_impact",
|
193 |
-
"text": "How does your dog's comfort level affect daily activities?",
|
194 |
"options": [
|
195 |
-
"
|
196 |
-
"
|
197 |
-
"
|
198 |
-
"
|
199 |
-
"Severe
|
200 |
]
|
201 |
}
|
202 |
],
|
@@ -204,39 +160,17 @@ HRQOL_QUESTIONNAIRE = {
|
|
204 |
},
|
205 |
"emotional_wellbeing": {
|
206 |
"title": "π Emotional Wellbeing",
|
207 |
-
"description": "Evaluate mood,
|
208 |
"questions": [
|
209 |
{
|
210 |
-
"id": "
|
211 |
-
"text": "How would you describe your dog's overall mood?",
|
212 |
-
"options": [
|
213 |
-
"Very positive - happy, content, enthusiastic",
|
214 |
-
"Mostly positive - generally cheerful",
|
215 |
-
"Neutral - neither particularly happy nor sad",
|
216 |
-
"Mostly negative - seems subdued or withdrawn",
|
217 |
-
"Very negative - appears depressed or distressed"
|
218 |
-
]
|
219 |
-
},
|
220 |
-
{
|
221 |
-
"id": "emotion_anxiety",
|
222 |
-
"text": "How often does your dog show signs of anxiety or stress?",
|
223 |
-
"options": [
|
224 |
-
"Never shows anxiety/stress",
|
225 |
-
"Rarely shows anxiety/stress",
|
226 |
-
"Sometimes shows anxiety/stress",
|
227 |
-
"Often shows anxiety/stress",
|
228 |
-
"Constantly shows anxiety/stress"
|
229 |
-
]
|
230 |
-
},
|
231 |
-
{
|
232 |
-
"id": "emotion_engagement",
|
233 |
-
"text": "How engaged is your dog with family activities?",
|
234 |
"options": [
|
235 |
-
"
|
236 |
-
"
|
237 |
-
"
|
238 |
-
"
|
239 |
-
"
|
240 |
]
|
241 |
}
|
242 |
],
|
@@ -244,39 +178,17 @@ HRQOL_QUESTIONNAIRE = {
|
|
244 |
},
|
245 |
"alertness": {
|
246 |
"title": "π§ Alertness & Cognition",
|
247 |
-
"description": "Assess cognitive function
|
248 |
"questions": [
|
249 |
{
|
250 |
-
"id": "
|
251 |
-
"text": "How
|
252 |
-
"options": [
|
253 |
-
"Highly alert, notices everything immediately",
|
254 |
-
"Alert, notices most things quickly",
|
255 |
-
"Moderately alert, notices things with some delay",
|
256 |
-
"Slightly alert, slow to notice surroundings",
|
257 |
-
"Not alert, seems confused or disoriented"
|
258 |
-
]
|
259 |
-
},
|
260 |
-
{
|
261 |
-
"id": "alert_commands",
|
262 |
-
"text": "How well does your dog respond to commands or their name?",
|
263 |
-
"options": [
|
264 |
-
"Responds immediately to name/commands",
|
265 |
-
"Usually responds quickly to name/commands",
|
266 |
-
"Sometimes responds, may need repetition",
|
267 |
-
"Often doesn't respond, needs multiple attempts",
|
268 |
-
"Rarely or never responds to name/commands"
|
269 |
-
]
|
270 |
-
},
|
271 |
-
{
|
272 |
-
"id": "alert_focus",
|
273 |
-
"text": "How focused is your dog during training or play?",
|
274 |
"options": [
|
275 |
-
"Highly
|
276 |
-
"Good
|
277 |
-
"
|
278 |
-
"
|
279 |
-
"
|
280 |
]
|
281 |
}
|
282 |
],
|
@@ -532,7 +444,7 @@ def compute_vision_quality(img: Image.Image):
|
|
532 |
logger.error(f"Error in quality computation: {e}")
|
533 |
return 0.5 # Default medium quality
|
534 |
|
535 |
-
# ======
|
536 |
|
537 |
def analyze_medical_image(img: Image.Image):
|
538 |
health_conditions = [
|
@@ -658,50 +570,30 @@ def score_from_response(response, score_mapping):
|
|
658 |
return 50
|
659 |
|
660 |
def calculate_hrqol_scores(hrqol_responses):
|
661 |
-
"""Convert
|
662 |
|
663 |
score_mapping = {
|
664 |
-
"excellent": 100, "very good": 80, "good": 60, "fair": 40, "poor": 20
|
665 |
-
"always": 100, "often": 80, "sometimes": 60, "rarely": 40, "never": 20,
|
666 |
-
"immediate": 100, "quick": 80, "moderate": 60, "slow": 40, "no response": 20,
|
667 |
-
"completely": 100, "mostly": 80, "some": 60, "frequently": 40, "severe": 20,
|
668 |
-
"very positive": 100, "mostly positive": 80, "neutral": 60, "mostly negative": 40, "very negative": 20,
|
669 |
-
"highly": 100, "well": 80, "moderately": 60, "minimally": 40, "not": 20
|
670 |
}
|
671 |
|
672 |
domain_scores = {}
|
673 |
|
674 |
-
#
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
score_from_response(hrqol_responses.get("vitality_response", ""), score_mapping)
|
679 |
-
]
|
680 |
-
domain_scores["vitality"] = np.mean(vitality_scores)
|
681 |
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
100 - score_from_response(hrqol_responses.get("comfort_pain_frequency", ""), score_mapping),
|
686 |
-
score_from_response(hrqol_responses.get("comfort_impact", ""), score_mapping)
|
687 |
-
]
|
688 |
-
domain_scores["comfort"] = max(0, np.mean(comfort_scores))
|
689 |
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
100 - score_from_response(hrqol_responses.get("emotion_anxiety", ""), score_mapping),
|
694 |
-
score_from_response(hrqol_responses.get("emotion_engagement", ""), score_mapping)
|
695 |
-
]
|
696 |
-
domain_scores["emotional_wellbeing"] = max(0, np.mean(emotion_scores))
|
697 |
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
score_from_response(hrqol_responses.get("alert_commands", ""), score_mapping),
|
702 |
-
score_from_response(hrqol_responses.get("alert_focus", ""), score_mapping)
|
703 |
-
]
|
704 |
-
domain_scores["alertness"] = np.mean(alertness_scores)
|
705 |
|
706 |
return domain_scores
|
707 |
|
@@ -787,7 +679,7 @@ def comprehensive_healthspan_analysis(input_type, image_input, video_input, bree
|
|
787 |
yield "β **Error**: Please complete the HRQOL questionnaire before analysis."
|
788 |
return
|
789 |
|
790 |
-
# Build HRQOL responses dictionary
|
791 |
response_keys = []
|
792 |
for domain_key, domain_data in HRQOL_QUESTIONNAIRE.items():
|
793 |
for question in domain_data["questions"]:
|
@@ -887,7 +779,7 @@ def comprehensive_healthspan_analysis(input_type, image_input, video_input, bree
|
|
887 |
<div style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 1000px; margin: 0 auto;">
|
888 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; border-radius: 15px; margin: 20px 0; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
889 |
<h2 style="margin: 0; font-size: 2em; text-shadow: 1px 1px 2px rgba(0,0,0,0.3);">{input_type_icon} Enhanced Multi-Modal Health Assessment</h2>
|
890 |
-
<div style="font-size: 1.1em; margin: 10px 0; opacity: 0.9;">Analysis Type: {input_type} |
|
891 |
<div style="font-size: 3em; font-weight: bold; margin: 15px 0; text-shadow: 2px 2px 4px rgba(0,0,0,0.3);">{final_healthspan_score:.1f}/100</div>
|
892 |
<div style="font-size: 1.2em; background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; display: inline-block;">{get_healthspan_grade(final_healthspan_score)}</div>
|
893 |
</div>
|
@@ -912,7 +804,7 @@ def comprehensive_healthspan_analysis(input_type, image_input, video_input, bree
|
|
912 |
|
913 |
report_html += "</div>"
|
914 |
|
915 |
-
# Enhanced Visual Analysis section
|
916 |
if breed_info:
|
917 |
uncertainty_info = ""
|
918 |
if breed_info.get('high_uncertainty', False):
|
@@ -940,7 +832,7 @@ def comprehensive_healthspan_analysis(input_type, image_input, video_input, bree
|
|
940 |
gait_factor = confidence_factors.get('gait_factor', 0)
|
941 |
|
942 |
factors_info = f"""<div style="background: #f8f9fa; border-radius: 8px; padding: 10px; margin: 10px 0;">
|
943 |
-
<p style="margin: 5px 0; font-size: 0.9em; color: #555;"><strong>
|
944 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ Visual Health Factor: {visual_health.get('age_factor', 0):.2f}</p>
|
945 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ HRQOL Adjustment: {hrqol_factor:.2f}</p>
|
946 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ Gait Factor: {gait_factor:.2f}</p>
|
@@ -1029,12 +921,11 @@ def comprehensive_healthspan_analysis(input_type, image_input, video_input, bree
|
|
1029 |
<div style="background: #F5F5F5; border: 1px solid #E0E0E0; padding: 20px; border-radius: 8px; margin: 20px 0;">
|
1030 |
<p style="margin: 0; font-size: 0.9em; color: #424242; line-height: 1.5;">
|
1031 |
<strong style="color: #D32F2F;">β οΈ Important Disclaimer:</strong>
|
1032 |
-
This analysis uses enhanced AI models with improved biological age prediction
|
1033 |
-
|
1034 |
-
Always consult with a qualified veterinarian for professional medical advice and diagnosis.
|
1035 |
</p>
|
1036 |
<p style="margin: 10px 0 0 0; font-size: 0.8em; color: #666;">
|
1037 |
-
<strong>Enhanced Features:</strong>
|
1038 |
</p>
|
1039 |
</div>
|
1040 |
</div>
|
@@ -1049,7 +940,7 @@ def update_media_input(input_type):
|
|
1049 |
else: # Video Analysis
|
1050 |
return gr.update(visible=False), gr.update(visible=True)
|
1051 |
|
1052 |
-
# Custom CSS for enhanced styling
|
1053 |
custom_css = """
|
1054 |
/* Enhanced gradient background */
|
1055 |
.gradio-container {
|
@@ -1137,7 +1028,7 @@ custom_css = """
|
|
1137 |
}
|
1138 |
"""
|
1139 |
|
1140 |
-
# Gradio Interface with Enhanced UI
|
1141 |
with gr.Blocks(
|
1142 |
title="πΆ Enhanced AI Dog Health Analyzer",
|
1143 |
theme=gr.themes.Soft(),
|
@@ -1151,7 +1042,7 @@ with gr.Blocks(
|
|
1151 |
π Enhanced AI Dog Health & Aging Analyzer
|
1152 |
</h1>
|
1153 |
<p style="margin: 15px 0 0 0; font-size: 1.2em; opacity: 0.9;">
|
1154 |
-
Enhanced Biological Age Prediction β’ Multi-Factor Analysis
|
1155 |
</p>
|
1156 |
</div>
|
1157 |
""")
|
@@ -1223,15 +1114,15 @@ with gr.Blocks(
|
|
1223 |
maximum=25
|
1224 |
)
|
1225 |
|
1226 |
-
# Right Column -
|
1227 |
with gr.Column(scale=1):
|
1228 |
gr.HTML("""
|
1229 |
<div class="questionnaire-card">
|
1230 |
<h2 style="color: #667eea; margin: 0 0 10px 0; text-align: center;">
|
1231 |
-
π HRQOL Assessment
|
1232 |
</h2>
|
1233 |
<p style="text-align: center; color: #666; font-style: italic; margin-bottom: 20px;">
|
1234 |
-
Complete all
|
1235 |
</p>
|
1236 |
</div>
|
1237 |
""")
|
|
|
49 |
medical_model = clip_model
|
50 |
MEDICAL_MODEL_AVAILABLE = False
|
51 |
|
52 |
+
# Stanford Dogs & lifespans
|
53 |
STANFORD_BREEDS = [
|
54 |
"afghan hound", "african hunting dog", "airedale", "american staffordshire terrier",
|
55 |
"appenzeller", "australian terrier", "basenji", "basset", "beagle",
|
|
|
120 |
"wire-haired fox terrier": 13.5, "yorkshire terrier": 13.3
|
121 |
}
|
122 |
|
123 |
+
# SHORTENED HRQOL Questionnaire - One comprehensive question per domain
|
124 |
HRQOL_QUESTIONNAIRE = {
|
125 |
"vitality": {
|
126 |
"title": "π Vitality & Energy Assessment",
|
127 |
+
"description": "Evaluate your dog's overall energy and responsiveness",
|
128 |
"questions": [
|
129 |
{
|
130 |
+
"id": "vitality_comprehensive",
|
131 |
+
"text": "How would you rate your dog's overall vitality considering energy levels, playfulness, and responsiveness to exciting activities?",
|
132 |
"options": [
|
133 |
+
"Excellent - Very energetic, always seeks play, immediate enthusiastic responses",
|
134 |
+
"Very Good - Generally energetic, often seeks play, quick positive responses",
|
135 |
+
"Good - Moderate energy, sometimes seeks play, moderate response time",
|
136 |
+
"Fair - Lower energy, rarely seeks play, slow or delayed responses",
|
137 |
+
"Poor - Very low energy, never seeks play, no response or negative reactions"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
]
|
139 |
}
|
140 |
],
|
|
|
142 |
},
|
143 |
"comfort": {
|
144 |
"title": "π Comfort & Pain Management",
|
145 |
+
"description": "Assess overall comfort and mobility",
|
146 |
"questions": [
|
147 |
{
|
148 |
+
"id": "comfort_comprehensive",
|
149 |
+
"text": "How would you assess your dog's overall comfort considering activity comfort, pain frequency, and impact on daily life?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
"options": [
|
151 |
+
"Excellent - Completely comfortable in all activities, never shows pain, no impact on daily life",
|
152 |
+
"Very Good - Mostly comfortable with minor adjustments, rarely shows pain, minimal impact",
|
153 |
+
"Good - Some discomfort in certain activities, occasional pain signs, moderate activity modifications",
|
154 |
+
"Fair - Frequently uncomfortable, often shows pain, significant activity limitations",
|
155 |
+
"Poor - Severe discomfort in most activities, daily pain signs, major activity restrictions"
|
156 |
]
|
157 |
}
|
158 |
],
|
|
|
160 |
},
|
161 |
"emotional_wellbeing": {
|
162 |
"title": "π Emotional Wellbeing",
|
163 |
+
"description": "Evaluate mood, stress levels, and social engagement",
|
164 |
"questions": [
|
165 |
{
|
166 |
+
"id": "emotional_comprehensive",
|
167 |
+
"text": "How would you describe your dog's overall emotional state considering mood, stress/anxiety levels, and family engagement?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
"options": [
|
169 |
+
"Excellent - Very positive mood, never shows stress, highly engaged with family activities",
|
170 |
+
"Very Good - Mostly positive mood, rarely shows stress, well engaged with family",
|
171 |
+
"Good - Generally neutral mood, sometimes shows stress, moderately engaged when invited",
|
172 |
+
"Fair - Often subdued mood, frequently shows stress, minimally engaged with encouragement",
|
173 |
+
"Poor - Negative/depressed mood, constantly stressed, avoids family activities"
|
174 |
]
|
175 |
}
|
176 |
],
|
|
|
178 |
},
|
179 |
"alertness": {
|
180 |
"title": "π§ Alertness & Cognition",
|
181 |
+
"description": "Assess cognitive function and awareness",
|
182 |
"questions": [
|
183 |
{
|
184 |
+
"id": "alertness_comprehensive",
|
185 |
+
"text": "How would you rate your dog's overall cognitive function considering awareness, command response, and focus during activities?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
"options": [
|
187 |
+
"Excellent - Highly alert and aware, responds immediately to commands, maintains excellent focus",
|
188 |
+
"Very Good - Alert and notices things quickly, usually responds quickly, good focus with occasional distraction",
|
189 |
+
"Good - Moderately alert with some delay, sometimes needs repetition, moderate focus with difficulty concentrating",
|
190 |
+
"Fair - Slightly alert and slow to notice, often needs multiple attempts, poor focus and easily distracted",
|
191 |
+
"Poor - Not alert or confused, rarely responds to commands, cannot maintain attention or focus"
|
192 |
]
|
193 |
}
|
194 |
],
|
|
|
444 |
logger.error(f"Error in quality computation: {e}")
|
445 |
return 0.5 # Default medium quality
|
446 |
|
447 |
+
# ====== EXISTING FUNCTIONS (UNCHANGED) ======
|
448 |
|
449 |
def analyze_medical_image(img: Image.Image):
|
450 |
health_conditions = [
|
|
|
570 |
return 50
|
571 |
|
572 |
def calculate_hrqol_scores(hrqol_responses):
|
573 |
+
"""Convert comprehensive HRQOL responses to 0-100 domain scores"""
|
574 |
|
575 |
score_mapping = {
|
576 |
+
"excellent": 100, "very good": 80, "good": 60, "fair": 40, "poor": 20
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
579 |
domain_scores = {}
|
580 |
|
581 |
+
# Each domain now has one comprehensive question
|
582 |
+
domain_scores["vitality"] = score_from_response(
|
583 |
+
hrqol_responses.get("vitality_comprehensive", ""), score_mapping
|
584 |
+
)
|
|
|
|
|
|
|
585 |
|
586 |
+
domain_scores["comfort"] = score_from_response(
|
587 |
+
hrqol_responses.get("comfort_comprehensive", ""), score_mapping
|
588 |
+
)
|
|
|
|
|
|
|
|
|
589 |
|
590 |
+
domain_scores["emotional_wellbeing"] = score_from_response(
|
591 |
+
hrqol_responses.get("emotional_comprehensive", ""), score_mapping
|
592 |
+
)
|
|
|
|
|
|
|
|
|
593 |
|
594 |
+
domain_scores["alertness"] = score_from_response(
|
595 |
+
hrqol_responses.get("alertness_comprehensive", ""), score_mapping
|
596 |
+
)
|
|
|
|
|
|
|
|
|
597 |
|
598 |
return domain_scores
|
599 |
|
|
|
679 |
yield "β **Error**: Please complete the HRQOL questionnaire before analysis."
|
680 |
return
|
681 |
|
682 |
+
# Build HRQOL responses dictionary - Updated for shortened questionnaire
|
683 |
response_keys = []
|
684 |
for domain_key, domain_data in HRQOL_QUESTIONNAIRE.items():
|
685 |
for question in domain_data["questions"]:
|
|
|
779 |
<div style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 1000px; margin: 0 auto;">
|
780 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; border-radius: 15px; margin: 20px 0; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
781 |
<h2 style="margin: 0; font-size: 2em; text-shadow: 1px 1px 2px rgba(0,0,0,0.3);">{input_type_icon} Enhanced Multi-Modal Health Assessment</h2>
|
782 |
+
<div style="font-size: 1.1em; margin: 10px 0; opacity: 0.9;">Analysis Type: {input_type} | Streamlined HRQOL Assessment</div>
|
783 |
<div style="font-size: 3em; font-weight: bold; margin: 15px 0; text-shadow: 2px 2px 4px rgba(0,0,0,0.3);">{final_healthspan_score:.1f}/100</div>
|
784 |
<div style="font-size: 1.2em; background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; display: inline-block;">{get_healthspan_grade(final_healthspan_score)}</div>
|
785 |
</div>
|
|
|
804 |
|
805 |
report_html += "</div>"
|
806 |
|
807 |
+
# Enhanced Visual Analysis section
|
808 |
if breed_info:
|
809 |
uncertainty_info = ""
|
810 |
if breed_info.get('high_uncertainty', False):
|
|
|
832 |
gait_factor = confidence_factors.get('gait_factor', 0)
|
833 |
|
834 |
factors_info = f"""<div style="background: #f8f9fa; border-radius: 8px; padding: 10px; margin: 10px 0;">
|
835 |
+
<p style="margin: 5px 0; font-size: 0.9em; color: #555;"><strong>Analysis Factors:</strong></p>
|
836 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ Visual Health Factor: {visual_health.get('age_factor', 0):.2f}</p>
|
837 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ HRQOL Adjustment: {hrqol_factor:.2f}</p>
|
838 |
<p style="margin: 2px 0; font-size: 0.8em; color: #666;">β’ Gait Factor: {gait_factor:.2f}</p>
|
|
|
921 |
<div style="background: #F5F5F5; border: 1px solid #E0E0E0; padding: 20px; border-radius: 8px; margin: 20px 0;">
|
922 |
<p style="margin: 0; font-size: 0.9em; color: #424242; line-height: 1.5;">
|
923 |
<strong style="color: #D32F2F;">β οΈ Important Disclaimer:</strong>
|
924 |
+
This analysis uses enhanced AI models with improved biological age prediction and streamlined HRQOL assessment.
|
925 |
+
Results are for educational purposes only. Always consult with a qualified veterinarian for professional medical advice and diagnosis.
|
|
|
926 |
</p>
|
927 |
<p style="margin: 10px 0 0 0; font-size: 0.8em; color: #666;">
|
928 |
+
<strong>Enhanced Features:</strong> Comprehensive 4-question HRQOL assessment, multi-factor age prediction, uncertainty quantification
|
929 |
</p>
|
930 |
</div>
|
931 |
</div>
|
|
|
940 |
else: # Video Analysis
|
941 |
return gr.update(visible=False), gr.update(visible=True)
|
942 |
|
943 |
+
# Custom CSS for enhanced styling
|
944 |
custom_css = """
|
945 |
/* Enhanced gradient background */
|
946 |
.gradio-container {
|
|
|
1028 |
}
|
1029 |
"""
|
1030 |
|
1031 |
+
# Gradio Interface with Enhanced UI
|
1032 |
with gr.Blocks(
|
1033 |
title="πΆ Enhanced AI Dog Health Analyzer",
|
1034 |
theme=gr.themes.Soft(),
|
|
|
1042 |
π Enhanced AI Dog Health & Aging Analyzer
|
1043 |
</h1>
|
1044 |
<p style="margin: 15px 0 0 0; font-size: 1.2em; opacity: 0.9;">
|
1045 |
+
Streamlined HRQOL Assessment β’ Enhanced Biological Age Prediction β’ Multi-Factor Analysis
|
1046 |
</p>
|
1047 |
</div>
|
1048 |
""")
|
|
|
1114 |
maximum=25
|
1115 |
)
|
1116 |
|
1117 |
+
# Right Column - SHORTENED HRQOL Questionnaire
|
1118 |
with gr.Column(scale=1):
|
1119 |
gr.HTML("""
|
1120 |
<div class="questionnaire-card">
|
1121 |
<h2 style="color: #667eea; margin: 0 0 10px 0; text-align: center;">
|
1122 |
+
π Streamlined HRQOL Assessment
|
1123 |
</h2>
|
1124 |
<p style="text-align: center; color: #666; font-style: italic; margin-bottom: 20px;">
|
1125 |
+
Complete all 4 comprehensive questions for accurate healthspan analysis
|
1126 |
</p>
|
1127 |
</div>
|
1128 |
""")
|