Update README.md
Browse files
README.md
CHANGED
@@ -1,874 +1,888 @@
|
|
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 |
-
- **Data
|
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 |
-
python
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Potato_Diseases_Detection_with_Deep_Learning
|
3 |
+
emoji: 🐨
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: blue
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
license: apache-2.0
|
9 |
+
---
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
# 🥔 Potato Skin Disease Detection Using Deep Learning
|
16 |
+
|
17 |
+
[](https://www.python.org/)
|
18 |
+
[](https://tensorflow.org/)
|
19 |
+
[](https://keras.io/)
|
20 |
+
[](LICENSE)
|
21 |
+
|
22 |
+
> 🔬 An AI-powered computer vision system for detecting and classifying potato skin diseases using deep learning techniques.
|
23 |
+
|
24 |
+
## 📋 Table of Contents
|
25 |
+
|
26 |
+
- [🎯 Project Overview](#-project-overview)
|
27 |
+
- [🌟 Features](#-features)
|
28 |
+
- [📊 Dataset](#-dataset)
|
29 |
+
- [🚀 Getting Started](#-getting-started)
|
30 |
+
- [💻 Usage](#-usage)
|
31 |
+
- [🏗️ Model Architecture](#-model-architecture)
|
32 |
+
- [📈 Results](#-results)
|
33 |
+
- [🚀 Next Steps](#-Next-Steps)
|
34 |
+
- [📄 License](#-license)
|
35 |
+
|
36 |
+
## 🎯 Project Overview
|
37 |
+
|
38 |
+
This project implements a **Convolutional Neural Network (CNN)** using TensorFlow/Keras to automatically detect and classify potato skin diseases from digital images. The system can identify three main categories:
|
39 |
+
|
40 |
+
- 🍃 **Healthy Potatoes**
|
41 |
+
- 🦠 **Early Blight Disease**
|
42 |
+
- 🍄 **Late Blight Disease**
|
43 |
+
|
44 |
+
### 🎥 Demo
|
45 |
+
|
46 |
+
<details>
|
47 |
+
<summary>Click to see sample predictions</summary>
|
48 |
+
|
49 |
+
```
|
50 |
+
Input: potato_image.jpg
|
51 |
+
Output: "Early Blight Disease" (Confidence: 94.2%)
|
52 |
+
```
|
53 |
+
|
54 |
+
</details>
|
55 |
+
|
56 |
+
## 🌟 Features
|
57 |
+
|
58 |
+
- ✅ **Multi-class Classification**: Detects 3 types of potato conditions
|
59 |
+
- ✅ **Data Augmentation**: Improves model robustness with image transformations
|
60 |
+
- ✅ **Interactive Visualization**: Displays sample images with predictions
|
61 |
+
- ✅ **Optimized Performance**: Uses caching and prefetching for faster training
|
62 |
+
- ✅ **Scalable Architecture**: Easy to extend to more disease types
|
63 |
+
- ✅ **Real-time Inference**: Fast prediction on new images
|
64 |
+
|
65 |
+
## 📊 Dataset
|
66 |
+
|
67 |
+
### 📈 Dataset Statistics
|
68 |
+
|
69 |
+
- **Total Images**: 2,152
|
70 |
+
- **Classes**: 3 (Early Blight, Late Blight, Healthy)
|
71 |
+
- **Image Size**: 256×256 pixels
|
72 |
+
- **Color Channels**: RGB (3 channels)
|
73 |
+
- **Data Split**: 80% Train, 10% Validation, 10% Test
|
74 |
+
|
75 |
+
## 📁 Project Structure
|
76 |
+
|
77 |
+
```
|
78 |
+
potato-disease-detection/
|
79 |
+
├── 📓 POTATO_Skin_Diseases_Detection_Using_Deep_Learning.ipynb
|
80 |
+
├── 📄 README.md
|
81 |
+
├── 📋 requirements.txt
|
82 |
+
├── 📁 PlantVillage/
|
83 |
+
│ ├── 📁 Potato___Early_blight/
|
84 |
+
│ ├── 📁 Potato___Late_blight/
|
85 |
+
│ └── 📁 Potato___healthy/
|
86 |
+
├── 📁 models/
|
87 |
+
│ └── 💾 trained_model.h5
|
88 |
+
└── 📁 results/
|
89 |
+
├── 📊 training_plots.png
|
90 |
+
└── 📈 confusion_matrix.png
|
91 |
+
```
|
92 |
+
|
93 |
+
📂 Root Directory/
|
94 |
+
├── 🐍 app.py # Main Flask application
|
95 |
+
├── 📦 requirements.txt # Dependencies
|
96 |
+
├── 🚀 run_flask_app.bat # Easy startup script
|
97 |
+
├── 📚 README_Flask.md # Complete documentation
|
98 |
+
├── 📂 templates/
|
99 |
+
│ └── 🌐 index.html # Web interface
|
100 |
+
└── 📂 static/
|
101 |
+
├── 📂 css/
|
102 |
+
│ └── 💄 style.css # Beautiful styling
|
103 |
+
└── 📂 js/
|
104 |
+
└── ⚡ script.js # Interactive functionality
|
105 |
+
|
106 |
+
## 🚀 Getting Started
|
107 |
+
|
108 |
+
### 📋 Prerequisites
|
109 |
+
|
110 |
+
```bash
|
111 |
+
Python 3.8+
|
112 |
+
TensorFlow 2.x
|
113 |
+
Matplotlib
|
114 |
+
NumPy
|
115 |
+
```
|
116 |
+
|
117 |
+
### ⚡ Quick Start and Installation
|
118 |
+
|
119 |
+
### 🐍 Environment Setup
|
120 |
+
|
121 |
+
```bash
|
122 |
+
# Create virtual environment
|
123 |
+
python -m venv potato_env
|
124 |
+
|
125 |
+
# Activate environment
|
126 |
+
# Windows:
|
127 |
+
potato_env\Scripts\activate
|
128 |
+
# macOS/Linux:
|
129 |
+
source potato_env/bin/activate
|
130 |
+
|
131 |
+
# Install packages
|
132 |
+
pip install -r requirements.txt
|
133 |
+
```
|
134 |
+
|
135 |
+
# Run Application
|
136 |
+
|
137 |
+
#### **Step 1: Install Dependencies**
|
138 |
+
|
139 |
+
```cmd
|
140 |
+
pip install -r requirements.txt
|
141 |
+
```
|
142 |
+
|
143 |
+
#### **Step 2: Run the Application**
|
144 |
+
|
145 |
+
```cmd
|
146 |
+
python app.py
|
147 |
+
```
|
148 |
+
|
149 |
+
#### **Step 3: Open Your Browser**
|
150 |
+
|
151 |
+
- **Main App**: http://localhost:5000
|
152 |
+
- **Health Check**: http://localhost:5000/health
|
153 |
+
|
154 |
+
## 💻 Usage
|
155 |
+
|
156 |
+
### 🔧 Training the Model
|
157 |
+
|
158 |
+
The notebook includes the complete pipeline:
|
159 |
+
|
160 |
+
1. **Data Loading & Preprocessing**
|
161 |
+
|
162 |
+
```python
|
163 |
+
# Load dataset
|
164 |
+
dataset = tf.keras.preprocessing.image_dataset_from_directory(
|
165 |
+
"PlantVillage",
|
166 |
+
image_size=(256, 256),
|
167 |
+
batch_size=32
|
168 |
+
)
|
169 |
+
```
|
170 |
+
|
171 |
+
2. **Data Augmentation**
|
172 |
+
|
173 |
+
```python
|
174 |
+
# Apply data augmentation
|
175 |
+
data_augmentation = tf.keras.Sequential([
|
176 |
+
tf.keras.layers.RandomFlip("horizontal_and_vertical"),
|
177 |
+
tf.keras.layers.RandomRotation(0.2)
|
178 |
+
])
|
179 |
+
```
|
180 |
+
|
181 |
+
3. **Model Configuration**
|
182 |
+
```python
|
183 |
+
IMAGE_SIZE = 256
|
184 |
+
BATCH_SIZE = 32
|
185 |
+
CHANNELS = 3
|
186 |
+
EPOCHS = 50
|
187 |
+
```
|
188 |
+
|
189 |
+
### 🎯 Making Predictions
|
190 |
+
|
191 |
+
```python
|
192 |
+
# Load your trained model
|
193 |
+
model = tf.keras.models.load_model('potato_disease_model.h5')
|
194 |
+
|
195 |
+
# Make prediction
|
196 |
+
prediction = model.predict(new_image)
|
197 |
+
predicted_class = class_names[np.argmax(prediction)]
|
198 |
+
```
|
199 |
+
|
200 |
+
## 🏗️ Model Architecture
|
201 |
+
|
202 |
+
### 🧠 Network Components
|
203 |
+
|
204 |
+
1. **Input Layer**: 256×256×3 RGB images
|
205 |
+
2. **Preprocessing**:
|
206 |
+
- Image resizing and rescaling (1.0/255)
|
207 |
+
- Data augmentation (RandomFlip, RandomRotation)
|
208 |
+
3. **Feature Extraction**: CNN layers for pattern recognition
|
209 |
+
4. **Classification**: Dense layers for final prediction
|
210 |
+
|
211 |
+
### ⚙️ Training Configuration
|
212 |
+
|
213 |
+
- **Optimizer**: Adam (recommended)
|
214 |
+
- **Loss Function**: Sparse Categorical Crossentropy
|
215 |
+
- **Metrics**: Accuracy
|
216 |
+
- **Epochs**: 50
|
217 |
+
- **Batch Size**: 32
|
218 |
+
|
219 |
+
## 📈 Results
|
220 |
+
|
221 |
+
### 📊 Performance Metrics
|
222 |
+
|
223 |
+
| Metric | Score |
|
224 |
+
| ------------------- | ----- |
|
225 |
+
| Training Accuracy | XX.X% |
|
226 |
+
| Validation Accuracy | XX.X% |
|
227 |
+
| Test Accuracy | XX.X% |
|
228 |
+
| F1-Score | XX.X% |
|
229 |
+
|
230 |
+
### 🎨 Visualization
|
231 |
+
|
232 |
+
The notebook includes:
|
233 |
+
|
234 |
+
- ✅ Sample image visualization
|
235 |
+
- ✅ Training/validation loss curves
|
236 |
+
- ✅ Confusion matrix
|
237 |
+
- ✅ Class-wise accuracy
|
238 |
+
|
239 |
+
# 🥔 Potato Disease Detection - Flask Web Application
|
240 |
+
|
241 |
+
A modern Flask web application for detecting potato diseases using deep learning. Upload images or use your camera to get instant disease predictions with confidence scores and treatment recommendations.
|
242 |
+
|
243 |
+
## ✨ Features
|
244 |
+
|
245 |
+
### 🖼️ **Dual Input Methods**
|
246 |
+
|
247 |
+
- **📁 File Upload**: Drag & drop or browse to select images
|
248 |
+
- **📸 Camera Capture**: Take photos directly from your device camera
|
249 |
+
|
250 |
+
### 🧠 **AI-Powered Detection**
|
251 |
+
|
252 |
+
- **🎯 Accurate Predictions**: Uses trained CNN model for disease detection
|
253 |
+
- **📊 Confidence Scores**: Shows prediction confidence with color-coded badges
|
254 |
+
- **📈 Probability Breakdown**: Displays probabilities for all disease classes
|
255 |
+
|
256 |
+
### 💡 **Smart Recommendations**
|
257 |
+
|
258 |
+
- **🏥 Treatment Advice**: Provides specific recommendations for each condition
|
259 |
+
- **🚨 Urgency Levels**: Different advice based on disease severity
|
260 |
+
- **📋 Downloadable Reports**: Generate and download analysis reports
|
261 |
+
|
262 |
+
### 🎨 **Modern Interface**
|
263 |
+
|
264 |
+
- **📱 Responsive Design**: Works perfectly on mobile and desktop
|
265 |
+
- **🌟 Beautiful UI**: Modern design with smooth animations
|
266 |
+
- **🔄 Real-time Analysis**: Instant predictions with loading indicators
|
267 |
+
|
268 |
+
## 🦠 Detected Diseases
|
269 |
+
|
270 |
+
1. **🍂 Early Blight** - Common fungal disease affecting potato leaves
|
271 |
+
2. **💀 Late Blight** - Serious disease that can destroy entire crops
|
272 |
+
3. **✅ Healthy** - No disease detected
|
273 |
+
|
274 |
+
## 🎯 How to Use
|
275 |
+
|
276 |
+
### **📁 Upload Method**
|
277 |
+
|
278 |
+
1. **Select Upload** tab (default)
|
279 |
+
2. **Drag & drop** an image or **click to browse**
|
280 |
+
3. **Click "Analyze Disease"** button
|
281 |
+
4. **View results** with predictions and recommendations
|
282 |
+
|
283 |
+
### **📸 Camera Method**
|
284 |
+
|
285 |
+
1. **Click Camera** tab
|
286 |
+
2. **Click "Start Camera"** (allow permissions)
|
287 |
+
3. **Click "Capture Photo"** when ready
|
288 |
+
4. **Click "Analyze Disease"** button
|
289 |
+
5. **View results** with predictions and recommendations
|
290 |
+
|
291 |
+
### **📊 Understanding Results**
|
292 |
+
|
293 |
+
- **🎯 Primary Diagnosis**: Main prediction with confidence score
|
294 |
+
- **📈 Probability Breakdown**: All disease probabilities
|
295 |
+
- **💡 Recommendations**: Treatment and care advice
|
296 |
+
- **📋 Download Report**: Save results as text file
|
297 |
+
|
298 |
+
## 🔧 Technical Details
|
299 |
+
|
300 |
+
- **🐍 Backend**: Flask 2.3+ with Python
|
301 |
+
- **🧠 AI Model**: TensorFlow/Keras CNN
|
302 |
+
- **🖼️ Image Processing**: PIL/Pillow for preprocessing
|
303 |
+
- **🎨 Frontend**: HTML5, CSS3, Vanilla JavaScript
|
304 |
+
- **📱 Camera**: WebRTC getUserMedia API
|
305 |
+
- **💾 Storage**: Local file system for uploads
|
306 |
+
|
307 |
+
## 📋 Requirements
|
308 |
+
|
309 |
+
- **🐍 Python**: 3.8+ (Recommended: 3.10+)
|
310 |
+
- **💻 OS**: Windows, macOS, or Linux
|
311 |
+
- **🧠 Memory**: 4GB+ RAM (8GB recommended)
|
312 |
+
- **💾 Storage**: ~2GB for dependencies and models
|
313 |
+
- **🌐 Browser**: Chrome, Firefox, Safari, Edge (latest versions)
|
314 |
+
|
315 |
+
## 🛠️ Troubleshooting
|
316 |
+
|
317 |
+
### ❌ **Model Not Loading**
|
318 |
+
|
319 |
+
```
|
320 |
+
Error: Model not loaded! Please check the model file path.
|
321 |
+
```
|
322 |
+
|
323 |
+
**Solution:**
|
324 |
+
|
325 |
+
- Ensure `models/1.h5` exists
|
326 |
+
- Check TensorFlow installation: `pip install tensorflow>=2.13.0`
|
327 |
+
|
328 |
+
### ❌ **Camera Not Working**
|
329 |
+
|
330 |
+
```
|
331 |
+
Could not access camera. Please check permissions.
|
332 |
+
```
|
333 |
+
|
334 |
+
**Solution:**
|
335 |
+
|
336 |
+
- Allow camera permissions in your browser
|
337 |
+
- Use HTTPS for camera access (or localhost)
|
338 |
+
- Check if another app is using the camera
|
339 |
+
|
340 |
+
### ❌ **Port Already in Use**
|
341 |
+
|
342 |
+
```
|
343 |
+
Address already in use
|
344 |
+
```
|
345 |
+
|
346 |
+
**Solution:**
|
347 |
+
|
348 |
+
- Close other Flask applications
|
349 |
+
- Change port in `app.py`: `app.run(port=5001)`
|
350 |
+
- Kill process: `taskkill /f /im python.exe` (Windows)
|
351 |
+
|
352 |
+
### ❌ **File Upload Issues**
|
353 |
+
|
354 |
+
```
|
355 |
+
Invalid file type or File too large
|
356 |
+
```
|
357 |
+
|
358 |
+
**Solution:**
|
359 |
+
|
360 |
+
- Use supported formats: PNG, JPG, JPEG
|
361 |
+
- Keep file size under 16MB
|
362 |
+
- Check image isn't corrupted
|
363 |
+
|
364 |
+
## 🎨 Customization
|
365 |
+
|
366 |
+
### **🎯 Add New Disease Classes**
|
367 |
+
|
368 |
+
1. Update `CLASS_NAMES` in `app.py`
|
369 |
+
2. Add descriptions in `CLASS_DESCRIPTIONS`
|
370 |
+
3. Update recommendations in `get_recommendations()`
|
371 |
+
4. Retrain model with new classes
|
372 |
+
|
373 |
+
## 📱 Mobile Responsiveness
|
374 |
+
|
375 |
+
The application is now **fully responsive** and optimized for mobile devices:
|
376 |
+
|
377 |
+
### 📲 Mobile Features:
|
378 |
+
|
379 |
+
- ✅ **Touch-friendly interface** with larger touch targets (44px minimum)
|
380 |
+
- ✅ **Responsive design** that adapts to screen sizes from 320px to desktop
|
381 |
+
- ✅ **Mobile camera support** with environment (back) camera preference
|
382 |
+
- ✅ **Optimized image display** for mobile viewports
|
383 |
+
- ✅ **Landscape/Portrait orientation** support
|
384 |
+
- ✅ **iOS Safari compatibility** with viewport fixes
|
385 |
+
- ✅ **Prevent accidental zoom** on form inputs
|
386 |
+
- ✅ **Touch-optimized drag & drop** for file uploads
|
387 |
+
|
388 |
+
### **🎨 Modify UI**
|
389 |
+
|
390 |
+
- **Colors**: Edit CSS variables in `style.css`
|
391 |
+
- **Layout**: Modify templates in `templates/`
|
392 |
+
- **Functionality**: Update JavaScript in `static/js/`
|
393 |
+
|
394 |
+
### **⚙️ Configuration**
|
395 |
+
|
396 |
+
- **Upload size**: Change `MAX_CONTENT_LENGTH` in `app.py`
|
397 |
+
- **Image size**: Modify `IMAGE_SIZE` parameter
|
398 |
+
- **Port**: Update `app.run(port=5000)` line
|
399 |
+
|
400 |
+
## 🔒 Security Notes
|
401 |
+
|
402 |
+
- **🚫 Production Use**: This is for development/research only
|
403 |
+
- **🔐 Secret Key**: Change `app.secret_key` for production
|
404 |
+
- **📁 File Validation**: Only accepts image files
|
405 |
+
- **💾 File Cleanup**: Consider automatic cleanup of old uploads
|
406 |
+
|
407 |
+
## 📈 Performance Tips
|
408 |
+
|
409 |
+
- **📸 Image Quality**: Use clear, well-lit potato leaf images
|
410 |
+
- **🎯 Focus**: Ensure leaves fill most of the frame
|
411 |
+
- **📏 Size**: Optimal size is 256x256 pixels or larger
|
412 |
+
- **🌟 Lighting**: Good natural lighting gives best results
|
413 |
+
|
414 |
+
## 🌐 Browser Compatibility
|
415 |
+
|
416 |
+
- ✅ **Chrome**: 90+
|
417 |
+
- ✅ **Firefox**: 88+
|
418 |
+
- ✅ **Safari**: 14+
|
419 |
+
- ✅ **Edge**: 90+
|
420 |
+
- ⚠️ **Mobile**: Camera features may vary
|
421 |
+
|
422 |
+
## 📄 API Endpoints
|
423 |
+
|
424 |
+
- `GET /` - Main web interface
|
425 |
+
- `POST /predict` - Upload image prediction
|
426 |
+
- `POST /predict_camera` - Camera image prediction
|
427 |
+
- `GET /health` - Application health check
|
428 |
+
|
429 |
+
## 🤝 Support
|
430 |
+
|
431 |
+
For issues or questions:
|
432 |
+
|
433 |
+
1. Check the troubleshooting section above
|
434 |
+
2. Verify your Python and dependencies versions
|
435 |
+
3. Ensure model files are in the correct location
|
436 |
+
4. Test with the provided sample images
|
437 |
+
|
438 |
+
---
|
439 |
+
|
440 |
+
## 🚀 Next Steps
|
441 |
+
|
442 |
+
### 🔮 Future Enhancements
|
443 |
+
|
444 |
+
- [ ] **Model Optimization**: Implement transfer learning with pre-trained models
|
445 |
+
- [ ] **Web Application**: Create a Flask/Streamlit web interface
|
446 |
+
- [ ] **Mobile App**: Develop a mobile application for field use
|
447 |
+
- [ ] **More Diseases**: Expand to detect additional potato diseases
|
448 |
+
- [ ] **Real-time Detection**: Implement live camera feed processing
|
449 |
+
- [ ] **API Development**: Create REST API for integration
|
450 |
+
|
451 |
+
### 🎯 Improvement Ideas
|
452 |
+
|
453 |
+
- [ ] **Hyperparameter Tuning**: Optimize model parameters
|
454 |
+
- [ ] **Cross-validation**: Implement k-fold cross-validation
|
455 |
+
- [ ] **Ensemble Methods**: Combine multiple models
|
456 |
+
- [ ] **Data Balancing**: Handle class imbalance if present
|
457 |
+
|
458 |
+
### 🐛 Bug Reports
|
459 |
+
|
460 |
+
If you find a bug, please create an issue with:
|
461 |
+
|
462 |
+
- Description of the problem
|
463 |
+
- Steps to reproduce
|
464 |
+
- Expected vs actual behavior
|
465 |
+
- System information
|
466 |
+
|
467 |
+
### 💡 Feature Requests
|
468 |
+
|
469 |
+
For new features, please provide:
|
470 |
+
|
471 |
+
- Clear description of the feature
|
472 |
+
- Use case and benefits
|
473 |
+
- Implementation suggestions```
|
474 |
+
|
475 |
+
# ==================DEBUGGING AND TROUBLESHOOTING GUIDE:===========================
|
476 |
+
|
477 |
+
# 🥔 Potato Disease Detection - Upload Functionality Guide
|
478 |
+
|
479 |
+
## 🚀 Quick Start
|
480 |
+
|
481 |
+
1. **Run the Application**:
|
482 |
+
|
483 |
+
```bash
|
484 |
+
python app.py
|
485 |
+
```
|
486 |
+
|
487 |
+
Or double-click `run_and_test.bat`
|
488 |
+
|
489 |
+
2. **Access the App**:
|
490 |
+
- Main app: http://localhost:5000
|
491 |
+
- Debug upload page: http://localhost:5000/debug
|
492 |
+
- Health check: http://localhost:5000/health
|
493 |
+
|
494 |
+
## 📋 Testing Upload Functionality
|
495 |
+
|
496 |
+
### Step 1: Check System Health
|
497 |
+
|
498 |
+
1. Go to http://localhost:5000/debug
|
499 |
+
2. Click "🔍 Check System Health"
|
500 |
+
3. Verify all items show ✅:
|
501 |
+
- Status: healthy
|
502 |
+
- Model Loaded: Yes
|
503 |
+
- Upload Dir Exists: Yes
|
504 |
+
- Upload Dir Writable: Yes
|
505 |
+
|
506 |
+
### Step 2: Test Upload Directory
|
507 |
+
|
508 |
+
1. Click "📂 Test Upload Directory"
|
509 |
+
2. Should show "Upload directory is working correctly"
|
510 |
+
|
511 |
+
### Step 3: Test Image Upload
|
512 |
+
|
513 |
+
1. Click "📁 Click here to select an image" or drag an image
|
514 |
+
2. Select a potato leaf image (JPG, PNG, JPEG)
|
515 |
+
3. Preview should appear
|
516 |
+
4. Click "🔬 Analyze Disease"
|
517 |
+
5. Results should show:
|
518 |
+
- Disease name and confidence
|
519 |
+
- Recommendations
|
520 |
+
- The analyzed image displayed
|
521 |
+
|
522 |
+
## 🔧 Troubleshooting Upload Issues
|
523 |
+
|
524 |
+
### Issue: "No file uploaded" Error
|
525 |
+
|
526 |
+
**Solutions:**
|
527 |
+
|
528 |
+
1. Ensure you're clicking the upload area or browse link
|
529 |
+
2. Check browser console for JavaScript errors (F12)
|
530 |
+
3. Try the debug page: http://localhost:5000/debug
|
531 |
+
4. **Mobile**: Tap firmly on upload area, wait for file picker
|
532 |
+
|
533 |
+
### Issue: File Not Saving
|
534 |
+
|
535 |
+
**Solutions:**
|
536 |
+
|
537 |
+
1. Check upload directory permissions:
|
538 |
+
```bash
|
539 |
+
mkdir static/uploads
|
540 |
+
```
|
541 |
+
2. Run as administrator if on Windows
|
542 |
+
3. Check disk space
|
543 |
+
4. **Mobile**: Ensure stable network connection
|
544 |
+
|
545 |
+
### Issue: Camera Not Working (Mobile)
|
546 |
+
|
547 |
+
**Solutions:**
|
548 |
+
|
549 |
+
1. **Grant camera permissions** when prompted
|
550 |
+
2. **Use HTTPS** for camera access on mobile (required by browsers)
|
551 |
+
3. **Check camera availability** - some devices block camera access
|
552 |
+
4. **Try different browsers** (Chrome/Safari work best)
|
553 |
+
5. **Close other camera apps** that might be using the camera
|
554 |
+
|
555 |
+
### Issue: Touch/Tap Not Working (Mobile)
|
556 |
+
|
557 |
+
**Solutions:**
|
558 |
+
|
559 |
+
1. **Clear browser cache** and reload
|
560 |
+
2. **Disable browser zoom** if enabled
|
561 |
+
3. **Try two-finger tap** if single tap doesn't work
|
562 |
+
4. **Check touch targets** - buttons should be at least 44px
|
563 |
+
5. **Restart browser app** on mobile device
|
564 |
+
|
565 |
+
### Issue: Image Too Small/Large on Mobile
|
566 |
+
|
567 |
+
**Solutions:**
|
568 |
+
|
569 |
+
1. **Portrait orientation** usually works better
|
570 |
+
2. **Pinch to zoom** on images if needed
|
571 |
+
3. **Landscape mode** available for wider screens
|
572 |
+
4. **Image auto-resizes** based on screen size
|
573 |
+
|
574 |
+
### Issue: Slow Performance on Mobile
|
575 |
+
|
576 |
+
**Solutions:**
|
577 |
+
|
578 |
+
1. **Close other browser tabs** to free memory
|
579 |
+
2. **Use smaller image files** (under 5MB recommended)
|
580 |
+
3. **Ensure good network connection** for uploads
|
581 |
+
4. **Clear browser cache** regularly
|
582 |
+
5. **Restart browser** if app becomes unresponsive
|
583 |
+
|
584 |
+
### Issue: Model Not Loading
|
585 |
+
|
586 |
+
**Solutions:**
|
587 |
+
|
588 |
+
1. Verify model file exists: `models/1.h5`
|
589 |
+
2. Install required packages:
|
590 |
+
```bash
|
591 |
+
pip install tensorflow pillow flask
|
592 |
+
```
|
593 |
+
|
594 |
+
### Issue: JavaScript Errors
|
595 |
+
|
596 |
+
**Solutions:**
|
597 |
+
|
598 |
+
1. Clear browser cache (Ctrl+F5)
|
599 |
+
2. Check browser console (F12)
|
600 |
+
3. Try a different browser
|
601 |
+
4. Disable browser extensions
|
602 |
+
|
603 |
+
### Issue: Image Not Displaying in Results
|
604 |
+
|
605 |
+
**Solutions:**
|
606 |
+
|
607 |
+
1. Check browser network tab (F12) for failed requests
|
608 |
+
2. Verify uploaded file in `static/uploads/` folder
|
609 |
+
3. Check Flask console for file save errors
|
610 |
+
|
611 |
+
## 🧪 Debug Features
|
612 |
+
|
613 |
+
### Console Logging
|
614 |
+
|
615 |
+
The JavaScript includes extensive console logging. Open browser developer tools (F12) to see:
|
616 |
+
|
617 |
+
- File selection events
|
618 |
+
- Upload progress
|
619 |
+
- Server responses
|
620 |
+
- Error details
|
621 |
+
|
622 |
+
### Debug Endpoints
|
623 |
+
|
624 |
+
- `/health` - System status
|
625 |
+
- `/debug/upload-test` - Upload directory test
|
626 |
+
- `/debug` - Interactive upload test page
|
627 |
+
|
628 |
+
### Manual Testing
|
629 |
+
|
630 |
+
1. **File Input Test**:
|
631 |
+
|
632 |
+
```javascript
|
633 |
+
document.getElementById("fileInput").click();
|
634 |
+
```
|
635 |
+
|
636 |
+
2. **Check Selected File**:
|
637 |
+
|
638 |
+
```javascript
|
639 |
+
console.log(selectedFile);
|
640 |
+
```
|
641 |
+
|
642 |
+
3. **Test FormData**:
|
643 |
+
```javascript
|
644 |
+
const formData = new FormData();
|
645 |
+
formData.append("file", selectedFile);
|
646 |
+
console.log([...formData.entries()]);
|
647 |
+
```
|
648 |
+
|
649 |
+
## 💡 Tips for Success
|
650 |
+
|
651 |
+
1. **Use supported image formats**: JPG, PNG, JPEG, GIF
|
652 |
+
2. **Keep file size under 16MB**
|
653 |
+
3. **Use clear potato leaf images**
|
654 |
+
4. **Check browser compatibility** (modern browsers work best)
|
655 |
+
5. **Enable JavaScript**
|
656 |
+
6. **Allow camera permissions** (for camera capture feature)
|
657 |
+
|
658 |
+
## 🆘 Getting Help
|
659 |
+
|
660 |
+
If upload functionality still doesn't work:
|
661 |
+
|
662 |
+
1. **Check Flask console output** for error messages
|
663 |
+
2. **Check browser console** (F12 → Console tab)
|
664 |
+
3. **Try the debug page** at `/debug`
|
665 |
+
4. **Test with different image files**
|
666 |
+
5. **Restart the Flask app**
|
667 |
+
6. **Check file permissions** on the upload directory
|
668 |
+
|
669 |
+
## 🎯 Expected Results
|
670 |
+
|
671 |
+
After successful upload and analysis:
|
672 |
+
|
673 |
+
- ✅ Disease classification (Early Blight, Late Blight, or Healthy)
|
674 |
+
- ✅ Confidence percentage
|
675 |
+
- ✅ Treatment recommendations
|
676 |
+
- ✅ Analyzed image displayed in results
|
677 |
+
- ✅ Timestamp of analysis
|
678 |
+
|
679 |
+
# PDF Report Download Upgrade Guide
|
680 |
+
|
681 |
+
## 🎉 New Features Added
|
682 |
+
|
683 |
+
### ✨ **PDF Format**
|
684 |
+
|
685 |
+
- Professional PDF reports instead of simple text files
|
686 |
+
- Includes header, footer, tables, and proper formatting
|
687 |
+
- Company branding and professional layout
|
688 |
+
|
689 |
+
### 📁 **Folder Selection**
|
690 |
+
|
691 |
+
- Choose where to save your PDF reports
|
692 |
+
- Modern file picker dialog (supported browsers)
|
693 |
+
- Automatic fallback to default downloads folder
|
694 |
+
|
695 |
+
### 🎨 **Enhanced Report Content**
|
696 |
+
|
697 |
+
- **Report Header**: Timestamp, analysis method, model version
|
698 |
+
- **Analyzed Image**: Embedded image (if available)
|
699 |
+
- **Diagnosis Section**: Disease name, confidence, risk assessment
|
700 |
+
- **Probability Breakdown**: Table showing all class probabilities
|
701 |
+
- **Treatment Recommendations**: Numbered list of actionable advice
|
702 |
+
- **Professional Footer**: Branding and copyright information
|
703 |
+
|
704 |
+
## 🚀 Installation Requirements
|
705 |
+
|
706 |
+
Add to your `requirements.txt`:
|
707 |
+
|
708 |
+
```
|
709 |
+
reportlab>=4.0.0
|
710 |
+
```
|
711 |
+
|
712 |
+
Install the new dependency:
|
713 |
+
|
714 |
+
```bash
|
715 |
+
pip install reportlab>=4.0.0
|
716 |
+
```
|
717 |
+
|
718 |
+
# PDF Generation Troubleshooting Guide
|
719 |
+
|
720 |
+
## 🔧 If PDF Generation is Failing
|
721 |
+
|
722 |
+
### Quick Fix Steps
|
723 |
+
|
724 |
+
1. **Install ReportLab Library**
|
725 |
+
|
726 |
+
```bash
|
727 |
+
pip install reportlab>=4.0.0
|
728 |
+
```
|
729 |
+
|
730 |
+
2. **Run Installation Script**
|
731 |
+
|
732 |
+
- **Windows**: Double-click `install_pdf_deps.bat`
|
733 |
+
- **Linux/Mac**: Run `bash install_pdf_deps.sh`
|
734 |
+
|
735 |
+
3. **Restart the Application**
|
736 |
+
```bash
|
737 |
+
python app.py
|
738 |
+
```
|
739 |
+
|
740 |
+
### Common Issues and Solutions
|
741 |
+
|
742 |
+
#### ❌ **"ReportLab not available" Error**
|
743 |
+
|
744 |
+
**Problem**: ReportLab library is not installed.
|
745 |
+
|
746 |
+
**Solution**:
|
747 |
+
|
748 |
+
```bash
|
749 |
+
pip install reportlab
|
750 |
+
# or
|
751 |
+
pip install reportlab>=4.0.0
|
752 |
+
```
|
753 |
+
|
754 |
+
**Alternative**: Use virtual environment
|
755 |
+
|
756 |
+
```bash
|
757 |
+
python -m venv pdf_env
|
758 |
+
source pdf_env/bin/activate # Linux/Mac
|
759 |
+
# or
|
760 |
+
pdf_env\Scripts\activate # Windows
|
761 |
+
pip install reportlab
|
762 |
+
```
|
763 |
+
|
764 |
+
#### ❌ **"Permission denied" or "Access denied" Errors**
|
765 |
+
|
766 |
+
**Problem**: Insufficient permissions to install packages.
|
767 |
+
|
768 |
+
**Solutions**:
|
769 |
+
|
770 |
+
1. **Use --user flag**:
|
771 |
+
|
772 |
+
```bash
|
773 |
+
pip install --user reportlab
|
774 |
+
```
|
775 |
+
|
776 |
+
2. **Run as administrator** (Windows):
|
777 |
+
|
778 |
+
- Right-click Command Prompt → "Run as administrator"
|
779 |
+
- Then run: `pip install reportlab`
|
780 |
+
|
781 |
+
3. **Use sudo** (Linux/Mac):
|
782 |
+
```bash
|
783 |
+
sudo pip install reportlab
|
784 |
+
```
|
785 |
+
|
786 |
+
#### ❌ **"Module not found" Error Despite Installation**
|
787 |
+
|
788 |
+
**Problem**: ReportLab installed in different Python environment.
|
789 |
+
|
790 |
+
**Solutions**:
|
791 |
+
|
792 |
+
1. **Check Python version**:
|
793 |
+
|
794 |
+
```bash
|
795 |
+
python --version
|
796 |
+
which python # Linux/Mac
|
797 |
+
where python # Windows
|
798 |
+
```
|
799 |
+
|
800 |
+
2. **Install for specific Python version**:
|
801 |
+
|
802 |
+
```bash
|
803 |
+
python3 -m pip install reportlab
|
804 |
+
# or
|
805 |
+
python3.9 -m pip install reportlab
|
806 |
+
```
|
807 |
+
|
808 |
+
3. **Verify installation**:
|
809 |
+
```bash
|
810 |
+
python -c "import reportlab; print('ReportLab available')"
|
811 |
+
```
|
812 |
+
|
813 |
+
#### ❌ **PDF Generation Works but Images Missing**
|
814 |
+
|
815 |
+
**Problem**: Image files not accessible or corrupted.
|
816 |
+
|
817 |
+
**Solutions**:
|
818 |
+
|
819 |
+
1. **Check upload folder permissions**:
|
820 |
+
|
821 |
+
```bash
|
822 |
+
ls -la static/uploads/ # Linux/Mac
|
823 |
+
dir static\uploads\ # Windows
|
824 |
+
```
|
825 |
+
|
826 |
+
2. **Verify image exists**:
|
827 |
+
|
828 |
+
- Check browser developer tools for 404 errors
|
829 |
+
- Ensure images are properly saved during upload
|
830 |
+
|
831 |
+
3. **Check image format**:
|
832 |
+
- Ensure images are JPG, PNG, or supported formats
|
833 |
+
- ReportLab may have issues with some image formats
|
834 |
+
|
835 |
+
#### ❌ **Client-side PDF Generation Fails**
|
836 |
+
|
837 |
+
**Problem**: jsPDF library not loading.
|
838 |
+
|
839 |
+
**Solutions**:
|
840 |
+
|
841 |
+
1. **Check internet connection** (jsPDF loads from CDN)
|
842 |
+
|
843 |
+
2. **Check browser console** for JavaScript errors
|
844 |
+
|
845 |
+
#### ❌ **Folder Selection Not Working**
|
846 |
+
|
847 |
+
**Problem**: File System Access API not supported.
|
848 |
+
|
849 |
+
**Solutions**:
|
850 |
+
|
851 |
+
1. **Update browser**:
|
852 |
+
|
853 |
+
- Chrome 86+ or Edge 86+ required for folder selection
|
854 |
+
- Firefox and Safari will use default download folder
|
855 |
+
|
856 |
+
2. **Enable experimental features** (Chrome):
|
857 |
+
|
858 |
+
- Go to `chrome://flags`
|
859 |
+
- Enable "Experimental Web Platform features"
|
860 |
+
|
861 |
+
3. **Accept automatic download** to default folder
|
862 |
+
|
863 |
+
The system should work with any clear image of a potato plant leaf!
|
864 |
+
|
865 |
+
## 📄 License
|
866 |
+
|
867 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
868 |
+
|
869 |
+
## 🙏 Acknowledgments
|
870 |
+
|
871 |
+
- **PlantVillage Dataset**: For providing the potato disease dataset
|
872 |
+
- **TensorFlow Team**: For the amazing deep learning framework
|
873 |
+
- **Open Source Community**: For inspiration and resources
|
874 |
+
|
875 |
+
## 📞 Contact
|
876 |
+
|
877 |
+
- **Author**: Lucky Sharma
|
878 |
+
- **Email**: [email protected]
|
879 |
+
- **LinkedIn**: https://www.linkedin.com/in/lucky-sharma918894599977
|
880 |
+
- **GitHub**: https://github.com/itsluckysharma01
|
881 |
+
|
882 |
+
---
|
883 |
+
|
884 |
+
<div align="center">
|
885 |
+
<p>⭐ Star this repository if you found it helpful!</p>
|
886 |
+
<p>🍀 Happy coding and may your potatoes be healthy!</p>
|
887 |
+
</div>
|
888 |
+
"
|