Viñamecum: A Computer-Aided Method for Diagnoses of Pests and Diseases in the Vineyard

: Information and telecommunication technologies (ICTs) offer new opportunities to provide more timely information services to farmers. This work aims to present a progressive web app (PWA) for mobile devices, which incorporates updated technical information on the pests and diseases of grapevines. In its development, it generated a database with content related to and photographs of grapevine pests and diseases for access by users using mobile devices. In addition, using an Expert System, the application allows the diagnosis of pathologies and the identiﬁcation of pests by answering questions that are asked. This PWA is mainly addressed to technicians, students, and winegrowers who want to implement more environmentally friendly crop management strategies. Viñamecum is currently freely.


Introduction
Grapevines (Vitis vinifera and Vitis spp.) are one of the most extensively grown and economically important woody perennial fruit crops in the world [1]. According to the FAO (2019) [2], the European continent, with 3.46 million ha and 26.7 million t, leads grape production worldwide and is followed by Asia (1.99 million ha and 29.51 million t), America (0.96 million ha and 14.4 millon t), Africa (0.34 million ha and 4.89 millon t), and Oceania (0.17 million ha and 1.97 millon t). Its cultivation is limited by the climatic demands imposed by optimal plant development [3] and the incidence of diseases and pests, which can compromise its productivity [4,5]. Chemical control has traditionally been used in conventional viticulture to control pests and diseases in the vineyard [6]. However, this practice is potentially leading to pollution [7] and human health issues [8]. For this reason, the use of phytosanitary products has been regulated in some countries. For example, in Europe, the Directive 2009/128/EC [9] established a framework for Community action to achieve the sustainable use of pesticides and the promotion of integrated pest management (IPM). IPM is an ecosystem-based strategy that focuses on the long-term prevention of crop pests and diseases through different techniques that include the use of resistant varieties, biological control, habitat management, modification of cultural practices and, when needed, judicious and timely use of chemical controls [10,11]. To implement this strategy in vineyard management, it is necessary to have qualified technical personnel and provide specific information to farmers so that they can act under the premises of the IPM.
The widespread growth of information and telecommunication technologies (ICTs) in rural areas offers new opportunities to provide more timely and low-cost information services to farmers, as well as assists in coordinating agricultural agents [12]. Moreover, the enormous progress of mobile devices has opened up a wide range of opportunities that were previously unfeasible. Their portability and computing performance are features that have allowed the development of innovative applications in fields such as medicine, sports, and agriculture [13]. However, in the field of viticulture, new technologies and modern management techniques are needed to ensure and facilitate a correct performance of the winegrowers in order to obtain a quality harvest and reduce the environmental impact. The goal of the present work was to develop a novel smartphone application, called Viñamecum [14], to facilitate a correct control of grapevine diseases and pests and boost IPM in vineyards. This application allows the identification of species suspected to act as pests or pathogens in the vineyard and incorporates technical information on their biological cycles, the different control strategies and images of the damages or symptoms they cause. The application was developed and implemented for mobile devices with the aim of maximizing its availability to users.

Solution Adopted: Viñamecum
Viñamecum is a PWA application that incorporates technical information on vineyard pests and diseases and allows the identification of pests and diseases through the use of an expert system. This PWA application is currently freely available at https://fcc.uca.es/ web/vinamecum, accessed on 10 March 2021.
For the design and development of the "Viñamecum" application, the target users, the areas or places where it can be used and the applicability of the tool have been considered.
Due mainly to the fact that the native language of the users to whom this application was originally addressed is Spanish, the language used throughout the application is Spanish. Another factor to take into account in the choice of language was the lack of such applications targeted at native Spanish-speaking users. For instance, in other languages, we found applications such as "Di@gnoPlant Vigne" developed by the French National Institute for Agricultural Research (INRA) [15], "MyVigneto Care" in Italian [16], and "Pests and Diseases of Grapes" written in English, but in a non-technical language and with the downloading involving economic costs [17]. The application is planned to be translated into other languages in the future.
Furthermore, a technology was required that would allow it to run on a mobile device, be easy to install and be used with poor connections so that it could be used in places with poor mobile coverage. In addition, the application would have to be fast and resourceefficient. Other desirable features were that it should be easily upgradable, have a simple interface and offer the possibility of user notifications.
There are different tools that could be used in the development of mobile apps. In this work, PWAs were chosen [18]. A search for "PWA the future of mobile apps" in Google generates numerous outputs that illustrate the importance of this technology in the development of applications. The first result tells us: "Progressive Web Application (PWA) is truly considered the future of multi-platform development because of its application on several devices, the improved speed, and the easiness that requires no installation or updates". We could say that a PWA is an enhanced web page, although its development is not entirely straightforward since they have several features that must be implemented.
The main reasons for the choice of this technology were as follows: 1.
Available offline: it allows to have the data available even if we do not have internet connection, which is very desirable due to the environment in which the application will be used.

