File size: 102,289 Bytes
e76c748 58c82c7 e76c748 4c008dc e76c748 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 a24c66c 58c82c7 4c008dc 58c82c7 4c008dc a24c66c 4c008dc a24c66c 58c82c7 4c008dc a24c66c 58c82c7 a24c66c 58c82c7 4c008dc a24c66c 58c82c7 a24c66c 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 4c008dc a24c66c 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 e76c748 4c008dc 58c82c7 e76c748 58c82c7 a24c66c 58c82c7 e76c748 4c008dc eb9d9f8 4c008dc 58c82c7 e76c748 a24c66c 4c008dc e76c748 58c82c7 a24c66c 58c82c7 e76c748 58c82c7 e76c748 4c008dc e76c748 58c82c7 e76c748 58c82c7 e76c748 a24c66c e76c748 a24c66c e76c748 58c82c7 4c008dc a24c66c 58c82c7 4c008dc e76c748 58c82c7 4c008dc 58c82c7 4c008dc 58c82c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 | import json
from pathlib import Path
from typing import Any
import numpy as np
from PIL import Image
import tensorflow as tf
from .config import CLASS_MAP_PATH, IMAGE_SIZE, MODEL_PATH, OOD_THRESHOLD, TOP_K_DEFAULT
_model = None
_idx_to_class: dict[str, str] | None = None
# ── Label helpers ─────────────────────────────────────────────────────────────
def _prettify(label: str) -> str:
return label.replace("___", " - ").replace("_", " ")
def _split_label(label: str) -> tuple[str, str]:
parts = label.split("___", 1)
if len(parts) == 2:
return parts[0], parts[1]
return label, "unknown"
# ── Full 58-class disease database ───────────────────────────────────────────
# Keyed by the exact class-map label (e.g. "Tomato___Early_blight").
# Lookup is O(1) and covers every class the model can predict.
# Previously only 4 diseases were covered; all other classes returned
# generic placeholder text. Now all 58 classes return rich English + Urdu data.
_DISEASES_DB: dict = {
"Apple___Apple_scab": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Apple Scab",
"description": "A very common fungal disease caused by Venturia inaequalis. It's most visible in spring and early summer, causing dark, velvety spots to appear on leaves and fruit.",
"description_ur": "ایک عام فنگل بیماری جو وینٹوریا انایکوالیس کی وجہ سے ہوتی ہے۔ یہ موسم بہار اور گرمیوں کے شروع میں پتوں اور پھلوں پر سیاہ دھبوں کی صورت میں ظاہر ہوتی ہے۔",
"causes": ["Fungus overwinters on fallen leaves", "Spore spread by rain and wind"],
"causes_ur": ["فنگس گرے ہوئے پتوں پر زندہ رہتی ہے", "بارش اور ہوا سے جراثیم پھیلتے ہیں"],
"cure": "Use fungicide sprays from leaf emergence until early summer.",
"cure_ur": "موسم بہار سے گرمیوں کے شروع تک فنگس کش سپرے کا استعمال کریں۔",
"prevention": "Rake and destroy fallen leaves. Choose scab-resistant varieties.",
"prevention_ur": "گرے ہوئے پتوں کو اکٹھا کر کے تلف کر دیں۔ بیماری کے خلاف مدافعت رکھنے والی اقسام لگائیں۔",
"severity": "Moderate",
"organic_remedies": "Lime sulfur or sulfur sprays.",
"organic_remedies_ur": "لائم سلفر یا سلفر سپرے۔",
"fertilizer": "Autumn application of zinc sulfate and urea foliar spray.",
"fertilizer_ur": "خزاں میں زنک سلفیٹ اور یوریا کا سپرے کریں۔",
"weather_advice": "Thrives in cool, wet weather. Plan sprays before wet periods.",
"weather_advice_ur": "ٹھنڈے اور گیلے موسم میں پھیلتی ہے۔ بارش سے پہلے حفاظتی سپرے کریں۔",
},
"Apple___Black_rot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Apple Black Rot",
"description": "Affects leaves, fruit, and bark. Leaves show 'frog-eye' spots. Fruit shows firm black rot starting at blossom end.",
"description_ur": "یہ پتوں، پھلوں اور چھال کو متاثر کرتی ہے۔ پتوں پر مینڈک کی آنکھ جیسے دھبے بن جاتے ہیں اور پھل سیاہ ہو کر سڑ جاتا ہے۔",
"causes": ["Fungus overwinters in cankers and mummified fruit", "Enters through bark wounds"],
"causes_ur": ["فنگس چھال کے زخموں اور خشک پھلوں میں رہتی ہے", "چھال کے زخموں کے ذریعے داخل ہوتی ہے"],
"cure": "Prune infected branches 20-30cm below canker. Remove mummified fruit.",
"cure_ur": "متاثرہ شاخوں کو 20-30 سینٹی میٹر نیچے سے کاٹ دیں۔ خشک پھل ہٹا دیں۔",
"prevention": "Sanitation (rake leaves/fruit), control bark-damaging insects.",
"prevention_ur": "صفائی کا خیال رکھیں، چھال کو نقصان پہنچانے والے کیڑوں کو کنٹرول کریں۔",
"severity": "High",
"organic_remedies": "Strict hygiene and fixed copper fungicides.",
"organic_remedies_ur": "سخت صفائی اور کاپر فنگسائیڈز کا استعمال۔",
"fertilizer": "Avoid over-fertilizing with nitrogen; apply balanced early spring feed.",
"fertilizer_ur": "نائٹروجن کا زیادہ استعمال نہ کریں؛ بہار کے شروع میں متوازن کھاد دیں۔",
"weather_advice": "Favored by high temperatures (around 26°C) and periods of rain.",
"weather_advice_ur": "زیادہ درجہ حرارت (تقریبا 26 ڈگری) اور بارش میں پھیلتی ہے۔",
},
"Apple___Cedar_apple_rust": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Cedar Apple Rust",
"description": "Unique fungal disease needing both apple and juniper (cedar) to survive. Causes bright yellow-orange spots on apple leaves.",
"description_ur": "ایک منفرد فنگل بیماری جسے زندہ رہنے کے لیے سیب اور جونیپر دونوں کی ضرورت ہوتی ہے۔ سیب کے پتوں پر چمکدار پیلے نارنجی دھبے بناتی ہے۔",
"causes": ["Fungus overwinters on junipers", "Spores blown from juniper to apple"],
"causes_ur": ["فنگس جونیپر کے درختوں پر سردیاں گزارتی ہے", "ہوا کے ذریعے جراثیم جونیپر سے سیب تک پہنچتے ہیں"],
"cure": "Fungicides required at 'pink' bud stage through early cover sprays.",
"cure_ur": "شگوفے نکلنے کے مرحلے پر فنگس کش ادویات کا استعمال ضروری ہے۔",
"prevention": "Avoid planting junipers and apples near each other. Prune galls from junipers.",
"prevention_ur": "سیب اور جونیپر کے درختوں کو ایک دوسرے کے قریب نہ لگائیں۔",
"severity": "Moderate",
"organic_remedies": "None effective currently.",
"organic_remedies_ur": "فی الحال کوئی نامیاتی علاج موثر نہیں ہے۔",
"fertilizer": "Balanced, slow-release fertilizer to maintain tree vigor.",
"fertilizer_ur": "درخت کی طاقت برقرار رکھنے کے لیے متوازن کھاد استعمال کریں۔",
"weather_advice": "Spring rain causes orange tendrils on junipers to release spores.",
"weather_advice_ur": "موسم بہار کی بارش جراثیم پھیلانے کا باعث بنتی ہے۔",
},
"Apple___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Healthy apple tree with vibrant green foliage and no signs of pests or disease.",
"description_ur": "سیب کا صحت مند درخت جس کے پتے سبز اور چمکدار ہیں اور بیماری کی کوئی علامت نہیں ہے۔",
"causes": ["Proper care", "Resistant varieties", "Optimal environment"],
"causes_ur": ["مناسب دیکھ بھال", "مضبوط اقسام", "بہترین ماحول"],
"cure": "Annual pruning in late winter while dormant.",
"cure_ur": "سردیوں کے آخر میں باقاعدہ کانٹ چھانٹ کریں۔",
"prevention": "Plant in sunny, well-drained location.",
"prevention_ur": "دھوپ والی اور اچھی نکاسی والی جگہ پر لگائیں۔",
"severity": "Healthy",
"organic_remedies": "Yearly layer of compost or well-rotted manure.",
"organic_remedies_ur": "ہر سال کمپوسٹ یا گوبر کی کھاد ڈالیں۔",
"fertilizer": "Balanced 10-10-10 fertilizer in early spring.",
"fertilizer_ur": "بہار کے شروع میں 10-10-10 کھاد ڈالیں۔",
"weather_advice": "Mature trees need 2.5 cm water per week.",
"weather_advice_ur": "بڑے درختوں کو ہفتے میں ڈھائی سینٹی میٹر پانی کی ضرورت ہوتی ہے۔",
},
"Blueberry___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Healthy blueberry bush with bright green leaves and vigorous growth.",
"description_ur": "نیل کنٹھی (بلوبیری) کا صحت مند پودا جس کی نشوونما بہترین ہے۔",
"causes": ["Acidic soil (pH 4.0-5.2)", "Consistent moisture"],
"causes_ur": ["تیزابی مٹی", "مستقل نمی"],
"cure": "Ensure soil pH stays between 4.0 and 5.2.",
"cure_ur": "مٹی کی تیزابیت برقرار رکھیں۔",
"prevention": "Mulch annually with pine needles or wood chips.",
"prevention_ur": "لکڑی کے برادے یا سوئیوں سے ملچنگ کریں۔",
"severity": "Healthy",
"organic_remedies": "Compost as top dressing in spring.",
"organic_remedies_ur": "بہار میں اوپر سے کمپوسٹ ڈالیں۔",
"fertilizer": "Acid-loving plant fertilizer after flowering.",
"fertilizer_ur": "پھول آنے کے بعد تیزابیت والی کھاد دیں۔",
"weather_advice": "Need 2-4 cm water weekly; shallow roots require consistent moisture.",
"weather_advice_ur": "ہفتہ وار 2-4 سینٹی میٹر پانی دیں؛ جڑیں کم گہری ہوتی ہیں۔",
},
"Cherry_(including_sour)___Powdery_mildew": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Cherry Powdery Mildew",
"description": "White, powdery coating on young leaves and sometimes fruit. Leaves may distort and curl.",
"description_ur": "نئے پتوں اور کبھی پھلوں پر سفید پاؤڈر جیسی تہہ جم جاتی ہے۔ پتے مڑ سکتے ہیں۔",
"causes": ["Warm, dry days with cool, humid nights", "High humidity"],
"causes_ur": ["گرم دن اور ٹھنڈی مرطوب راتیں", "زیادہ نمی"],
"cure": "Preventive fungicides from early season. Potassium bicarbonate for organic.",
"cure_ur": "سیزن کے شروع میں حفاظتی فنگس کش ادویات استعمال کریں۔",
"prevention": "Full sun, open canopy pruning, avoid excess nitrogen.",
"prevention_ur": "مکمل دھوپ، کانٹ چھانٹ، اور زیادہ نائٹروجن سے گریز کریں۔",
"severity": "Moderate",
"organic_remedies": "Potassium bicarbonate spray (Kaligreen).",
"organic_remedies_ur": "پوٹاشیم بائیکاربونیٹ سپرے۔",
"fertilizer": "Avoid excess; use slow-release fertilizer.",
"fertilizer_ur": "زیادہ کھاد سے بچیں؛ آہستہ اثر کرنے والی کھاد دیں۔",
"weather_advice": "Doesn't need rain; humidity is enough to spread.",
"weather_advice_ur": "بارش کی ضرورت نہیں؛ صرف نمی ہی پھیلانے کے لیے کافی ہے۔",
},
"Cherry_(including_sour)___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Lush green leaves, strong structure, and abundant fruit.",
"description_ur": "سبز پتے، مضبوط ڈھانچہ اور بھرپور پھل والا صحت مند چیری کا درخت۔",
"causes": ["Site selection", "Consistent care", "Open center pruning"],
"causes_ur": ["بہترین جگہ کا انتخاب", "مستقل دیکھ بھال"],
"cure": "Regular pruning to maintain open center shape.",
"cure_ur": "درمیانی حصہ کھلا رکھنے کے لیے باقاعدہ کٹائی کریں۔",
"prevention": "Plant in sunny, well-drained location.",
"prevention_ur": "دھوپ والی اور اچھی نکاسی والی جگہ پر لگائیں۔",
"severity": "Healthy",
"organic_remedies": "Compost or manure around base each spring.",
"organic_remedies_ur": "ہر بہار میں جڑ کے پاس کمپوسٹ ڈالیں۔",
"fertilizer": "Balanced 10-10-10 once in early spring.",
"fertilizer_ur": "بہار کے شروع میں 10-10-10 کھاد ڈالیں۔",
"weather_advice": "Water young trees regularly; mature trees drought tolerant.",
"weather_advice_ur": "نئے پودوں کو باقاعدگی سے پانی دیں؛ بڑے پودے خشک سالی برداشت کر سکتے ہیں۔",
},
"Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Gray Leaf Spot",
"description": "Yield-limiting disease with long, narrow, light-brown to gray lesions on leaves.",
"description_ur": "پتوں پر لمبے، تنگ اور بھورے یا سرمئی نشانات بن جاتے ہیں جو پیداوار کم کر دیتے ہیں۔",
"causes": ["Survives in residue", "Warm humid conditions", "Leaf wetness"],
"causes_ur": ["فصل کی باقیات میں فنگس", "گرم اور مرطوب حالات"],
"cure": "Foliar fungicides (pyraclostrobin, azoxystrobin).",
"cure_ur": "پتوں پر فنگس کش اسپرے کریں۔",
"prevention": "Crop rotation, tillage to bury residue, resistant hybrids.",
"prevention_ur": "فصلوں کی تبدیلی اور باقیات کو مٹی میں دبانا۔",
"severity": "High",
"organic_remedies": "Crop rotation and resistant varieties.",
"organic_remedies_ur": "فصلوں کی تبدیلی اور بیماری کے خلاف مدافعت والی اقسام۔",
"fertilizer": "Balanced fertility program based on soil test.",
"fertilizer_ur": "مٹی کے ٹیسٹ کی بنیاد پر متوازن کھاد دیں۔",
"weather_advice": "Requires 12+ hours of leaf wetness to develop.",
"weather_advice_ur": "پتوں پر 12 گھنٹے سے زیادہ نمی رہنے سے پھیلتی ہے۔",
},
"Corn_(maize)___Common_rust_": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Common Corn Rust",
"description": "Powdery, cinnamon-brown pustules on both leaf surfaces. Spores carried by wind.",
"description_ur": "پتوں کی دونوں سطحوں پر دار چینی کے رنگ کے پاؤڈر جیسے دھبے بن جاتے ہیں۔",
"causes": ["Wind-blown spores", "Moist cool temperatures", "High humidity"],
"causes_ur": ["ہوا سے پھیلنے والے جراثیم", "ٹھنڈا اور مرطوب موسم"],
"cure": "Resistant hybrids. Fungicides if severe.",
"cure_ur": "مدافعتی اقسام استعمال کریں؛ شدید صورت میں فنگس کش سپرے کریں۔",
"prevention": "Resistant hybrids are the best defense.",
"prevention_ur": "بیماری کے خلاف مدافعت والی اقسام بہترین بچاؤ ہیں۔",
"severity": "Moderate",
"organic_remedies": "None highly effective; focus on resistant hybrids.",
"organic_remedies_ur": "مدافعتی اقسام پر توجہ دیں؛ کوئی خاص نامیاتی علاج نہیں۔",
"fertilizer": "Avoid excessive nitrogen to prevent lush, susceptible growth.",
"fertilizer_ur": "زیادہ نائٹروجن سے گریز کریں تاکہ پودا نرم اور حساس نہ ہو۔",
"weather_advice": "Favored by cool, moist conditions. Hot dry weather stops it.",
"weather_advice_ur": "ٹھنڈے اور مرطوب موسم میں پھیلتی ہے؛ گرم خشک موسم میں رک جاتی ہے۔",
},
"Corn_(maize)___Northern_Leaf_Blight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Northern Corn Leaf Blight",
"description": "Long, elliptical grayish-green or tan 'cigar-shaped' lesions.",
"description_ur": "پتوں پر لمبے، بیضوی اور سرمئی یا بھورے 'سگار کی شکل' کے نشانات بنتے ہیں۔",
"causes": ["Survives in residue", "Wind and rain splash spread"],
"causes_ur": ["فصل کی باقیات", "ہوا اور بارش سے پھیلاؤ"],
"cure": "Resistant hybrids. Fungicides like pyraclostrobin if severe.",
"cure_ur": "مدافعتی اقسام اور فنگس کش ادویات کا استعمال کریں۔",
"prevention": "Rotate crops and bury crop residue.",
"prevention_ur": "فصلیں بدل کر لگائیں اور باقیات کو دفن کریں۔",
"severity": "High",
"organic_remedies": "Crop rotation and tillage.",
"organic_remedies_ur": "فصلوں کی تبدیلی اور ہل چلا کر صفائی۔",
"fertilizer": "Ensure adequate potassium for disease resistance.",
"fertilizer_ur": "بیماریوں کے خلاف مدافعت کے لیے پوٹاشیم کا استعمال یقینی بنائیں۔",
"weather_advice": "Favored by cool temps (18-27°C) and high humidity.",
"weather_advice_ur": "ٹھنڈے درجہ حرارت (18-27 ڈگری) اور زیادہ نمی میں پھیلتی ہے۔",
},
"Corn_(maize)___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Tall, thick stalk, dark green leaves, and well-filled ears.",
"description_ur": "مضبوط تنا اور سبز پتوں والا صحت مند مکئی کا پودا۔",
"causes": ["Good genetics", "Proper management", "Watering"],
"causes_ur": ["بہترین بیج", "اچھی دیکھ بھال"],
"cure": "Consistent watering (2.5 cm/week), especially during tasseling.",
"cure_ur": "ہفتہ وار ڈھائی سینٹی میٹر پانی دیں، خاص طور پر سٹا بنتے وقت۔",
"prevention": "Well-drained soil (pH 5.8-6.8), weed regularly.",
"prevention_ur": "مناسب مٹی اور جڑی بوٹیوں کی صفائی۔",
"severity": "Healthy",
"organic_remedies": "Side-dress with compost when knee-high.",
"organic_remedies_ur": "جب پودے گھٹنے تک ہوں تو کمپوسٹ ڈالیں۔",
"fertilizer": "Balanced NPK at planting; side-dress with nitrogen later.",
"fertilizer_ur": "بوائی پر این پی کے اور بعد میں نائٹروجن دیں۔",
"weather_advice": "Critical water need during flowering and grain fill.",
"weather_advice_ur": "پھول اور دانے بننے کے دوران پانی بہت ضروری ہے۔",
},
"Grape___Black_rot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Grape Black Rot",
"description": "Destructive disease making berries black, shriveled, and hard (mummies).",
"description_ur": "انگور کے دانے سیاہ ہو کر سوکھ جاتے ہیں اور پتھر کی طرح سخت ہو جاتے ہیں۔",
"causes": ["Overwinters in infected berries/leaves", "Warm wet weather"],
"causes_ur": ["انفیکشن والی باقیات", "گرم اور گیلا موسم"],
"cure": "Fungicide program from 10-15 cm shoot length (copper-based).",
"cure_ur": "شاخیں نکلتے ہی کاپر والی فنگس کش ادویات کا سپرے کریں۔",
"prevention": "Prune for air circulation, remove mummies, bury debris.",
"prevention_ur": "ہوا کے لیے کٹائی کریں، خشک انگور ہٹائیں اور صفائی رکھیں۔",
"severity": "High",
"organic_remedies": "Copper-based fungicides like Bordeaux mixture.",
"organic_remedies_ur": "بورڈو مکسچر یا کاپر سپرے۔",
"fertilizer": "Avoid over-fertilizing with nitrogen.",
"fertilizer_ur": "زیادہ نائٹروجن سے گریز کریں۔",
"weather_advice": "Thrives in warm, humid conditions with rain.",
"weather_advice_ur": "گرم، مرطوب اور بارش والے موسم میں تیزی سے پھیلتی ہے۔",
},
"Grape___Esca_(Black_Measles)": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Esca (Black Measles)",
"description": "Complex trunk disease causing decline in vigor and leaf scorching.",
"description_ur": "تنے کی بیماری جس سے پودا کمزور ہو جاتا ہے اور پتے جھلس جاتے ہیں۔",
"causes": ["Xylem-inhabiting fungi", "Spread via infected cuttings/wounds"],
"causes_ur": ["فنگس جو تنے کے اندر رہتی ہے", "زخموں کے ذریعے پھیلاؤ"],
"cure": "No cure. Remove and destroy infected vines. Seal pruning wounds.",
"cure_ur": "کوئی علاج نہیں؛ متاثرہ بیل کو جلا دیں اور کٹائی کے زخموں پر سیلنٹ لگائیں۔",
"prevention": "Use certified disease-free stock, late pruning strategy.",
"prevention_ur": "بیماری سے پاک پودے لگائیں اور سیزن کے آخر میں کٹائی کریں۔",
"severity": "Critical",
"organic_remedies": "None; focus on prevention and sanitation.",
"organic_remedies_ur": "کوئی نامیاتی علاج نہیں؛ صرف صفائی ہی حل ہے۔",
"fertilizer": "Maintain vine health via proper fertilization and irrigation.",
"fertilizer_ur": "مناسب کھاد اور پانی سے پودے کو مضبوط رکھیں۔",
"weather_advice": "Wet conditions promote spore production.",
"weather_advice_ur": "گیلے حالات جراثیم بننے میں مدد دیتے ہیں۔",
},
"Grape___Leaf_blight_(Isariopsis_Leaf_Spot)": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Grape Leaf Blight",
"description": "Irregular brown spots on leaves; can cause severe defoliation.",
"description_ur": "پتوں پر بے ترتیب بھورے دھبے جو پتوں کے گرنے کا سبب بن سکتے ہیں۔",
"causes": ["Fungus survives on leaf litter", "Warm humid weather"],
"causes_ur": ["گرے ہوئے پتوں میں فنگس", "گرم مرطوب موسم"],
"cure": "Preventative fungicide sprays (copper-based or mancozeb).",
"cure_ur": "کاپر سپرے یا مینکوزیب کا استعمال کریں۔",
"prevention": "Prune for air circulation, rake and destroy fallen leaves.",
"prevention_ur": "ہوا کی آمد و رفت بہتر کریں اور گرے ہوئے پتے تلف کریں۔",
"severity": "Moderate",
"organic_remedies": "Copper-based fungicides or Bordeaux mixture.",
"organic_remedies_ur": "کاپر سپرے یا بورڈو مکسچر۔",
"fertilizer": "Balanced, non-excessive fertilization.",
"fertilizer_ur": "متوازن کھاد کا استعمال کریں۔",
"weather_advice": "Most active after rain events.",
"weather_advice_ur": "بارش کے بعد یہ بیماری زیادہ سرگرم ہوتی ہے۔",
},
"Grape___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Sturdy trunk, lush green leaves, and abundant clusters.",
"description_ur": "مضبوط تنا اور سبز پتوں والی صحت مند انگور کی بیل۔",
"causes": ["Proper pruning", "Sunlight", "Consistent care"],
"causes_ur": ["مناسب کٹائی", "دھوپ", "دیکھ بھال"],
"cure": "Annual dormant pruning in late winter.",
"cure_ur": "سردیوں کے آخر میں باقاعدہ کٹائی کریں۔",
"prevention": "Full sun and good air circulation.",
"prevention_ur": "مکمل دھوپ اور ہوا والی جگہ پر لگائیں۔",
"severity": "Healthy",
"organic_remedies": "Dormant oil spray in early spring.",
"organic_remedies_ur": "بہار کے شروع میں آئل سپرے کریں۔",
"fertilizer": "Balanced 10-10-10 in early spring.",
"fertilizer_ur": "بہار کے شروع میں 10-10-10 کھاد ڈالیں۔",
"weather_advice": "Water deeply during dry periods; new vines need 2.5 cm/week.",
"weather_advice_ur": "خشک موسم میں گہرا پانی دیں؛ نئے پودوں کو زیادہ ضرورت ہوتی ہے۔",
},
"Mango___Anthracnose": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Anthracnose",
"description": "Widespread disease causing black spots on flowers, leaves, and fruit.",
"description_ur": "پھولوں، پتوں اور پھلوں پر سیاہ دھبے بن جاتے ہیں جس سے پھل سڑ جاتا ہے۔",
"causes": ["Warm, humid, rainy conditions", "Present on dead twigs"],
"causes_ur": ["گرم، مرطوب اور بارش والا موسم", "خشک شاخوں میں فنگس"],
"cure": "Prune for airy canopy. Copper-based sprays during bloom.",
"cure_ur": "ہوا کے لیے کٹائی کریں؛ بور پر کاپر سپرے کریں۔",
"prevention": "Select resistant varieties, remove dead twigs and infected fruit.",
"prevention_ur": "بیماری سے پاک اقسام لگائیں اور خشک شاخیں ہٹا دیں۔",
"severity": "High",
"organic_remedies": "Preventive copper-based sprays and good sanitation.",
"organic_remedies_ur": "کاپر سپرے اور درخت کی صفائی۔",
"fertilizer": "Avoid high nitrogen which encourages susceptible growth.",
"fertilizer_ur": "زیادہ نائٹروجن سے گریز کریں تاکہ پودا کمزور نہ ہو۔",
"weather_advice": "Most severe during warm wet periods.",
"weather_advice_ur": "بارش اور گرمی میں یہ زیادہ نقصان دہ ہے۔",
},
"Mango___Bacterial_Canker": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Bacterial Canker",
"description": "Raised, angular, black lesions on leaves and fruit. Fruit can crack.",
"description_ur": "پتوں اور پھلوں پر ابھرے ہوئے سیاہ دھبے بنتے ہیں اور پھل پھٹ سکتا ہے۔",
"causes": ["Wind-driven rain", "Contaminated equipment", "Bacteria enters wounds"],
"causes_ur": ["تیز ہوا اور بارش", "گندی مشینری یا اوزار"],
"cure": "No cure. Prune and destroy infected branches. Copper sprays reduce spread.",
"cure_ur": "کوئی مستقل علاج نہیں؛ متاثرہ شاخیں جلا دیں اور کاپر سپرے کریں۔",
"prevention": "Disease-free nursery stock, sterilized pruning tools.",
"prevention_ur": "بیماری سے پاک پودے اور اوزاروں کو جراثیم سے پاک رکھیں۔",
"severity": "Critical",
"organic_remedies": "Rigorous sanitation and removal of infected material.",
"organic_remedies_ur": "سخت صفائی اور متاثرہ حصوں کا خاتمہ۔",
"fertilizer": "Balanced nutrition to keep trees healthy.",
"fertilizer_ur": "درخت کی صحت کے لیے متوازن کھاد دیں۔",
"weather_advice": "Favored by warm, wet, and windy weather.",
"weather_advice_ur": "گرم، گیلے اور طوفانی موسم میں پھیلتی ہے۔",
},
"Mango___Cutting_Weevil": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Leaf-Cutting Weevil",
"description": "Adults cut and roll young leaves; larvae feed inside. Severe damage to new growth.",
"description_ur": "بالغ سنڈی نئے پتے کاٹتی ہے اور انہیں رول بنا دیتی ہے جس میں بچے پلتے ہیں۔",
"causes": ["Pest active during rainy periods", "Adults cut leaves"],
"causes_ur": ["بارش کے دوران کیڑا زیادہ سرگرم ہوتا ہے"],
"cure": "Spray insecticides (chlorpyrifos or dimethoate).",
"cure_ur": "کیڑے مار ادویات (کلورپائیریفوس وغیرہ) کا سپرے کریں۔",
"prevention": "Hand-pick rolled leaves to kill larvae. Rake fallen leaves.",
"prevention_ur": "رول ہوئے پتوں کو ہاتھ سے توڑ کر تلف کریں؛ گرے پتے ہٹا دیں۔",
"severity": "Moderate",
"organic_remedies": "Neem seed kernel extract spray.",
"organic_remedies_ur": "نیم کے بیجوں کے تیل کا سپرے۔",
"fertilizer": "Maintain tree vigor with good fertilization.",
"fertilizer_ur": "کھاد کے ذریعے درخت کو طاقتور رکھیں۔",
"weather_advice": "Most active May-October, influenced by rain.",
"weather_advice_ur": "مئی سے اکتوبر تک زیادہ سرگرم ہوتا ہے۔",
},
"Mango___Die_Back": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Dieback",
"description": "Wilting and yellowing leaves followed by death of twigs/branches.",
"description_ur": "پتے پیلے ہو کر مرجھا جاتے ہیں اور شاخیں سوکھنا شروع ہو جاتی ہیں۔",
"causes": ["Fungal pathogens", "Enters through bark wounds"],
"causes_ur": ["فنگل بیماری", "زخموں کے ذریعے داخل ہوتی ہے"],
"cure": "Prune and burn infected twigs well below disease. Use Bordeaux mixture.",
"cure_ur": "متاثرہ شاخیں نیچے سے کاٹ کر جلا دیں؛ بورڈو مکسچر لگائیں۔",
"prevention": "Avoid unnecessary bark wounds, keep tree stress-free.",
"prevention_ur": "چھال کو زخمی ہونے سے بچائیں اور درخت کو کمزور نہ ہونے دیں۔",
"severity": "Critical",
"organic_remedies": "Remove and destroy infected wood; copper spray on wounds.",
"organic_remedies_ur": "متاثرہ لکڑی کا خاتمہ اور کاپر سپرے۔",
"fertilizer": "Proper nutrition and watering to improve resistance.",
"fertilizer_ur": "مدافعت بڑھانے کے لیے اچھی خوراک اور پانی دیں۔",
"weather_advice": "Water stress (drought) predisposes trees to dieback.",
"weather_advice_ur": "پانی کی کمی (خشک سالی) اس بیماری کو دعوت دیتی ہے۔",
},
"Mango___Gall_Midge": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Gall Midge",
"description": "Small flies lay eggs in leaves causing pimple-like growths (galls).",
"description_ur": "چھوٹی مکھیاں پتوں میں انڈے دیتی ہیں جس سے پھنسیوں جیسے نشانات بنتے ہیں۔",
"causes": ["Midge flies lay eggs in tissue", "Larvae feeding stimulates gall growth"],
"causes_ur": ["مکھیوں کا پتوں میں انڈے دینا"],
"cure": "Insecticide like bifenthrin for severe cases. Hand-pick for light cases.",
"cure_ur": "شدید صورت میں بائیفینتھرین سپرے کریں؛ معمولی میں پتے توڑ دیں۔",
"prevention": "Encourage natural predators, monitor regularly, rake soil.",
"prevention_ur": "درخت کے نیچے مٹی کی گوڈی کریں اور باقاعدہ معائنہ کریں۔",
"severity": "Moderate",
"organic_remedies": "Neem seed kernel extract spray.",
"organic_remedies_ur": "نیم کا سپرے۔",
"fertilizer": "Adequate fertilizer and irrigation for tolerance.",
"fertilizer_ur": "درخت کی برداشت بڑھانے کے لیے کھاد اور پانی دیں۔",
"weather_advice": "Populations build up during rainy season.",
"weather_advice_ur": "بارشوں کے موسم میں کیڑوں کی تعداد بڑھتی ہے۔",
},
"Mango___Healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Full, open canopy, dark green leaves, and reliable crop.",
"description_ur": "سبز پتوں اور بہترین چھتری والا صحت مند آم کا درخت۔",
"causes": ["Proper variety", "Correct pruning", "Consistent care"],
"causes_ur": ["درست قسم", "باقاعدہ کٹائی", "مناسب دیکھ بھال"],
"cure": "Prune to shape tree and improve light/air flow after harvest.",
"cure_ur": "پھل اتارنے کے بعد درخت کی کٹائی کریں تاکہ ہوا اور روشنی مل سکے۔",
"prevention": "Full sun, well-drained soil, mulching.",
"prevention_ur": "مکمل دھوپ اور اچھی مٹی میں لگائیں۔",
"severity": "Healthy",
"organic_remedies": "Mulch heavily with wood chips; keep away from trunk.",
"organic_remedies_ur": "درخت کے گرد لکڑی کا برادہ یا ملچ ڈالیں۔",
"fertilizer": "Complete fertilizer in spring and after harvest.",
"fertilizer_ur": "بہار اور کٹائی کے بعد مکمل کھاد ڈالیں۔",
"weather_advice": "Drought-tolerant once established but needs water during bloom.",
"weather_advice_ur": "بڑا درخت خشک سالی برداشت کر لیتا ہے مگر بور کے وقت پانی ضروری ہے۔",
},
"Mango___Powdery_Mildew": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Powdery Mildew",
"description": "White powdery coating on flowers, young leaves, and fruit.",
"description_ur": "بور، پتوں اور پھلوں پر سفید پاؤڈر جیسی تہہ جم جاتی ہے۔",
"causes": ["Cool dry weather", "Spread by wind", "Bloom season is highest risk"],
"causes_ur": ["ٹھنڈا خشک موسم", "ہوا سے پھیلاؤ"],
"cure": "Apply registered fungicide from pre-bloom to fruit set.",
"cure_ur": "بور آنے سے پھل بننے تک فنگس کش ادویات کا سپرے کریں۔",
"prevention": "Choose less susceptible varieties, open canopy pruning.",
"prevention_ur": "کم حساس اقسام اور شاخوں کی کٹائی۔",
"severity": "High",
"organic_remedies": "Protective sprays of wettable sulfur before fungus is visible.",
"organic_remedies_ur": "بیماری آنے سے پہلے سلفر کا سپرے کریں۔",
"fertilizer": "Balanced fertilization; avoid high nitrogen.",
"fertilizer_ur": "متوازن کھاد دیں؛ زیادہ نائٹروجن سے بچیں۔",
"weather_advice": "Thrives in cool dry conditions; doesn't need rain to spread.",
"weather_advice_ur": "ٹھنڈے خشک موسم میں پھیلتی ہے؛ بارش کے بغیر بھی پھیل سکتی ہے۔",
},
"Mango___Sooty_Mould": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mango Sooty Mould",
"description": "Black powdery coating on leaves and fruit growing on insect honeydew.",
"description_ur": "پتوں اور پھلوں پر کالی کالک جم جاتی ہے جو کیڑوں کے فضلے پر پلتی ہے۔",
"causes": ["Sap-sucking insects (aphids/scale)", "Untreated insect problem"],
"causes_ur": ["تیلا، سست تیلا اور دیگر کیڑے"],
"cure": "Treat insects (aphids/scale). Wash mold with starch solution.",
"cure_ur": "پہلے کیڑوں کا علاج کریں؛ کالک اتارنے کے لیے نشاستہ (سٹارچ) کا سپرے کریں۔",
"prevention": "Prune for air/light to reduce humid environments for pests.",
"prevention_ur": "ہوا اور روشنی کا انتظام کریں تاکہ کیڑے کم ہوں۔",
"severity": "Moderate",
"organic_remedies": "Insecticidal soap, neem oil, or horticultural oil.",
"organic_remedies_ur": "نیم کا تیل یا جراثیم کش صابن کا محلول۔",
"fertilizer": "Avoid over-fertilizing with nitrogen.",
"fertilizer_ur": "زیادہ نائٹروجن نہ ڈالیں کیونکہ کیڑے اس سے زیادہ آتے ہیں۔",
"weather_advice": "Hot dry conditions can increase sap-sucking insects.",
"weather_advice_ur": "گرم اور خشک موسم میں یہ کیڑے زیادہ حملہ کرتے ہیں۔",
},
"Orange___Haunglongbing_(Citrus_greening)": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Citrus Greening (HLB)",
"description": "Small, lopsided, bitter fruit. Most devastating citrus disease; kills the tree.",
"description_ur": "پھل چھوٹے، بد شکل اور کڑوے ہو جاتے ہیں۔ یہ مالٹے کی سب سے خطرناک بیماری ہے۔",
"causes": ["Asian citrus psyllid (insect vector)", "Liberibacter bacterium"],
"causes_ur": ["سائٹرس سائیلا (ایک چھوٹا کیڑا)"],
"cure": "No cure. Remove and destroy tree to prevent spread.",
"cure_ur": "کوئی علاج نہیں؛ بیماری پھیلنے سے روکنے کے لیے درخت جڑ سے اکھاڑ دیں۔",
"prevention": "Certified disease-free trees, psyllid control (soaps/oils).",
"prevention_ur": "بیماری سے پاک پودے لگائیں اور سائیلا کیڑے کو کنٹرول کریں۔",
"severity": "Critical",
"organic_remedies": "None; focus on psyllid control and tree removal.",
"organic_remedies_ur": "صرف کیڑے کو مارنا اور بیمار درخت ہٹانا ہی حل ہے۔",
"fertilizer": "No fertilizer cure; infected trees will decline.",
"fertilizer_ur": "کھاد سے اس کا علاج نہیں ہو سکتا۔",
"weather_advice": "Psyllids more active in warm weather.",
"weather_advice_ur": "گرم موسم میں کیڑا زیادہ تیزی سے پھیلتا ہے۔",
},
"Orange___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Glossy deep green leaves and abundance of juicy fruit.",
"description_ur": "سبز چمکدار پتوں اور رس بھرے پھلوں والا صحت مند مالٹے کا درخت۔",
"causes": ["Site selection", "Well-drained soil", "Consistent routine"],
"causes_ur": ["بہترین جگہ", "اچھی مٹی", "باقاعدہ دیکھ بھال"],
"cure": "Full sun and well-drained soil. Water deeply every 2-3 weeks.",
"cure_ur": "مکمل دھوپ اور اچھی مٹی؛ ہر دو تین ہفتے بعد گہرا پانی دیں۔",
"prevention": "Keep area clear of grass/weeds. Minimal pruning needed.",
"prevention_ur": "درخت کے نیچے صفائی رکھیں اور جڑی بوٹیاں نکالیں۔",
"severity": "Healthy",
"organic_remedies": "Compost or manure around drip line in spring.",
"organic_remedies_ur": "بہار میں گوبر کی کھاد یا کمپوسٹ ڈالیں۔",
"fertilizer": "Citrus-specific fertilizer 3 times a year (winter, spring, summer).",
"fertilizer_ur": "سال میں تین بار مالٹے کی مخصوص کھاد ڈالیں۔",
"weather_advice": "Protect young trees from frost. Sensitive to waterlogging.",
"weather_advice_ur": "چھوٹے پودوں کو کورے سے بچائیں؛ زیادہ پانی کھڑا نہ ہونے دیں۔",
},
"Peach___Bacterial_spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Bacterial Spot",
"description": "Reddish-purple water-soaked spots on leaves, fruit, and twigs. Causes holes in leaves.",
"description_ur": "پتوں اور پھلوں پر سرخ بھورے دھبے بن جاتے ہیں جو بعد میں سوراخ بن جاتے ہیں۔",
"causes": ["Bacterium overwinters in twig cankers", "Warm wet springs"],
"causes_ur": ["شاخوں میں جراثیم", "گرم اور گیلا موسم بہار"],
"cure": "Copper bactericide program starting early season.",
"cure_ur": "سیزن کے شروع میں کاپر والے جراثیم کش سپرے کریں۔",
"prevention": "Plant resistant varieties, prune for airy center.",
"prevention_ur": "مدافعتی اقسام لگائیں اور شاخوں کی کٹائی کریں۔",
"severity": "High",
"organic_remedies": "Fixed copper spray program.",
"organic_remedies_ur": "کاپر سپرے کا باقاعدہ پروگرام۔",
"fertilizer": "Moderate balanced feed; avoid high nitrogen.",
"fertilizer_ur": "متوازن کھاد دیں؛ زیادہ نائٹروجن سے پرہیز کریں۔",
"weather_advice": "Severe after wet spring, especially during 3 weeks post-petal fall.",
"weather_advice_ur": "پھول گرنے کے تین ہفتے بعد والا گیلا موسم خطرناک ہے۔",
},
"Peach___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Open branching, vibrant green leaves, and large juicy fruit.",
"description_ur": "مضبوط شاخوں اور سبز پتوں والا صحت مند آڑو کا درخت۔",
"causes": ["Good genetics", "Proper pruning", "Fruit thinning"],
"causes_ur": ["اچھی قسم", "درست کٹائی", "پھل کی چھدرائی"],
"cure": "Hard annual pruning (up to 40%) for open center vase shape.",
"cure_ur": "ہر سال سخت کٹائی کریں تاکہ درخت کا درمیانی حصہ کھلا رہے۔",
"prevention": "Thin excess fruit in early summer to prevent branch breakage.",
"prevention_ur": "گرمیوں میں فالتو پھل توڑ دیں تاکہ شاخیں نہ ٹوٹیں۔",
"severity": "Healthy",
"organic_remedies": "Dormant oil spray in late winter.",
"organic_remedies_ur": "سردیوں کے آخر میں آئل سپرے کریں۔",
"fertilizer": "Balanced 10-10-10 in early spring.",
"fertilizer_ur": "بہار کے شروع میں 10-10-10 کھاد ڈالیں۔",
"weather_advice": "Consistent moisture needed during fruit growing season.",
"weather_advice_ur": "پھل لگنے کے دوران پانی کا مستقل انتظام رکھیں۔",
},
"Pepper,_bell___Bacterial_spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Bacterial Spot",
"description": "Water-soaked spots on leaves turning brown. Raised scabby spots on fruit.",
"description_ur": "پتوں پر گیلے دھبے بنتے ہیں جو بھورے ہو جاتے ہیں؛ پھل پر کھردرے نشانات بنتے ہیں۔",
"causes": ["Warm humid wet environment", "Splashed by rain/watering"],
"causes_ur": ["گرم، مرطوب اور گیلا ماحول", "بارش یا اوپر سے پانی دینا"],
"cure": "Preventive copper bactericide spray program.",
"cure_ur": "کاپر والے جراثیم کش سپرے کریں۔",
"prevention": "Resistant varieties, crop rotation (2-3 years), avoid overhead water.",
"prevention_ur": "فصلوں کی تبدیلی اور پودے کے اوپر پانی دینے سے گریز کریں۔",
"severity": "High",
"organic_remedies": "Copper-based bactericides applied preventively.",
"organic_remedies_ur": "حفاظتی طور پر کاپر سپرے کا استعمال۔",
"fertilizer": "Balanced nutrition; avoid stress and high nitrogen.",
"fertilizer_ur": "متوازن خوراک دیں؛ نائٹروجن زیادہ نہ ہو۔",
"weather_advice": "Prevalent in wet seasons; bacteria needs free water to infect.",
"weather_advice_ur": "بارشوں کے سیزن میں زیادہ پھیلتی ہے؛ پتوں پر پانی اس کا سبب ہے۔",
},
"Pepper,_bell___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Compact but rugged, dark green leaves, and many peppers.",
"description_ur": "سبز پتوں اور بھرپور مرچوں والا صحت مند شملہ مرچ کا پودا۔",
"causes": ["Consistent watering", "Balanced feeding"],
"causes_ur": ["باقاعدہ پانی", "متوازن خوراک"],
"cure": "Consistent watering (2.5 cm/week); allow top soil to dry slightly.",
"cure_ur": "باقاعدگی سے پانی دیں؛ اگلی بار پانی سے پہلے مٹی تھوڑی خشک ہونے دیں۔",
"prevention": "Full sun, rich soil, mulch around base.",
"prevention_ur": "مکمل دھوپ، اچھی مٹی اور جڑوں کے پاس ملچنگ کریں۔",
"severity": "Healthy",
"organic_remedies": "Fish emulsion or compost tea every few weeks.",
"organic_remedies_ur": "ہر چند ہفتوں بعد کمپوسٹ چائے یا مچھلی کی کھاد دیں۔",
"fertilizer": "Blossom-booster formula once flowering starts.",
"fertilizer_ur": "پھول آنے پر فاسفورس والی کھاد دیں۔",
"weather_advice": "Water at base, not overhead; increase watering in hot weather.",
"weather_advice_ur": "پودے کی جڑ میں پانی دیں، اوپر نہیں؛ گرمی میں پانی بڑھا دیں۔",
},
"Potato___Early_blight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Potato Early Blight",
"description": "Dark brown spots with 'bullseye' concentric rings on older leaves.",
"description_ur": "پرانے پتوں پر بھورے دھبے بن جاتے ہیں جن کے اندر دائرے نظر آتے ہیں۔",
"causes": ["Fungus survives in debris", "Warm humid conditions", "Plant stress"],
"causes_ur": ["باقیات میں فنگس", "گرم مرطوب موسم", "پودے پر دباؤ"],
"cure": "Fixed copper fungicide or chlorothalonil starting at first sign.",
"cure_ur": "بیماری ظاہر ہوتے ہی کاپر فنگسائیڈ کا سپرے کریں۔",
"prevention": "Certified seed, crop rotation (2-3 years), remove end-season debris.",
"prevention_ur": "صاف بیج، فصلوں کی تبدیلی اور صفائی۔",
"severity": "Moderate",
"organic_remedies": "Fixed copper fungicides.",
"organic_remedies_ur": "کاپر فنگسائیڈز۔",
"fertilizer": "Balanced feed; avoid excess nitrogen; ensure adequate potassium.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں؛ پوٹاشیم کا استعمال بڑھائیں۔",
"weather_advice": "Favored by 24-29°C and frequent rain/heavy dew.",
"weather_advice_ur": "24-29 ڈگری اور زیادہ نمی میں پھیلتی ہے۔",
},
"Potato___Late_blight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Potato Late Blight",
"description": "Destructive disease causing brown spots and white fuzzy mildew. Rots tubers.",
"description_ur": "آلو کی سب سے خطرناک بیماری؛ پتے سڑ جاتے ہیں اور آلو بھی خراب ہو جاتے ہیں۔",
"causes": ["Survives in cull piles/volunteers", "Cool wet weather"],
"causes_ur": ["پرانی باقیات", "ٹھنڈا اور گیلا موسم"],
"cure": "Protective fungicides weekly. Remove and destroy infected plants immediately.",
"cure_ur": "ہفتہ وار حفاظتی سپرے کریں؛ بیمار پودے فوری اکھاڑ دیں۔",
"prevention": "Resistant varieties, certified seed, hilling up soil.",
"prevention_ur": "مدافعتی اقسام اور آلوؤں پر مٹی چڑھانا۔",
"severity": "Critical",
"organic_remedies": "Copper-based fungicides and rigorous sanitation.",
"organic_remedies_ur": "کاپر سپرے اور سخت صفائی۔",
"fertilizer": "Avoid over-fertilizing with nitrogen.",
"fertilizer_ur": "زیادہ نائٹروجن سے بچیں۔",
"weather_advice": "Active in cool (10-21°C), wet weather with long leaf wetness periods.",
"weather_advice_ur": "ٹھنڈے گیلے موسم (10-21 ڈگری) میں تیزی سے پھیلتی ہے۔",
},
"Potato___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Upright form, dark green leaves, high yield of clean tubers.",
"description_ur": "مضبوط قد اور سبز پتوں والے صحت مند آلو کے پودے۔",
"causes": ["High-quality seed", "Consistent care"],
"causes_ur": ["بہترین بیج", "باقاعدہ دیکھ بھال"],
"cure": "Consistent watering (2.5 cm/week) especially during tuber swelling.",
"cure_ur": "آلو بننے کے دوران ہفتہ وار ڈھائی سینٹی میٹر پانی دیں۔",
"prevention": "Hill soil up around base; keeps tubers clean and unexposed.",
"prevention_ur": "جڑوں کے گرد مٹی چڑھائیں تاکہ آلو دھوپ سے بچیں۔",
"severity": "Healthy",
"organic_remedies": "Compost or manure before planting.",
"organic_remedies_ur": "بوائی سے پہلے کمپوسٹ یا گوبر کی کھاد ڈالیں۔",
"fertilizer": "NPK ratio 1:1:2 is ideal; high potassium needed for tubers.",
"fertilizer_ur": "پوٹاشیم والی کھاد آلو کے لیے بہترین ہے۔",
"weather_advice": "Water in morning to allow leaves to dry.",
"weather_advice_ur": "صبح کے وقت پانی دیں تاکہ پتے سارا دن خشک رہیں۔",
},
"Raspberry___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Vigorous canes with bright green leaves and heavy berries.",
"description_ur": "سبز پتوں اور بہترین پھلوں والی صحت مند رس بھری (راسبیری)۔",
"causes": ["Correct seasonal pruning", "Well-drained soil"],
"causes_ur": ["موسمی کٹائی", "اچھی نکاسی والی مٹی"],
"cure": "Prune out canes that just produced fruit; leave new green ones.",
"cure_ur": "پھل دینے والی شاخیں کاٹ دیں اور نئی سبز شاخیں رہنے دیں۔",
"prevention": "Plant in full sun, provide trellis for support.",
"prevention_ur": "مکمل دھوپ اور شاخوں کے لیے سہارا دیں۔",
"severity": "Healthy",
"organic_remedies": "Thick layer of organic mulch to suppress weeds.",
"organic_remedies_ur": "جڑی بوٹیوں سے بچاؤ کے لیے موٹی ملچنگ کریں۔",
"fertilizer": "Balanced 5-10-5 early; avoid late nitrogen.",
"fertilizer_ur": "شروع میں 5-10-5 کھاد دیں؛ نائٹروجن دیر سے نہ دیں۔",
"weather_advice": "Shallow roots need consistent moisture (2-4 cm/week).",
"weather_advice_ur": "جڑیں کم گہری ہوتی ہیں، اس لیے مستقل نمی ضروری ہے۔",
},
"Rice___Bacterialblight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Bacterial Leaf Blight",
"description": "Yellow-orange water-soaked stripes on leaves leading to wilting.",
"description_ur": "پتوں پر پیلی نارنجی دھاریاں بنتی ہیں اور پودا مرجھا جاتا ہے۔",
"causes": ["Bacteria survive on stubble/soil", "High nitrogen rates"],
"causes_ur": ["فصل کی باقیات", "نائٹروجن کا زیادہ استعمال"],
"cure": "Copper-based fungicides. Destroy infected stubble after harvest.",
"cure_ur": "کاپر سپرے کریں اور کٹائی کے بعد مڈھیاں تلف کریں۔",
"prevention": "Resistant varieties, avoid high nitrogen, drain fields periodically.",
"prevention_ur": "مدافعتی اقسام، نائٹروجن میں کمی اور کھیت سے پانی نکالنا۔",
"severity": "High",
"organic_remedies": "Resistant varieties and balanced organic soil fertility.",
"organic_remedies_ur": "مدافعتی اقسام اور متوازن نامیاتی کھاد۔",
"fertilizer": "Avoid high rates of nitrogen which favor bacterial growth.",
"fertilizer_ur": "نائٹروجن زیادہ نہ ڈالیں کیونکہ اس سے جراثیم بڑھتے ہیں۔",
"weather_advice": "Severe in warm, humid, rainy conditions.",
"weather_advice_ur": "گرم، مرطوب اور بارش والے موسم میں زیادہ حملہ کرتی ہے۔",
},
"Rice___Blast": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Rice Blast",
"description": "Major disease affecting leaves and panicles (neck blast).",
"description_ur": "دھان کی بڑی بیماری جو پتوں اور سٹے (نییک بلاسٹ) کو متاثر کرتی ہے۔",
"causes": ["Overwinters on straw", "Warm temps and high humidity"],
"causes_ur": ["پرانی پرالی میں فنگس", "گرمی اور زیادہ نمی"],
"cure": "Fungicides (tricyclazole or isoprothiolane).",
"cure_ur": "ٹرائیسائیکلازول یا اسوپروتھیولین کا سپرے کریں۔",
"prevention": "Resistant varieties, balanced fertilizer, silicon application.",
"prevention_ur": "مدافعتی اقسام، متوازن کھاد اور سلیکون کا استعمال۔",
"severity": "Critical",
"organic_remedies": "Avoid over-fertilizing with nitrogen; use compost.",
"organic_remedies_ur": "نائٹروجن کے زیادہ استعمال سے بچیں اور کمپوسٹ دیں۔",
"fertilizer": "More severe when the plant has abundant nitrogen.",
"fertilizer_ur": "نائٹروجن کی زیادتی سے بیماری بڑھتی ہے۔",
"weather_advice": "Favored by night-time leaf wetness and high humidity.",
"weather_advice_ur": "رات کے وقت پتوں پر نمی اور زیادہ حبس میں پھیلتی ہے۔",
},
"Rice___Brownspot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Brown Spot",
"description": "Circular oval brown spots resembling sesame seeds on leaves.",
"description_ur": "پتوں پر تلوں کی طرح کے بھورے بیضوی دھبے بن جاتے ہیں۔",
"causes": ["Infected seed and debris", "Nutrient-deficient soils"],
"causes_ur": ["بیمار بیج", "خوراک کی کمی والی مٹی"],
"cure": "Certified seed, copper-based fungicides, or propiconazole.",
"cure_ur": "صاف بیج اور فنگس کش ادویات کا استعمال کریں۔",
"prevention": "Crop rotation, balanced fertilization (avoid potassium deficiency).",
"prevention_ur": "فصلوں کی تبدیلی اور پوٹاشیم کی کمی دور کریں۔",
"severity": "Moderate",
"organic_remedies": "Focus on crop rotation and organic soil fertility.",
"organic_remedies_ur": "فصلوں کی تبدیلی اور زمین کی زرخیزی پر توجہ دیں۔",
"fertilizer": "Sign of potassium deficiency; ensure adequate levels.",
"fertilizer_ur": "یہ پوٹاشیم کی کمی کی علامت ہے؛ اس کی کمی دور کریں۔",
"weather_advice": "High humidity and prolonged leaf wetness favor development.",
"weather_advice_ur": "زیادہ نمی اور پتوں کا دیر تک گیلا رہنا اس کا سبب ہے۔",
},
"Rice___Tungro": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Rice Tungro Disease",
"description": "Viral disease causing stunting and yellow-orange discoloration.",
"description_ur": "وائرل بیماری جس سے پودا چھوٹا رہ جاتا ہے اور پتے پیلے نارنجی ہو جاتے ہیں۔",
"causes": ["Transmitted by green leafhopper", "Virus complex"],
"causes_ur": ["سبز تیلا (لیف ہاپپر) اس وائرس کو پھیلاتا ہے"],
"cure": "No cure. Manage leafhopper vector using insecticides. Rogue infected plants.",
"cure_ur": "کوئی علاج نہیں؛ تیلے کو ماریں اور بیمار پودے نکال دیں۔",
"prevention": "Resistant varieties, synchronized planting in large areas.",
"prevention_ur": "مدافعتی اقسام اور پورے علاقے میں ایک ساتھ بوائی کریں۔",
"severity": "Critical",
"organic_remedies": "Encourage natural predators like spiders and damselflies.",
"organic_remedies_ur": "مکڑیوں اور دیگر شکاری کیڑوں کی حفاظت کریں۔",
"fertilizer": "Balanced fertilization to produce strong plants.",
"fertilizer_ur": "مضبوط پودوں کے لیے متوازن کھاد دیں۔",
"weather_advice": "Leafhoppers more active in warm, dry weather.",
"weather_advice_ur": "گرم اور خشک موسم میں تیلا زیادہ سرگرم ہوتا ہے۔",
},
"Rice___Healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Robust stalk, deep green color, and full plump grain heads.",
"description_ur": "مضبوط تنا، گہرا سبز رنگ اور بھرے ہوئے دانوں والا صحت مند دھان۔",
"causes": ["Good genetics", "Water management", "Balanced nutrition"],
"causes_ur": ["اچھا بیج", "پانی کا انتظام", "متوازن خوراک"],
"cure": "Intermittent irrigation (SRI methods) for deep root growth.",
"cure_ur": "جڑوں کی مضبوطی کے لیے وقفے وقفے سے پانی دیں۔",
"prevention": "Right variety selection and weed control.",
"prevention_ur": "درست قسم کا انتخاب اور جڑی بوٹیوں کی صفائی۔",
"severity": "Healthy",
"organic_remedies": "Incorporate well-decomposed compost before planting.",
"organic_remedies_ur": "بوائی سے پہلے اچھی طرح گلی سڑی کھاد ڈالیں۔",
"fertilizer": "Apply nitrogen, phosphorus, and potassium in splits.",
"fertilizer_ur": "نائٹروجن، فاسفورس اور پوٹاشیم قسطوں میں دیں۔",
"weather_advice": "Maintain shallow flood; rice needs consistent access to water.",
"weather_advice_ur": "کھیت میں ہلکا پانی رکھیں؛ چاول کو مستقل پانی چاہیے۔",
},
"Soybean___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Thick stem, trifoliate green leaves, pods filled with plump beans.",
"description_ur": "مضبوط تنا اور سبز پتوں والی صحت مند سویا بین کی فصل۔",
"causes": ["Genetics", "Nitrogen-fixing bacteria", "Correct pH"],
"causes_ur": ["بہترین بیج", "نائٹروجن بنانے والے بیکٹیریا"],
"cure": "Maintain consistent soil moisture especially during pod-filling.",
"cure_ur": "پھلیاں بننے کے دوران زمین میں نمی برقرار رکھیں۔",
"prevention": "Inoculate seed at planting; rotate crops.",
"prevention_ur": "بیج کو ٹیکہ لگائیں اور فصلیں بدل کر بوئیں۔",
"severity": "Healthy",
"organic_remedies": "Crop rotation with non-legumes.",
"organic_remedies_ur": "غیر پھلی دار فصلوں کے ساتھ ادل بدل کر کاشت کریں۔",
"fertilizer": "Requires little nitrogen; focus on phosphorus and potassium.",
"fertilizer_ur": "نائٹروجن کی کم ضرورت ہے؛ فاسفورس اور پوٹاشیم دیں۔",
"weather_advice": "Sensitive to water stress during reproductive stage.",
"weather_advice_ur": "پھول اور پھلیاں بننے کے دوران پانی کی کمی نہ ہونے دیں۔",
},
"Squash___Powdery_mildew": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Powdery Mildew",
"description": "White powdery spots on lower leaves covering entire plant.",
"description_ur": "پتوں پر سفید پاؤڈر جیسے دھبے جو پورے پودے کو ڈھانپ لیتے ہیں۔",
"causes": ["Warm dry weather", "Airborne spores", "Shaded areas"],
"causes_ur": ["گرم خشک موسم", "ہوا سے جراثیم کا پھیلاؤ"],
"cure": "Baking soda solution or fungicide like chlorothalonil.",
"cure_ur": "بیکنگ سوڈا محلول یا فنگس کش ادویات کا سپرے کریں۔",
"prevention": "Resistant varieties, full sun, water at base.",
"prevention_ur": "مدافعتی اقسام، مکمل دھوپ اور جڑ میں پانی دینا۔",
"severity": "Moderate",
"organic_remedies": "Sulfur fungicides, potassium bicarbonate, or milk spray.",
"organic_remedies_ur": "سلفر سپرے، پوٹاشیم بائیکاربونیٹ یا دودھ کا سپرے۔",
"fertilizer": "Avoid high-nitrogen; use balanced slow-release.",
"fertilizer_ur": "زیادہ نائٹروجن سے بچیں؛ آہستہ اثر کرنے والی کھاد دیں۔",
"weather_advice": "Favors warm dry days and cool humid nights.",
"weather_advice_ur": "گرم خشک دن اور مرطوب راتیں اس کے لیے سازگار ہیں۔",
},
"Squash___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Large vigorous sprawling plant with heavy fruit set.",
"description_ur": "بڑی بیل اور سبز پتوں والا صحت مند کدو / سکوائش کا پودا۔",
"causes": ["High water demand", "Heavy feeding"],
"causes_ur": ["زیادہ پانی", "بھرپور خوراک"],
"cure": "Apply nitrogen early for foliage growth; switch to phosphorus for bloom.",
"cure_ur": "شروع میں نائٹروجن دیں اور پھول آنے پر فاسفورس والی کھاد دیں۔",
"prevention": "Full sun, rich amended soil, mulching.",
"prevention_ur": "مکمل دھوپ، بھرپور مٹی اور ملچنگ۔",
"severity": "Healthy",
"organic_remedies": "Compost tea or fish emulsion every 1-2 weeks.",
"organic_remedies_ur": "ہر ہفتے دو ہفتے بعد کمپوسٹ چائے یا مچھلی کی کھاد دیں۔",
"fertilizer": "Balanced 10-10-10 at planting; side-dress when vining.",
"fertilizer_ur": "بوائی پر 10-10-10 اور بیل بنتے وقت دوبارہ کھاد دیں۔",
"weather_advice": "Avoid overhead watering to keep foliage dry.",
"weather_advice_ur": "پتوں پر پانی نہ ڈالیں تاکہ بیماریوں سے بچا جا سکے۔",
},
"Strawberry___Leaf_scorch": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Strawberry Leaf Scorch",
"description": "Irregular purple red blotches making leaves look scorched.",
"description_ur": "پتوں پر جامنی سرخ دھبے جو پتوں کو جھلسا دیتے ہیں۔",
"causes": ["Fungus in debris", "Wet spring conditions"],
"causes_ur": ["پرانی باقیات میں فنگس", "موسم بہار کی نمی"],
"cure": "Fungicides like captan at first sign.",
"cure_ur": "بیماری کے شروع میں کیپٹان جیسی فنگس کش دوا سپرے کریں۔",
"prevention": "Resistant varieties, space plants for airflow, remove dead leaves.",
"prevention_ur": "مدافعتی اقسام، پودوں میں فاصلہ اور پرانے پتے ہٹانا۔",
"severity": "Moderate",
"organic_remedies": "Sanitation (remove infected leaves); drip irrigation.",
"organic_remedies_ur": "صفائی اور ڈرپ ایریگیشن تاکہ پتے خشک رہیں۔",
"fertilizer": "Balanced nutrition; avoid excessive nitrogen.",
"fertilizer_ur": "متوازن خوراک دیں؛ نائٹروجن زیادہ نہ ہو۔",
"weather_advice": "Severe when wet in spring; spreads in cool humid conditions.",
"weather_advice_ur": "بہار کی بارشوں اور ٹھنڈی نمی میں زیادہ پھیلتی ہے۔",
},
"Strawberry___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Low-growing crown with runners and abundant sweet berries.",
"description_ur": "سبز پتوں اور میٹھے پھلوں والا صحت مند اسٹرابیری کا پودا۔",
"causes": ["Healthy root system", "Sunny location", "Post-harvest renovation"],
"causes_ur": ["مضبوط جڑیں", "دھوپ والی جگہ", "کٹائی کے بعد صفائی"],
"cure": "Renovate bed post-harvest (mow leaves, thin plants, fertilize).",
"cure_ur": "پھل ختم ہونے کے بعد پودوں کی چھانٹی اور کھاد کا استعمال کریں۔",
"prevention": "Well-drained soil, weed control, remove dead winter leaves.",
"prevention_ur": "اچھی مٹی، جڑی بوٹیوں کی صفائی اور پرانے پتوں کا خاتمہ۔",
"severity": "Healthy",
"organic_remedies": "Compost and mulch with straw around plants.",
"organic_remedies_ur": "کمپوسٹ ڈالیں اور تنکوں سے ملچنگ کریں۔",
"fertilizer": "Early spring balanced feed; high potassium for fruit.",
"fertilizer_ur": "بہار کے شروع میں متوازن کھاد اور پھل کے لیے پوٹاشیم دیں۔",
"weather_advice": "Need 2.5 cm water/week; keep soil moist but not waterlogged.",
"weather_advice_ur": "ہفتہ وار ڈھائی سینٹی میٹر پانی دیں؛ مٹی کو نم رکھیں۔",
},
"Sugarcane___Healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Tall, thick stalk filled with sweet juice; wide green leaves.",
"description_ur": "لمبے موٹے تنے اور سبز پتوں والی صحت مند گنے کی فصل۔",
"causes": ["Warm sunny climate", "High water/nutrient supply"],
"causes_ur": ["گرم دھوپ والا موسم", "بھرپور پانی اور خوراک"],
"cure": "Consistent irrigation and heavy feeding throughout vegetative growth.",
"cure_ur": "بڑھوتری کے دوران باقاعدہ پانی اور بھرپور کھاد دیں۔",
"prevention": "Soil pH 6.0-6.5, weed control, balanced NPK.",
"prevention_ur": "مٹی کی درست پی ایچ اور جڑی بوٹیوں کی صفائی۔",
"severity": "Healthy",
"organic_remedies": "Organic soil amendments (compost/manure).",
"organic_remedies_ur": "کمپوسٹ یا گوبر کی کھاد کا استعمال کریں۔",
"fertilizer": "Split applications of NPK; high potassium for sugar.",
"fertilizer_ur": "این پی کے قسطوں میں دیں؛ چینی کے لیے پوٹاشیم ضروری ہے۔",
"weather_advice": "Needs 1600-1800 mm water; requires high humidity.",
"weather_advice_ur": "گنے کو بہت زیادہ پانی اور نمی کی ضرورت ہوتی ہے۔",
},
"Sugarcane___Mosaic": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Mosaic Virus",
"description": "Light/dark green patches (mosaic) on leaves; stunted growth.",
"description_ur": "پتوں پر ہلکے اور گہرے سبز دھبے (موزیک) بن جاتے ہیں اور قد چھوٹا رہتا ہے۔",
"causes": ["Aphids (insect vector)", "Infected seed cane"],
"causes_ur": ["تیلا (ایفڈز) اور بیمار بیج"],
"cure": "No cure. Remove infected plants. Control aphid vectors.",
"cure_ur": "کوئی علاج نہیں؛ بیمار پودے نکال دیں اور تیلے کو ماریں۔",
"prevention": "Certified virus-free seed cane, aphid control.",
"prevention_ur": "وائرس سے پاک بیج اور تیلے کا خاتمہ۔",
"severity": "Critical",
"organic_remedies": "Encourage natural predators (ladybugs/lacewings).",
"organic_remedies_ur": "لیڈی بگ جیسے فائدہ مند کیڑوں کی حفاظت کریں۔",
"fertilizer": "Balanced fertility to maintain plant health.",
"fertilizer_ur": "پودے کی صحت کے لیے متوازن کھاد دیں۔",
"weather_advice": "Aphids thrive in warm, dry weather.",
"weather_advice_ur": "گرم اور خشک موسم میں تیلا زیادہ پھیلتا ہے۔",
},
"Sugarcane___RedRot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Red Rot",
"description": "Internal tissues turn red and rot with foul smell. Devastating.",
"description_ur": "گنے کے اندرونی حصے سرخ ہو کر سڑ جاتے ہیں اور بدبو آتی ہے۔",
"causes": ["Infected setts", "Soil-borne/debris survival", "Water stress"],
"causes_ur": ["بیمار بیج (گولیاں)", "مٹی میں موجود فنگس"],
"cure": "Certified seed setts; hot water treatment. Fungicides like Amistar Top.",
"cure_ur": "صاف بیج، گرم پانی سے علاج اور فنگس کش ادویات کا استعمال۔",
"prevention": "2-year crop rotation, destroy infected residue.",
"prevention_ur": "دو سالہ فصلوں کی تبدیلی اور باقیات کو جلانا۔",
"severity": "Critical",
"organic_remedies": "Rogue out infected plants; burn crop residue.",
"organic_remedies_ur": "بیمار پودے نکال دیں اور باقیات کو جلا دیں۔",
"fertilizer": "Avoid high nitrogen; avoid water stress.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں اور پانی کی کمی نہ ہونے دیں۔",
"weather_advice": "Drought stress predisposes plant to infection.",
"weather_advice_ur": "خشک سالی اس بیماری کے حملے کو آسان بناتی ہے۔",
},
"Sugarcane___Rust": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Orange Rust",
"description": "Small yellow-orange pustules on leaves; reduces sugar content.",
"description_ur": "پتوں پر چھوٹے پیلے نارنجی دھبے بنتے ہیں جو چینی کی مقدار کم کر دیتے ہیں۔",
"causes": ["Warm humid conditions", "Wind-blown spores"],
"causes_ur": ["گرم مرطوب موسم", "ہوا سے پھیلنے والے جراثیم"],
"cure": "Resistant varieties. Triazole/strobilurin fungicides if severe.",
"cure_ur": "مدافعتی اقسام اور فنگس کش ادویات کا سپرے کریں۔",
"prevention": "Resistant varieties, remove volunteer plants.",
"prevention_ur": "مدافعتی اقسام کا انتخاب اور فالتو پودوں کا خاتمہ۔",
"severity": "Moderate",
"organic_remedies": "Use resistant varieties primarily.",
"organic_remedies_ur": "صرف مدافعتی اقسام ہی بہترین حل ہیں۔",
"fertilizer": "Balanced fertilization; adequate potassium helps resistance.",
"fertilizer_ur": "پوٹاشیم والی متوازن کھاد مدافعت بڑھاتی ہے۔",
"weather_advice": "Warm to hot temperatures and high humidity favor spread.",
"weather_advice_ur": "زیادہ درجہ حرارت اور نمی میں بیماری پھیلتی ہے۔",
},
"Sugarcane___Yellow": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Yellow Leaf Syndrome",
"description": "Bright golden-yellowing of midrib spreading to blade.",
"description_ur": "پتے کی درمیانی رگ کا سنہرا پیلا ہونا جو پورے پتے میں پھیل جاتا ہے۔",
"causes": ["Viral infection (SCYLV)", "Environmental/nutrient stress"],
"causes_ur": ["وائرس اور غذائی اجزاء کی کمی"],
"cure": "Disease-free planting material. Reduce water/nutrient stress.",
"cure_ur": "بیماری سے پاک بیج اور پانی و خوراک کی کمی دور کریں۔",
"prevention": "Certified seed cane, consistent adequate nutrition.",
"prevention_ur": "صاف ستھرا بیج اور پودے کی بھرپور خوراک۔",
"severity": "Moderate",
"organic_remedies": "None specific; focus on stress reduction.",
"organic_remedies_ur": "پودے پر دباؤ کم کریں؛ کوئی خاص نامیاتی علاج نہیں۔",
"fertilizer": "Avoid nutrient deficiencies, particularly K and N.",
"fertilizer_ur": "پوٹاشیم اور نائٹروجن کی کمی نہ ہونے دیں۔",
"weather_advice": "Induced by water stress (too much or too little).",
"weather_advice_ur": "پانی کی کمی یا زیادتی اس کا سبب بن سکتی ہے۔",
},
"Tomato___Bacterial_spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Bacterial Spot",
"description": "Small dark water-soaked spots with yellow halos on leaves.",
"description_ur": "پتوں پر چھوٹے سیاہ دھبے جن کے گرد پیلا دائرہ ہوتا ہے۔",
"causes": ["Seed-borne bacteria", "Splashing rain/irrigation"],
"causes_ur": ["بیمار بیج", "بارش یا پانی کی چھینٹیں"],
"cure": "Copper-based bactericide mixed with mancozeb.",
"cure_ur": "کاپر اور مینکوزیب کا سپرے کریں۔",
"prevention": "Certified seed, crop rotation (2-3 years), avoid overhead water.",
"prevention_ur": "صاف بیج، فصلوں کی تبدیلی اور اوپر سے پانی نہ دیں۔",
"severity": "High",
"organic_remedies": "Fixed copper fungicide as preventive treatment.",
"organic_remedies_ur": "کاپر فنگسائیڈ کا حفاظتی استعمال۔",
"fertilizer": "Balanced nutrition; avoid high nitrogen.",
"fertilizer_ur": "نائٹروجن کا زیادہ استعمال نہ کریں۔",
"weather_advice": "Worse in warm wet seasons; requires prolonged leaf wetness.",
"weather_advice_ur": "گرم گیلے موسم اور پتوں پر نمی سے پھیلتی ہے۔",
},
"Tomato___Early_blight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Early Blight",
"description": "Dark spots with 'target' concentric rings on lower leaves.",
"description_ur": "نیچلے پتوں پر سیاہ دائروں والے دھبے بن جاتے ہیں۔",
"causes": ["Fungus overwinters on debris", "Warm humid conditions"],
"causes_ur": ["باقیات میں فنگس", "گرم مرطوب موسم"],
"cure": "Fixed copper or chlorothalonil every 7-10 days.",
"cure_ur": "ہر دس دن بعد کاپر یا کلوروتھیلونل کا سپرے کریں۔",
"prevention": "Crop rotation, mulch to reduce splash, water at base.",
"prevention_ur": "فصلوں کی تبدیلی، ملچنگ اور جڑ میں پانی دینا۔",
"severity": "Moderate",
"organic_remedies": "Fixed copper; remove lower infected leaves early.",
"organic_remedies_ur": "کاپر سپرے اور نیچلے بیمار پتے توڑ دیں۔",
"fertilizer": "Avoid excessive nitrogen; balanced nutrition.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں؛ متوازن کھاد استعمال کریں۔",
"weather_advice": "Favored by 24-29°C and humid conditions.",
"weather_advice_ur": "24-29 ڈگری اور نمی والے موسم میں پھیلتی ہے۔",
},
"Tomato___Late_blight": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Tomato Late Blight",
"description": "Devastating; dark water-soaked spots with white fuzzy growth. Collapse.",
"description_ur": "ٹماٹر کی سب سے خطرناک بیماری؛ پودا تیزی سے گل سڑ کر ختم ہو جاتا ہے۔",
"causes": ["Cool wet weather", "Pathogen blown into area"],
"causes_ur": ["ٹھنڈا اور گیلا موسم", "ہوا سے آنے والے جراثیم"],
"cure": "Preventive copper fungicide weekly. Destroy infected plants immediately.",
"cure_ur": "ہفتہ وار کاپر سپرے کریں؛ بیمار پودے فوراً تلف کریں۔",
"prevention": "Resistant varieties, good airflow, remove volunteer plants.",
"prevention_ur": "مدافعتی اقسام اور ہوا کا انتظام۔",
"severity": "Critical",
"organic_remedies": "Copper-based fungicide applied before disease strikes.",
"organic_remedies_ur": "بیماری آنے سے پہلے کاپر فنگسائیڈ کا سپرے۔",
"fertilizer": "Avoid high nitrogen which promotes dense growth.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں تاکہ جھاڑی زیادہ گھنی نہ ہو۔",
"weather_advice": "Most likely when nights are cool and days are warm with high humidity.",
"weather_advice_ur": "ٹھنڈی راتیں، گرم دن اور زیادہ حبس میں بہت خطرناک ہے۔",
},
"Tomato___Leaf_Mold": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Leaf Mold",
"description": "Pale yellow spots on upper leaf surface; velvety mold underneath.",
"description_ur": "پتے کے اوپر پیلے دھبے اور نیچے مخملی فنگس نظر آتی ہے۔",
"causes": ["High humidity (>85%)", "Poor air circulation"],
"causes_ur": ["زیادہ نمی (85 فیصد سے زائد)", "ہوا کی کمی"],
"cure": "Chlorothalonil or copper-based products. Cover lower leaf surface.",
"cure_ur": "کلوروتھیلونل یا کاپر کا سپرے کریں؛ پتوں کے نیچے بھی لگائیں۔",
"prevention": "Reduce humidity, improve ventilation, space plants widely.",
"prevention_ur": "نمی کم کریں، ہوا کا انتظام بہتر کریں اور فاصلہ رکھیں۔",
"severity": "Moderate",
"organic_remedies": "Manage environment to lower humidity below 85%.",
"organic_remedies_ur": "ماحول میں نمی کو 85 فیصد سے نیچے رکھیں۔",
"fertilizer": "Avoid high nitrogen levels.",
"fertilizer_ur": "نائٹروجن کی زیادہ مقدار سے گریز کریں۔",
"weather_advice": "Risk low during dry weather; primarily a problem in high humidity.",
"weather_advice_ur": "خشک موسم میں خطرہ کم ہوتا ہے؛ زیادہ نمی میں پھیلتی ہے۔",
},
"Tomato___Septoria_leaf_spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Septoria Leaf Spot",
"description": "Circular spots with dark margins and gray centers on lower leaves.",
"description_ur": "نیچلے پتوں پر بھورے کناروں اور سرمئی مرکز والے گول دھبے۔",
"causes": ["Survives on soil debris", "Splashing rain spread"],
"causes_ur": ["مٹی کی باقیات", "بارش کی چھینٹیں"],
"cure": "Copper-based products or chlorothalonil every 7-10 days.",
"cure_ur": "ہر دس دن بعد کاپر یا کلوروتھیلونل کا سپرے کریں۔",
"prevention": "Crop rotation (2-3 years), mulch to prevent soil splash.",
"prevention_ur": "فصلوں کی تبدیلی اور ملچنگ کا استعمال۔",
"severity": "Moderate",
"organic_remedies": "Fixed copper; remove infected lower leaves.",
"organic_remedies_ur": "کاپر فنگسائیڈ اور متاثرہ نیچلے پتے توڑ دیں۔",
"fertilizer": "Balanced fertility; avoid high nitrogen.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں؛ متوازن کھاد استعمال کریں۔",
"weather_advice": "Severe in warm humid climates with frequent rain.",
"weather_advice_ur": "گرم مرطوب اور بارش والے موسم میں زیادہ پھیلتی ہے۔",
},
"Tomato___Spider_mites Two-spotted_spider_mite": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Two-Spotted Spider Mite",
"description": "Sap-sucking pest; causes yellow/bronze mottling and fine webbing.",
"description_ur": "چھوٹے کیڑے جو پتے کا رس چوستے ہیں اور باریک جالے بناتے ہیں۔",
"causes": ["Hot dry weather", "Rapid life cycle (5-7 days)"],
"causes_ur": ["گرم اور خشک موسم"],
"cure": "Miticide or insecticidal soap. Repeat every 7-10 days.",
"cure_ur": "کیڑے مار صابن یا مائٹیسائیڈ کا سپرے کریں اور دہرائیں۔",
"prevention": "Keep plants well-watered; avoid drought stress.",
"prevention_ur": "پودوں کو پانی دیں تاکہ وہ خشک سالی کے دباؤ میں نہ آئیں۔",
"severity": "Moderate",
"organic_remedies": "Insecticidal soap or horticultural oil.",
"organic_remedies_ur": "کیڑے مار صابن یا نیم کا تیل۔",
"fertilizer": "Avoid high nitrogen which attracts mites.",
"fertilizer_ur": "نائٹروجن زیادہ نہ دیں کیونکہ یہ کیڑوں کو کھینچتی ہے۔",
"weather_advice": "Pest of hot dry weather; less active in cool humid conditions.",
"weather_advice_ur": "گرم خشک موسم کا کیڑا ہے؛ ٹھنڈے مرطوب میں کم ہوتا ہے۔",
},
"Tomato___Target_Spot": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Target Spot",
"description": "Dark target-like lesions on leaves; can affect greenhouse and field.",
"description_ur": "پتوں پر سیاہ دائرے نما نشانات؛ یہ گرین ہاؤس میں زیادہ ہوتی ہے۔",
"causes": ["Seed-borne/Soil-borne", "High humidity (>80%)"],
"causes_ur": ["بیمار بیج یا مٹی", "زیادہ نمی (80 فیصد سے زائد)"],
"cure": "Weekly protectant fungicides (chlorothalonil, azoxystrobin).",
"cure_ur": "ہفتہ وار فنگس کش ادویات کا سپرے کریں۔",
"prevention": "Rotate crops, improve airflow, avoid overhead water.",
"prevention_ur": "فصلیں بدلیں، ہوا کا انتظام بہتر کریں اور اوپر سے پانی نہ دیں۔",
"severity": "High",
"organic_remedies": "Fixed copper fungicides as preventive treatment.",
"organic_remedies_ur": "کاپر فنگسائیڈ کا حفاظتی استعمال۔",
"fertilizer": "Balanced fertility to promote resilience.",
"fertilizer_ur": "پودے کی طاقت کے لیے متوازن کھاد دیں۔",
"weather_advice": "Rapid development when humidity is consistently high.",
"weather_advice_ur": "مسلسل زیادہ نمی میں بہت تیزی سے پھیلتی ہے۔",
},
"Tomato___Tomato_Yellow_Leaf_Curl_Virus": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Tomato Yellow Leaf Curl Virus",
"description": "Stunted growth, small wrinkled upward-cupping leaves with yellow margins.",
"description_ur": "پودا چھوٹا رہ جاتا ہے، پتے مڑ جاتے ہیں اور ان کے کنارے پیلے ہو جاتے ہیں۔",
"causes": ["Sweet potato whitefly (vector)"],
"causes_ur": ["سفید مکھی اس وائرس کو پھیلاتی ہے"],
"cure": "No cure. Destroy infected plants immediately. Control whitefly.",
"cure_ur": "کوئی علاج نہیں؛ بیمار پودے تلف کریں اور سفید مکھی کو ماریں۔",
"prevention": "Resistant varieties, reflective mulches, row covers.",
"prevention_ur": "مدافعتی اقسام اور سفید مکھی سے بچاؤ کے لیے جالی کا استعمال۔",
"severity": "Critical",
"organic_remedies": "Reflective mulches and insecticidal soaps for vector management.",
"organic_remedies_ur": "سفید مکھی کو کنٹرول کرنے کے لیے نامیاتی سپرے۔",
"fertilizer": "N/A for virus treatment.",
"fertilizer_ur": "کھاد سے اس کا علاج نہیں ہو سکتا۔",
"weather_advice": "Whitefly populations explode in warm weather.",
"weather_advice_ur": "گرم موسم میں سفید مکھی کی تعداد تیزی سے بڑھتی ہے۔",
},
"Tomato___Tomato_mosaic_virus": {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": "Tomato Mosaic Virus",
"description": "Mottled mosaic pattern on leaves; young leaves distorted/fern-like.",
"description_ur": "پتوں پر ہلکے گہرے دھبے بنتے ہیں اور پتے کٹے پھٹے نظر آتے ہیں۔",
"causes": ["Mechanical transmission (contact)", "Tobacco contact"],
"causes_ur": ["چھونے یا اوزاروں کے ذریعے پھیلاؤ"],
"cure": "No cure. Destroy infected plants immediately. Strict hygiene.",
"cure_ur": "کوئی علاج نہیں؛ بیمار پودے تلف کریں اور صفائی کا خاص خیال رکھیں۔",
"prevention": "Wash hands with soap before handling; use sterile seed.",
"prevention_ur": "پودوں کو چھونے سے پہلے ہاتھ دھوئیں؛ صاف بیج استعمال کریں۔",
"severity": "High",
"organic_remedies": "10% skim milk spray to reduce virus spread.",
"organic_remedies_ur": "وائرس کو روکنے کے لیے 10 فیصد سکم ملک کا سپرے۔",
"fertilizer": "N/A for virus treatment.",
"fertilizer_ur": "کھاد سے علاج ممکن نہیں۔",
"weather_advice": "Injuries from wind or insects create entry points.",
"weather_advice_ur": "ہوا یا کیڑوں سے لگنے والے زخموں سے وائرس داخل ہوتا ہے۔",
},
"Tomato___healthy": {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": "Robust stem, rich green leaves, heavy set of crack-free fruit.",
"description_ur": "مضبوط تنے اور سبز پتوں والا صحت مند ٹماٹر کا پودا۔",
"causes": ["Good genetics", "Proper support", "Consistent care"],
"causes_ur": ["بہترین بیج", "سہارا دینا", "باقاعدہ دیکھ بھال"],
"cure": "Prune suckers (crotch growth) to focus energy on fruit production.",
"cure_ur": "فالتو شاخیں (سکرز) کاٹ دیں تاکہ ساری طاقت پھل کو ملے۔",
"prevention": "Full sun, stake/cage plants, mulch to retain moisture.",
"prevention_ur": "مکمل دھوپ، سہارا دینا اور ملچنگ کا استعمال۔",
"severity": "Healthy",
"organic_remedies": "Thick layer of straw mulch to act as disease barrier.",
"organic_remedies_ur": "تنکوں کی ملچنگ کریں تاکہ مٹی کی بیماریاں نہ لگیں۔",
"fertilizer": "Blossom booster once flowering starts; higher P and K.",
"fertilizer_ur": "پھول آنے پر فاسفورس اور پوٹاشیم والی کھاد دیں۔",
"weather_advice": "Consistent water (2.5 cm/week) to prevent blossom end rot.",
"weather_advice_ur": "ہفتہ وار ڈھائی سینٹی میٹر پانی دیں تاکہ پھل نیچے سے نہ سڑے۔",
},
}
def _get_disease_info(raw_label: str, plant: str, disease: str) -> dict[str, Any]:
"""
Look up disease data by exact class-map key.
Priority:
1. Exact key match in _DISEASES_DB → full rich data for all 58 classes
2. Healthy fallback (not in DB) → generic healthy message
3. Generic diseased fallback → still better than empty string
"""
# 1. Exact match — covers all 58 trained classes
if raw_label in _DISEASES_DB:
return dict(_DISEASES_DB[raw_label])
# 2. Healthy fallback (should not happen with complete DB, but safe guard)
if "healthy" in disease.lower():
return {
"status": "Healthy",
"status_ur": "صحت مند",
"disease_name": "None",
"description": f"The {_prettify(plant)} plant appears healthy with no visible signs of disease.",
"description_ur": f"آپ کا {_prettify(plant)} کا پودا بالکل صحت مند معلوم ہوتا ہے۔",
"causes": ["Proper care and environment"],
"causes_ur": ["مناسب دیکھ بھال اور ماحول"],
"cure": "No treatment needed.",
"cure_ur": "کسی علاج کی ضرورت نہیں ہے۔",
"prevention": "Continue regular maintenance.",
"prevention_ur": "باقاعدگی سے دیکھ بھال جاری رکھیں۔",
"severity": "Healthy",
"organic_remedies": "None needed",
"organic_remedies_ur": "کسی چیز کی ضرورت نہیں",
"fertilizer": "Regular compost",
"fertilizer_ur": "عام کھاد یا کمپوسٹ",
"weather_advice": "Ideal conditions for growth.",
"weather_advice_ur": "نشوونما کے لیے بہترین حالات۔",
}
# 3. Generic diseased fallback
return {
"status": "Diseased",
"status_ur": "بیمار",
"disease_name": _prettify(disease),
"description": "A condition affecting the health and growth of the plant.",
"description_ur": "ایک ایسی حالت جو پودے کی صحت اور نشوونما کو متاثر کر رہی ہے۔",
"causes": ["Environmental stress", "Pathogen exposure"],
"causes_ur": ["ماحولیاتی دباؤ", "جراثیم کا حملہ"],
"cure": "Remove affected parts and monitor closely.",
"cure_ur": "متاثرہ حصوں کو ہٹا دیں اور قریب سے نگرانی کریں۔",
"prevention": "Maintain proper watering and sunlight.",
"prevention_ur": "پانی اور سورج کی روشنی کا مناسب انتظام برقرار رکھیں۔",
"severity": "Moderate",
"organic_remedies": "Neem oil spray",
"organic_remedies_ur": "نیم کے تیل کا سپرے",
"fertilizer": "Balanced NPK fertilizer",
"fertilizer_ur": "متوازن این پی کے کھاد",
"weather_advice": "Avoid extreme humidity or dry spells.",
"weather_advice_ur": "بہت زیادہ نمی یا خشک سالی سے بچیں",
}
# ── Model loading ─────────────────────────────────────────────────────────────
def load_model_and_classes() -> tuple[Any, dict[str, str]]:
global _model, _idx_to_class
# Dynamic path resolution — same pattern as the working HF config
hf_model_path = Path("/app/GardCom/saved_models_run2/best_model.keras")
hf_class_path = Path("/app/GardCom/saved_models_run2/class_map.json")
final_model_path = hf_model_path if hf_model_path.exists() else MODEL_PATH
final_class_path = hf_class_path if hf_class_path.exists() else CLASS_MAP_PATH
if not final_model_path.exists():
raise Exception(f"Model file missing at {final_model_path}")
if not final_class_path.exists():
raise Exception(f"Class map file missing at {final_class_path}")
if _model is None:
_model = tf.keras.models.load_model(final_model_path)
if _idx_to_class is None:
with open(final_class_path, "r", encoding="utf-8") as f:
_idx_to_class = json.load(f)
return _model, _idx_to_class
# ── Image preprocessing ───────────────────────────────────────────────────────
def preprocess_image(file_path: str) -> np.ndarray:
# Raw 0-255 float32 — EfficientNetB0 has its own built-in normalization
img = Image.open(file_path).convert("RGB").resize(IMAGE_SIZE, Image.LANCZOS)
arr = np.array(img, dtype=np.float32)
return np.expand_dims(arr, axis=0)
# ── Main prediction function ──────────────────────────────────────────────────
def predict(
file_path: str,
top_k: int = TOP_K_DEFAULT,
plant_hint: str | None = None,
) -> dict[str, Any]:
model, idx_to_class = load_model_and_classes()
probs = model.predict(preprocess_image(file_path), verbose=0)[0]
top_idx = -1
confidence = 0.0
hint_status = "none"
# Step 1: Plant hint prioritization
if plant_hint and len(plant_hint.strip()) > 1:
hint = plant_hint.strip().lower()
matching_indices = []
for i, label in idx_to_class.items():
plant_part, _ = _split_label(label)
if hint in plant_part.lower() or plant_part.lower() in hint:
matching_indices.append(int(i))
if matching_indices:
best_match_idx = matching_indices[0]
max_match_prob = probs[best_match_idx]
for idx in matching_indices:
if probs[idx] > max_match_prob:
max_match_prob = probs[idx]
best_match_idx = idx
if max_match_prob > 0.30:
top_idx = best_match_idx
confidence = float(max_match_prob)
hint_status = "correct"
# Step 2: Fall back to global argmax
if top_idx == -1:
top_idx = int(np.argmax(probs))
confidence = float(probs[top_idx])
if plant_hint and len(plant_hint.strip()) > 1:
global_plant, _ = _split_label(idx_to_class[str(top_idx)])
hint_low = plant_hint.strip().lower()
if hint_low in global_plant.lower() or global_plant.lower() in hint_low:
hint_status = "correct"
else:
hint_status = "wrong"
# Step 3: OOD rejection — multi-signal check
# Signal A: max confidence below threshold (primary gate)
low_confidence = confidence < OOD_THRESHOLD
# Signal B: probability mass too spread out (high entropy = uncertain prediction)
# If the top-1 probability is below 0.55 AND top-3 combined is below 0.75,
# the model is unsure — likely an out-of-domain image.
top3_sum = float(sum(sorted(probs, reverse=True)[:3]))
spread_signal = (confidence < 0.55) and (top3_sum < 0.75)
# Signal C: plant hint mismatch with low confidence — the model can't even
# agree with what the user says the plant is, so it's likely not in-domain.
hint_mismatch_ood = (hint_status == "wrong") and (confidence < 0.60)
is_ood = low_confidence or spread_signal or hint_mismatch_ood
if is_ood:
return {
"status": "not_recognised",
"message": (
"The submitted image could not be recognised as a supported plant. "
"Please ensure the image clearly shows a plant leaf and belongs to one "
"of the 17 supported plant species. For best results, use a well-lit, "
"close-up photograph of the leaf."
),
"message_ur": (
"جمع کروائی گئی تصویر کو کسی معاون پودے کے طور پر شناخت نہیں کیا جا سکا۔ "
"براہ کرم یقینی بنائیں کہ تصویر میں پودے کا پتہ واضح طور پر نظر آ رہا ہو "
"اور وہ 17 معاون اقسام میں سے کسی ایک سے تعلق رکھتا ہو۔"
),
"plant_name": "Not Recognised",
"disease_name": "N/A",
"confidence": round(confidence * 100.0, 2),
"top_k": [],
"user_hint": plant_hint,
"hint_status": "none",
"error": None,
}
# Step 4: Build result
top_pairs = sorted(enumerate(probs), key=lambda x: x[1], reverse=True)[: max(1, top_k)]
raw_label = idx_to_class[str(top_idx)]
plant, disease = _split_label(raw_label)
# O(1) lookup — covers all 58 classes with full English + Urdu data
details = _get_disease_info(raw_label, plant, disease)
return {
"status": "ok",
"message": (
f"Healthy {_prettify(plant)} leaf detected."
if details["status"] == "Healthy"
else f"{details['disease_name']} detected on {_prettify(plant)}."
),
"plant_name": _prettify(plant),
"disease_name": details["disease_name"],
"disease_status": details["status"],
"disease_status_ur": details["status_ur"],
"confidence": round(confidence * 100.0, 1),
"description": details["description"],
"description_ur": details["description_ur"],
"causes": details["causes"],
"causes_ur": details["causes_ur"],
"cure": details["cure"],
"cure_ur": details["cure_ur"],
"prevention": details["prevention"],
"prevention_ur": details["prevention_ur"],
"severity": details["severity"],
"organic_remedies": details["organic_remedies"],
"organic_remedies_ur": details["organic_remedies_ur"],
"fertilizer": details["fertilizer"],
"fertilizer_ur": details["fertilizer_ur"],
"weather_advice": details["weather_advice"],
"weather_advice_ur": details["weather_advice_ur"],
"user_hint": plant_hint,
"hint_status": hint_status,
"top_k": [
{
"class": idx_to_class[str(i)],
"confidence": round(float(p) * 100.0, 1),
}
for i, p in top_pairs
],
"error": None,
} |