import gradio as gr import spaces # Africa Science AI Demo — HIV Funding + AMR Classifier # AutoScientist Challenge 2026, Part 2 | Science Category # Author: Hussein Adeiza (mabera) — Licensed Environmental Health Officer, Abuja Nigeria # ══════════════════════════════════════════════════════════ # ── HIV Funding & Response Interpreter ────────────────────── # ══════════════════════════════════════════════════════════ HIV_EXAMPLES = { "Regional donor dependency split (West/Central vs East/Southern Africa)": { "stats": "Donors cover approximately 90 percent of antiretroviral (ARV) drug costs in West and Central Africa, compared to approximately 38 percent in East and Southern Africa. Several high-burden East and Southern African countries are almost entirely dependent on PEPFAR specifically for HIV prevention programs: Malawi at 88.5 percent, Zimbabwe at 82.7 percent, and Mozambique at 81.8 percent. By contrast, South Africa, Botswana, Kenya, and Namibia each rely on PEPFAR for below 25 percent of their prevention funding.", "interpretation": "The regional split matters more than the continental average suggests: West and Central Africa's near-total donor dependency for treatment costs (90 percent) means any disruption there would affect ongoing ARV supply directly, while East and Southern Africa's lower regional average for treatment (38 percent) masks enormous country-level variance specifically in prevention funding, where Malawi, Zimbabwe, and Mozambique sit above 80 percent dependency while South Africa, Botswana, Kenya, and Namibia sit below 25 percent. A single continental narrative about 'Africa's HIV response' obscures two fundamentally different risk profiles." }, "The 2025 PrEP collapse and Nigeria's disproportionate hit": { "stats": "PrEP use across 62 reporting countries fell from 3.3 million people in 2024 to 2.1 million in 2025, a 38 percent decline, including in Nigeria, Cameroon, and Uganda. In Nigeria specifically, monthly PrEP initiations fell from approximately 40,000 to approximately 6,000 following budget cuts, an 85 percent reduction. Meanwhile, the DREAMS programme, which had targeted 2 million adolescent girls and young women across 10 countries for HIV prevention, halted entirely in all 10 countries.", "interpretation": "The gap between the 38 percent multi-country PrEP decline and Nigeria's 85 percent collapse in monthly initiations suggests Nigeria's prevention infrastructure was disproportionately exposed compared to the average reporting country. The complete halt of DREAMS across all 10 countries, rather than a partial reduction, indicates this was a program entirely dependent on a single funding source with no domestic or alternative donor bridge in place." }, "Mozambique: a real, measured case study": { "stats": "In Mozambique, where PEPFAR has funded roughly two-thirds of the national HIV program for over a decade, comparing February to May 2025 against the same period in 2024 shows more than 15,000 fewer people started antiretroviral treatment, a 14 percent reduction. Viral load testing fell 38 percent in adults and 44 percent in children, while viral suppression rates among those tested fell 33 percent in adults and 43 percent in children.", "interpretation": "The consistent pattern of children being harder hit than adults across both viral load testing and viral suppression suggests pediatric HIV services in Mozambique were more concentrated in the disrupted funding stream than adult services. This four-month snapshot from a single country provides a concrete, measured example of what larger continental modeling projections describe in the abstract." }, "2030 modeling: why treatment funding matters as much as prevention": { "stats": "Modeling presented at the 2025 International AIDS Society Conference projected two scenarios through 2030. A moderate scenario, with prevention and testing funding cut by 24 percent by 2026 but treatment sustained by domestic funding, would result in 71,500 to 1.7 million additional new HIV infections. A severe scenario, adding full PEPFAR discontinuation, would result in 4.4 million to 10.8 million additional new infections.", "interpretation": "The roughly 6-fold jump in the upper-bound infection estimate between the moderate and severe scenarios is not proportional to the funding change, since the severe scenario only adds full PEPFAR discontinuation on top of the same prevention cuts. This indicates that treatment funding, not just prevention funding, plays an outsized protective role against new infections." }, "The resilience counter-narrative: treatment held, prevention didn't": { "stats": "Despite the 2025 funding disruptions, the number of people on antiretroviral treatment globally rose 2.7 percent year-on-year to 32.1 million by December 2025, though below the roughly 4 percent historical average. Domestic funding's share of total HIV resources in low and middle-income countries rose to approximately 52 percent in 2024, up from 28 percent in 2010.", "interpretation": "The continued growth in treatment numbers despite the funding shock indicates the treatment system had more built-in resilience than the prevention system. Domestic funding growth, while a genuine long-term positive trend, is not currently happening at a scale capable of substituting for the 2025 funding shock." }, } @spaces.GPU def interpret_hiv_stats(selected_example, custom_stats): if custom_stats and custom_stats.strip(): return f""" ## 🌍 HIV Funding & Response Interpretation **Input stats:** {custom_stats} **Note:** This is a demo using pre-built reference interpretations. Try a dropdown example for a real cited interpretation. --- *Africa HIV Funding Analysis Model — Fine-tuned Llama 4 Scout 17B-16E | AutoScientist 2026 Part 2* """ example = HIV_EXAMPLES.get(selected_example, list(HIV_EXAMPLES.values())[0]) return f""" ## 🌍 HIV Funding & Response Interpretation **Raw cited statistics (input):** {example['stats']} **Structured public health interpretation (output):** {example['interpretation']} --- ### ⚠️ Important Disclosure This dataset was intended for Science but the platform's classifier tagged it News/Governance, routing training to Llama 4 Scout 17B-16E rather than Llama 3.3 70B. Reported to Adaption before publishing. Win rate 71% on dataset, 60% General Win Rate (News-domain benchmark). Full disclosure in the model card. *Africa HIV Funding Analysis Model — Fine-tuned Llama 4 Scout 17B-16E | AutoScientist 2026 | Science Category* *Powered by Adaptive Data — Adaption Labs* """ # ══════════════════════════════════════════════════════════ # ── AMR Closed-Label Classifier ────────────────────────────── # ══════════════════════════════════════════════════════════ BREAKPOINTS = { "Enterobacterales / Ampicillin": {"s_max": 8, "i_val": 16, "r_min": 32}, "Enterobacterales / Ceftriaxone": {"s_max": 1, "i_val": 2, "r_min": 4}, "Enterobacterales / Ciprofloxacin": {"s_max": 0.25, "i_val": 0.5, "r_min": 1}, "Enterobacterales / Meropenem": {"s_max": 1, "i_val": 2, "r_min": 4}, "Enterobacterales / Gentamicin": {"s_max": 4, "i_val": 8, "r_min": 16}, "Staphylococcus aureus / Oxacillin (MRSA screen)": {"s_max": 2, "i_val": None, "r_min": 4}, "Enterobacterales / Colistin (no S category)": {"s_max": None, "i_val": 2, "r_min": 4}, } @spaces.GPU def classify_mic(organism_antibiotic, mic_value): bp = BREAKPOINTS.get(organism_antibiotic) if bp is None or mic_value is None: return "Please select a valid organism/antibiotic combination and enter a MIC value." mic = float(mic_value) if bp["s_max"] is not None and mic <= bp["s_max"]: result, color = "Susceptible", "🟢" elif bp["r_min"] is not None and mic >= bp["r_min"]: result, color = "Resistant", "🔴" else: result, color = "Intermediate", "🟡" s_str = f"≤{bp['s_max']}" if bp["s_max"] is not None else "none (no S category)" i_str = f"{bp['i_val']}" if bp["i_val"] is not None else "none (no I category)" r_str = f"≥{bp['r_min']}" if bp["r_min"] is not None else "n/a" return f""" ## {color} Classification: {result} **Your input:** {organism_antibiotic}, MIC = {mic} ug/mL **CLSI M100 (2025) breakpoints applied:** - Susceptible: {s_str} - Intermediate: {i_str} - Resistant: {r_str} This classification was computed live from your input against the real CLSI breakpoint registry, the same deterministic logic used to build and verify every row in the training dataset. --- *Nigeria AMR Classifier v2 — Fine-tuned Llama 3.3 70B | AutoScientist 2026 | Science Category* """ @spaces.GPU def classify_rate(n_tested, n_nonsusceptible): if not n_tested or n_tested <= 0: return "Please enter a valid number of isolates tested (must be greater than 0)." if n_nonsusceptible is None or n_nonsusceptible < 0: return "Please enter a valid number of non-susceptible isolates." if n_nonsusceptible > n_tested: return "Non-susceptible count cannot exceed the number tested." rate = round((n_nonsusceptible / n_tested) * 100, 1) if rate < 20: level, color = "Low", "🟢" elif rate <= 50: level, color = "Moderate", "🟡" else: level, color = "High", "🔴" return f""" ## {color} Resistance Rate: {rate}% — {level} Resistance **Calculation:** {int(n_nonsusceptible)} / {int(n_tested)} isolates × 100 = {rate}% **Classification thresholds:** Low (<20%), Moderate (20-50%), High (>50%) This is the exact calculation method used to build and verify all 28 national surveillance rows in the training dataset, each independently recomputed against Nigeria's real MAAP/Fleming Fund surveillance report. --- *Nigeria AMR Classifier v2 — Fine-tuned Llama 3.3 70B | AutoScientist 2026 | Science Category* """ # ══════════════════════════════════════════════════════════ # ── Build Interface ───────────────────────────────────────── # ══════════════════════════════════════════════════════════ with gr.Blocks(title="Africa Science AI") as demo: gr.Markdown(""" # 🌍🧫 Africa Science AI Demo ## AutoScientist Challenge 2026, Part 2 | Science Category **Author:** Hussein Adeiza (mabera) — Licensed Environmental Health Officer, Abuja Nigeria **Two models:** HIV Funding Analysis (Llama 4 Scout) + AMR Classifier v2 (Llama 3.3 70B) **Powered by Adaptive Data — Adaption Labs** """) with gr.Tabs(): with gr.Tab("🌍 HIV Funding & Response Interpreter"): gr.Markdown("### Raw HIV funding and epidemiological stats in, structured public health interpretation out") gr.Markdown("⚠️ Built on real, cited UNAIDS, IAS 2025, Health Policy Watch, and CNBC Africa reporting.") with gr.Row(): with gr.Column(): hiv_example = gr.Dropdown( choices=list(HIV_EXAMPLES.keys()), value=list(HIV_EXAMPLES.keys())[0], label="Select a real cited finding" ) hiv_custom = gr.Textbox( label="Or paste your own HIV funding/epidemiological stats (demo mode)", placeholder="e.g. PrEP use fell from N to N between year and year...", lines=2 ) hiv_btn = gr.Button("🌍 Interpret HIV Funding Data", variant="primary") with gr.Column(): hiv_output = gr.Markdown() hiv_btn.click(interpret_hiv_stats, inputs=[hiv_example, hiv_custom], outputs=hiv_output) with gr.Tab("🧪 AMR: MIC → Susceptibility Classification"): gr.Markdown("### Enter a real MIC value and see the CLSI-based classification computed live") gr.Markdown("⚠️ Closed-label classification: results are deterministically computed, not generated.") with gr.Row(): with gr.Column(): mic_organism = gr.Dropdown( choices=list(BREAKPOINTS.keys()), value=list(BREAKPOINTS.keys())[0], label="Organism / Antibiotic" ) mic_value = gr.Number(label="Measured MIC (ug/mL)", value=0.5, precision=3) mic_btn = gr.Button("🧪 Classify", variant="primary") with gr.Column(): mic_output = gr.Markdown() mic_btn.click(classify_mic, inputs=[mic_organism, mic_value], outputs=mic_output) with gr.Tab("📊 AMR: Surveillance Rate Classification"): gr.Markdown("### Enter isolate counts and see the resistance rate computed live") with gr.Row(): with gr.Column(): n_tested = gr.Number(label="Isolates tested (N)", value=2528, precision=0) n_nonsusceptible = gr.Number(label="Non-susceptible isolates (n)", value=1766, precision=0) rate_btn = gr.Button("📊 Calculate Rate", variant="primary") with gr.Column(): rate_output = gr.Markdown() rate_btn.click(classify_rate, inputs=[n_tested, n_nonsusceptible], outputs=rate_output) gr.Markdown(""" --- ### Models — Open Source | Model | Category | Win Rate | Quality | Note | |-------|----------|----------|---------|------| | HIV Funding Analysis (Llama 4 Scout) | Science | 71% (60% general) | 6.0→6.5, Grade C | Domain classification issue disclosed | | AMR Classifier v2 (Llama 3.3 70B) | Science | 58% (71% general) | 8.0→8.7, Grade B | 34/34 rows verified | 🤗 [HIV Model](https://huggingface.co/mabera/africa-hiv-funding-analysis-model) | 🤗 [AMR Model](https://huggingface.co/mabera/nigeria-amr-classifier-v2) | 🤗 [HIV Dataset](https://huggingface.co/datasets/mabera/africa-hiv-funding-dataset) | 🤗 [AMR Dataset](https://huggingface.co/datasets/mabera/nigeria-amr-classifier-v2-dataset) ### Other Portfolio Demos - Part 1 (Healthcare, Legal, Marketing, Finance, Language): [nigeria-health-ai-demo](https://huggingface.co/spaces/mabera/nigeria-health-ai-demo) - Part 2 Agriculture: [nigeria-agriculture-ai](https://huggingface.co/spaces/mabera/nigeria-agriculture-ai) """) demo.launch(theme=gr.themes.Soft())