{"id":18989,"date":"2023-06-12T13:30:15","date_gmt":"2023-06-12T11:30:15","guid":{"rendered":"https:\/\/www.graviton.at\/letterswaplibrary\/need-a-dataset-for-fruit-disease-detection-i-will-show-the-code-below-and-pls-tell-me-a-dataset-and-how-to-use-it-im-a-total-idiot-when-it-comes-to-this-i-learnt-theory-abt-it-but-not-that-much-pr\/"},"modified":"2023-06-24T10:42:16","modified_gmt":"2023-06-24T08:42:16","slug":"need-a-dataset-for-fruit-disease-detection-i-will-show-the-code-below-and-pls-tell-me-a-dataset-and-how-to-use-it-im-a-total-idiot-when-it-comes-to-this-i-learnt-theory-abt-it-but-not-that-much-pr","status":"publish","type":"post","link":"https:\/\/www.graviton.at\/letterswaplibrary\/need-a-dataset-for-fruit-disease-detection-i-will-show-the-code-below-and-pls-tell-me-a-dataset-and-how-to-use-it-im-a-total-idiot-when-it-comes-to-this-i-learnt-theory-abt-it-but-not-that-much-pr\/","title":{"rendered":"Need A Dataset For Fruit Disease Detection I Will Show The Code Below And Pls Tell Me A Dataset And How To Use It. I&#8217;m A Total Idiot When It Comes To This. I Learnt Theory ABT It But Not That Much Practicals..can Somebody Help"},"content":{"rendered":"<p><!-- SC_OFF --><\/p>\n<div class=\"md\">\n<p>import os import cv2 import numpy as np<\/p>\n<h1>Data organization<\/h1>\n<p>dataset_root = &#8216;path_to_dataset_root_directory&#8217; categories = [&#8216;healthy&#8217;, &#8216;diseased&#8217;]<\/p>\n<p>for category in categories: category_dir = os.path.join(dataset_root, category) images = os.listdir(category_dir) for image_name in images: image_path = os.path.join(category_dir, image_name) # Perform further processing on each image<\/p>\n<h1>Preprocessing and disease detection<\/h1>\n<p>def preprocess_and_detect_disease(image_path): # Load the image image = cv2.imread(image_path)<\/p>\n<p> # Preprocess the image gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) blurred_image = cv2.GaussianBlur(gray_image, (5, 5), 0) # Apply image processing techniques (e.g., thresholding) _, thresholded_image = cv2.threshold(blurred_image, 100, 255, cv2.THRESH_BINARY) # Find contours in the image contours, _ = cv2.findContours(thresholded_image.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Loop over the contours and detect fruit disease for contour in contours: # Calculate the area of the contour area = cv2.contourArea(contour) # Set a threshold for disease detection threshold_area = 5000 if area &gt; threshold_area: # Draw a bounding box around the detected fruit x, y, w, h = cv2.boundingRect(contour) cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2) # Display the output image cv2.imshow(&#8216;Fruit Disease Detection&#8217;, image) cv2.waitKey(0) cv2.destroyAllWindows()  <\/p>\n<h1>Example usage<\/h1>\n<p>image_path = &#8216;path_to_your_image.jpg&#8217; preprocess_and_detect_disease(image_path)<\/p>\n<\/div>\n<p><!-- SC_ON -->   submitted by   <a href=\"https:\/\/www.reddit.com\/user\/No-Bad-5051\"> \/u\/No-Bad-5051 <\/a> <br \/> <span><a href=\"https:\/\/www.reddit.com\/r\/datasets\/comments\/141l7i9\/need_a_dataset_for_fruit_disease_detection_i_will\/\">[link]<\/a><\/span>   <span><a href=\"https:\/\/www.reddit.com\/r\/datasets\/comments\/141l7i9\/need_a_dataset_for_fruit_disease_detection_i_will\/\">[comments]<\/a><\/span><\/p><div class='watch-action'><div class='watch-position align-right'><div class='action-like'><a class='lbg-style1 like-18989 jlk' href='javascript:void(0)' data-task='like' data-post_id='18989' data-nonce='65e0e39b87' rel='nofollow'><img class='wti-pixel' src='https:\/\/www.graviton.at\/letterswaplibrary\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Like' \/><span class='lc-18989 lc'>0<\/span><\/a><\/div><\/div> <div class='status-18989 status align-right'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>import os import cv2 import numpy as np Data organization dataset_root = &#8216;path_to_dataset_root_directory&#8217; categories = [&#8216;healthy&#8217;, &#8216;diseased&#8217;]&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[27],"class_list":["post-18989","post","type-post","status-publish","format-standard","hentry","category-datatards","tag-english","wpcat-85-id"],"_links":{"self":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/comments?post=18989"}],"version-history":[{"count":1,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18989\/revisions"}],"predecessor-version":[{"id":19353,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18989\/revisions\/19353"}],"wp:attachment":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/media?parent=18989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/categories?post=18989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/tags?post=18989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}