RandomCatLover commited on
Commit
1179283
·
1 Parent(s): 993300b

added stuff

Browse files
Files changed (4) hide show
  1. TomatoHealthy2.jpg +0 -0
  2. TomatoYellowCurlVirus3.jpg +0 -0
  3. gr.py +26 -0
  4. requirements.txt +99 -0
TomatoHealthy2.jpg ADDED
TomatoYellowCurlVirus3.jpg ADDED
gr.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+ import tensorflow as tf
4
+ import numpy as np
5
+ import cv2
6
+ # %%
7
+ model_folder = 'plants_disease'
8
+ with open(f'{model_folder}/labels.txt', 'r') as f:
9
+ labels = f.read().split('\n')
10
+
11
+ # model = tf.saved_model.load(f'{model_folder}/last_layer.hdf5')
12
+ model = tf.keras.models.load_model(f'{model_folder}/last_layer.hdf5')
13
+ # %%
14
+ def classify_image(model, inp):
15
+ inp = cv2.resize(inp, (224,224,))
16
+ inp = inp.reshape((-1, 224, 224, 3))
17
+ inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
18
+ prediction = model.predict(inp).flatten()
19
+ print(prediction)
20
+ confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
21
+ return confidences
22
+
23
+ gr.Interface(fn=classify_image,
24
+ inputs=gr.Image(shape=(224, 224)),
25
+ outputs=gr.Label(num_top_classes=3),
26
+ examples=["TomatoHealthy2.jpg", "TomatoYellowCurlVirus3.jpg"]).launch()
requirements.txt ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.4.0
2
+ aiofiles==23.1.0
3
+ aiohttp==3.8.4
4
+ aiosignal==1.3.1
5
+ altair==5.0.0
6
+ anyio==3.6.2
7
+ astunparse==1.6.3
8
+ async-timeout==4.0.2
9
+ attrs==23.1.0
10
+ cachetools==5.3.0
11
+ certifi==2023.5.7
12
+ charset-normalizer==3.1.0
13
+ click==8.1.3
14
+ contourpy==1.0.7
15
+ cycler==0.11.0
16
+ fastapi==0.95.2
17
+ ffmpy==0.3.0
18
+ filelock==3.12.0
19
+ flatbuffers==23.5.9
20
+ fonttools==4.39.4
21
+ frozenlist==1.3.3
22
+ fsspec==2023.5.0
23
+ gast==0.4.0
24
+ google-auth==2.18.1
25
+ google-auth-oauthlib==1.0.0
26
+ google-pasta==0.2.0
27
+ gradio==3.31.0
28
+ gradio_client==0.2.5
29
+ grpcio==1.54.2
30
+ h11==0.14.0
31
+ h5py==3.8.0
32
+ httpcore==0.17.1
33
+ httpx==0.24.1
34
+ huggingface-hub==0.14.1
35
+ idna==3.4
36
+ importlib-metadata==6.6.0
37
+ importlib-resources==5.12.0
38
+ jax==0.4.10
39
+ Jinja2==3.1.2
40
+ jsonschema==4.17.3
41
+ keras==2.12.0
42
+ kiwisolver==1.4.4
43
+ libclang==16.0.0
44
+ linkify-it-py==2.0.2
45
+ Markdown==3.4.3
46
+ markdown-it-py==2.2.0
47
+ MarkupSafe==2.1.2
48
+ matplotlib==3.7.1
49
+ mdit-py-plugins==0.3.3
50
+ mdurl==0.1.2
51
+ ml-dtypes==0.1.0
52
+ multidict==6.0.4
53
+ numpy==1.23.5
54
+ oauthlib==3.2.2
55
+ opencv-python==4.7.0.72
56
+ opt-einsum==3.3.0
57
+ orjson==3.8.12
58
+ packaging==23.1
59
+ pandas==2.0.1
60
+ Pillow==9.5.0
61
+ pkgutil_resolve_name==1.3.10
62
+ protobuf==4.23.1
63
+ pyasn1==0.5.0
64
+ pyasn1-modules==0.3.0
65
+ pydantic==1.10.7
66
+ pydub==0.25.1
67
+ Pygments==2.15.1
68
+ pyparsing==3.0.9
69
+ pyrsistent==0.19.3
70
+ python-dateutil==2.8.2
71
+ python-multipart==0.0.6
72
+ pytz==2023.3
73
+ PyYAML==6.0
74
+ requests==2.30.0
75
+ requests-oauthlib==1.3.1
76
+ rsa==4.9
77
+ scipy==1.10.1
78
+ semantic-version==2.10.0
79
+ six==1.16.0
80
+ sniffio==1.3.0
81
+ starlette==0.27.0
82
+ tensorboard==2.12.3
83
+ tensorboard-data-server==0.7.0
84
+ tensorflow==2.12.0
85
+ tensorflow-estimator==2.12.0
86
+ tensorflow-io-gcs-filesystem==0.32.0
87
+ termcolor==2.3.0
88
+ toolz==0.12.0
89
+ tqdm==4.65.0
90
+ typing_extensions==4.5.0
91
+ tzdata==2023.3
92
+ uc-micro-py==1.0.2
93
+ urllib3==1.26.15
94
+ uvicorn==0.22.0
95
+ websockets==11.0.3
96
+ Werkzeug==2.3.4
97
+ wrapt==1.14.1
98
+ yarl==1.9.2
99
+ zipp==3.15.0