2.
Security: the idea is that a farmer can contribute to the application and introduce warning systems. PWAs have enhanced security features and for example impose the use of encrypted connections (Hypertext Transfer Protocol Secure protocol). This is essential when sending data anonymously over the internet.
Some of the features of this technology are discussed in more detail below.

Progressive Web Applications
A Progressive Web Application (PWA) is a type of application software delivered over the web [18], created using common web technologies such as HTML, CSS, and JavaScript. The origins of PWAs can be traced back to the launch of the iPhone in 2007. Steve Jobs announced that web applications, developed in HTML5 using the AJAX architecture [19], would be the standard format for iPhone applications. No software development kit (SDK) was required, and applications would be fully integrated into the device through the Safari browser engine. This model was later changed for the App Store [20], as a means to avoid jailbreakers and appease frustrated developers. In October 2007, Jobs announced that an SDK would be released the following year. As a result, although Apple continued to support web apps, the vast majority of iOS apps shifted to the App Store.
This type of application is intended to run on any platform that uses a standardscompliant browser. In addition, its includes working offline, push notifications, and device hardware access, enabling user experiences similar to native apps on mobile and desktop devices. Since a progressive web app is a web page or website known as a web app, there is no requirement for developers or users to install web apps through digital distribution systems such as the Apple App Store [20] or Google Play [21].
While web apps have been available for mobile devices since the beginning, they have generally been slower, less feature-rich, and less widely used than native apps. However, with the ability to work offline, which was previously only available to native apps, PWAs running on mobile devices can run much faster and provide more features, closing the gap with native apps, and being portable on desktop and mobile platforms (see [18] for further details).
One of the main advantages of the PWAs is that they do not require separate bundling or distribution. Publishing a progressive web app is the same process as it would be for any other web page. PWAs work in any browser, but "app-like" features, such as connectivity independent, installing on the home screen, and sending messages, depending on browser compatibility. As of April 2018, these features are supported to varying degrees in Microsoft Edge, Google Chrome, Mozilla Firefox, and Apple Safari browsers, but more browsers may support the future's necessary features.
The core of a PWA is in a program named Service Worker (SW), which is just a JavaScript program. It operates separately from the main browser to handle push notifications, synchronize background data, caches or retrieve resource requests, intercept network requests and receive centralized updates. SWs are used to give PWAs the ability to deliver the high performance and rich experience of native mobile apps, to provide real-time updates, and to improve search engine visibility of traditional web apps.
From a technical point of view, SWs go through a three-step lifecycle of registration, installation, and activation. Registration involves telling the browser the location of the service worker in preparation for installation. Installation occurs when there is no service worker installed in the browser for the web application or an update to the service worker. Activation occurs when all PWA pages are closed, so there is no conflict between the previous version and the updated version. The lifecycle also maintains consistency when switching between service worker versions, as only a single service worker can be active for a domain. For more details on these steps, the reader is referred to [18] (Chapter 4). Technically, SWs provide a programmable network proxy in the web browser to manage web/HTTP requests programmatically. Service workers sit between the network and the device to deliver content. They can use caching mechanisms efficiently and enable error-free behavior during offline periods.
Finally, we emphasize that PWAs can be installed on mobile, but this is unnecessary as the same tasks can be carried out simply through the web. In other words, they do not require installation; thanks to this feature, they offer important advantages: better performance, short loading times, interface similar to that of a native app, automatic updating, responsive design, push notifications, secure TLS protocol, and no internet connection. The technology used to develop PWAs provides a cross-platform system, independent of the browser and operating system. This means that there is no need to develop specific programming for each operating system, which greatly reduces costs.

Knowledge Base and Expert System
An expert system is a computer system emulating the decision-making ability of a human expert [22]. Expert systems are designed to solve complex problems by reasoning through knowledge bodies, represented mainly as if-then rules rather than through a conventional procedural code. The components of the expert system used in this app are the following: • Knowledge Base: in this component, facts, and rules are represented. Knowledge in a particular domain is stored here and rules for solving a problem, procedures, and intrinsic data relevant to the domain. • Inference engine is the brain of the expert system. Its function is to obtain the knowledge base's relevant knowledge, interpret it, and find a relevant solution to the user's problem. It contains the rules of its knowledge base and applies them to known facts to infer new facts.
The main part of this application is the Knowledge Base. There are different forms of storage for it. In this application, the form adopted has been a spreadsheet in which each row is a disease/pest, and each column is a symptom/damage. The "1" or "0" mark indicates whether, for a disease/pest, a symptom/damage appears or not. From a mathematical perspective, it is nothing more than a matrix of m rows (number of diseases/pests) and n columns (number of symptoms/damages) with zeros and ones in their entries. We denote the set of matrices of this form by (Z 2 ) m×n .

User Interface
One of the most important parts of an application is the user interface. In this app, we had to make a design that made it possible for non-expert users (some of them had never worked with this kind of technology before) to interact with the program and that users could easily send all the errors found in it.
We chose to implement a very simple diagnostic system. The user only has to answer 1 (if the symptom/damage is present) or 0 (if it is not present). Once detected, the user will be redirected to a page with the characteristics of the disease/pest. The app also has many illustrations, as you can see in the example in the Section 3. The total amount of pictures used in the app is around 400. All these images make it easy for the farmer to identify the symptoms or damages caused by diseases or pests in the vineyard and they make possible to obtain a diagnosis in situ. In addition, the app includes the different strategies the farmer can use to control the diseases and pests. For instance, a link is provided to the website of the "Ministerio de Agricultura, Pesca y Alimentación" (Spain) [23] that regulates the active substances authorized for phytosanitary control.

The Efficiency of the System
We can view our knowledge base as a matrix A of m rows (diseases/pests) and n columns (symptoms/damages). Formally, we can say that we have an A matrix (Z 2 ) m×n . We will see each row as the set of symptoms of a disease.
The process to determine the disease or pest consists of asking for possible symptoms/damages through the user interface. If the symptoms or damage is present, all rows (diseases/pests) that do not manifest that symptom/damage (all rows with a 0 in that column) will be deleted. If the answer is negative, it eliminates the rows that manifest the symptom/damage (all rows with a 1 in that column). The implementation in pseudo-code is showed in Algorithm 1.
The average maximum time needed to obtain an answer is log(m), where m is the number of rows (diseases and pests classified). We have to take into account that after performing the first steps of the algorithm, our matrix will be equal to the following one: In each step, the algorithm eliminates on average half of the rows. The actions performed at each step with the matrix consist of eliminating one of the rows that do not meet the condition. If the random value is q, the resulting matrix would be as follows: The efficiency of the algorithm is based on the search for the elements of a column that are equal to 1 or 0 (depending on the user's answer).The column to be examined is obtained directly from the matrix and to determine the diseases or pests we are left with, only the rows that have not been discarded so far have to be examined. A tree design could have been used to store all the information, but making it in the form of a matrix makes it much easier to maintain. For example, adding new diseases is as simple as adding a new item to our disease database (the current list of pests and diseases is shown in Table 1).
On the other hand, this form of storage allows us to see the existing relationships between the symptoms of each of the diseases and to establish between them different chains of diseases and symptomatology. From a mathematical point of view, what we have is a graph [24] that relates the different diseases/pests and establishes a distance and a partial order between each of them. The detection of nearby diseases/pests in adjacent areas could enable us to detect diseases with very similar symptomatologies.

A Complete Example
This application can be accessed at the site Viñamecum, accessed on 10 March 2021. From there, the installation is quite simple. When selecting the option "Viñamecum" from the menu, the first three images in the Figure 1 will be seen. Then, Algorithm 1 will be executed.
When answered, the program will ask us a question that will make the algorithm perform a loop, and as many questions as necessary will be asked to determine the disease from the symptoms. Once a solution is obtained, the program will display it, and a message will be sent with a link to the description of the disease and its treatment, as shown in Table 2.  As can be seen, all the diseases/pests have been illustrated completely so that the specialist can appreciate the validity of the result obtained in the application. In Figure 2, we can see the images availables in the app for Drepanotrips reuteri Uzel.

Conclusions
Based on our experience with the application from its development to its implementation, we have seen that this type of app has a practical application in viticulture. The use of these applications can facilitate integrated pest management.
It is important to highlight that these applications must have the following characteristics: • Ease of use for farmers; • Easy installation on mobile devices. PWAs make all this work much easier; • Automatic updates. PWAs provide simple mechanisms for this purpose; • They have to provide clear solutions as quickly as possible. The farmers are experts, although it is sometimes difficult to handle so much information on diseases and pests. That is why this type of initiative is so well received on their part; • They must be available in places with no or poor connections. Crop sites are sometimes far away from communication towers. This is why PWAs are the most appropriate solution; • The use of mobile devices and the lack of connection make it so that large databases cannot be accessed. Thus, the knowledge base and inference engine used are simple, but in this context, they are a quite effective tool. In addition, the simplicity of the inference engine makes mobile devices suitable for this type of application.
Finally, we would like to emphasize that this paper is just an introductive contribution to the diffusion and the knowledge of the software Viñamecum. Our goal is to have its content continuously updated over time as it is already being used and we are receiving a lot of feedback from the users to improve it.

Patents
The "Viñamecum" application was registered on 27 November 2018 with reference CA-256-18 in the "Registrador Territorial de la Propiedad Intelectual de la Comunidad Autónoma de Andalucia", Spain. Funding: The first and third authors were supported partially by Junta de Andalucía research group FQM-366 and by the project MTM2017-84890-P (MINECO/FEDER, UE). We would like to thank all those who have generously collaborated in the development of this application by allowing the use of their pictures. Among the contributors we would like to highlight the following institutions: UC Davis, University of California: Agricultura y Recursos Naturales (California), Unit State Forest Service, University of Georgia, Consejo Superior de Investigaciones Científicas, INRA (France), Ministério da Agricultura, Pecuária e Abastecimento.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: