Green Doctor Deployer commited on
Commit
5675d5f
·
1 Parent(s): a9d8feb

Fix specialist string map keys

Browse files
Files changed (3) hide show
  1. backend/app.py +38 -38
  2. fix_map.py +53 -0
  3. out.py +8 -0
backend/app.py CHANGED
@@ -147,44 +147,44 @@ GENERALIST_MAP = {
147
 
148
  # Specialist Map (PlantVillage 38 Classes)
149
  SPECIALIST_MAP = {
150
- "Apple___Apple_scab": "Apple - Scab",
151
- "Apple___Black_rot": "Apple - Black Rot",
152
- "Apple___Cedar_apple_rust": "Apple - Cedar Rust",
153
- "Apple___healthy": "Apple - Healthy",
154
- "Blueberry___healthy": "Blueberry - Healthy",
155
- "Cherry_(including_sour)___Powdery_mildew": "Cherry - Powdery Mildew",
156
- "Cherry_(including_sour)___healthy": "Cherry - Healthy",
157
- "Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot": "Corn - Gray Leaf Spot",
158
- "Corn_(maize)___Common_rust_": "Corn - Common Rust",
159
- "Corn_(maize)___Northern_Leaf_Blight": "Corn - Leaf Blight",
160
- "Corn_(maize)___healthy": "Corn - Healthy",
161
- "Grape___Black_rot": "Grape - Black Rot",
162
- "Grape___Esca_(Black_Measles)": "Grape - Black Measles",
163
- "Grape___Leaf_blight_(Isariopsis_Leaf_Spot)": "Grape - Leaf Blight",
164
- "Grape___healthy": "Grape - Healthy",
165
- "Orange___Haunglongbing_(Citrus_greening)": "Orange - Huanglongbing (Greening)",
166
- "Peach___Bacterial_spot": "Peach - Bacterial Spot",
167
- "Peach___healthy": "Peach - Healthy",
168
- "Pepper,_bell___Bacterial_spot": "Pepper - Bacterial Spot",
169
- "Pepper,_bell___healthy": "Pepper - Healthy",
170
- "Potato___Early_blight": "Potato - Early Blight",
171
- "Potato___Late_blight": "Potato - Late Blight",
172
- "Potato___healthy": "Potato - Healthy",
173
- "Raspberry___healthy": "Raspberry - Healthy",
174
- "Soybean___healthy": "Soybean - Healthy",
175
- "Squash___Powdery_mildew": "Squash - Powdery Mildew",
176
- "Strawberry___Leaf_scorch": "Strawberry - Leaf Scorch",
177
- "Strawberry___healthy": "Strawberry - Healthy",
178
- "Tomato___Bacterial_spot": "Tomato - Bacterial Spot",
179
- "Tomato___Early_blight": "Tomato - Early Blight",
180
- "Tomato___Late_blight": "Tomato - Late Blight",
181
- "Tomato___Leaf_Mold": "Tomato - Leaf Mold",
182
- "Tomato___Septoria_leaf_spot": "Tomato - Septoria Spot",
183
- "Tomato___Spider_mites Two-spotted_spider_mite": "Tomato - Spider Mite",
184
- "Tomato___Target_Spot": "Tomato - Target Spot",
185
- "Tomato___Tomato_Yellow_Leaf_Curl_Virus": "Tomato - Yellow Leaf Curl",
186
- "Tomato___Tomato_mosaic_virus": "Tomato - Mosaic Virus",
187
- "Tomato___healthy": "Tomato - Healthy"
188
  }
189
 
190
  @app.get("/")
 
147
 
148
  # Specialist Map (PlantVillage 38 Classes)
149
  SPECIALIST_MAP = {
150
+ "Apple Scab": "Apple - Scab",
151
+ "Apple with Black Rot": "Apple - Black Rot",
152
+ "Cedar Apple Rust": "Apple - Rust",
153
+ "Healthy Apple": "Apple - Healthy",
154
+ "Healthy Blueberry Plant": "Blueberry - Healthy",
155
+ "Cherry with Powdery Mildew": "Cherry - Powdery Mildew",
156
+ "Healthy Cherry Plant": "Cherry - Healthy",
157
+ "Corn (Maize) with Cercospora and Gray Leaf Spot": "Corn - Gray Leaf Spot",
158
+ "Corn (Maize) with Common Rust": "Corn - Common Rust",
159
+ "Corn (Maize) with Northern Leaf Blight": "Corn - Northern Leaf Blight",
160
+ "Healthy Corn": "Corn - Healthy",
161
+ "Grape with Black Measles": "Grape - Black Measles",
162
+ "Grape with Black Rot": "Grape - Black Rot",
163
+ "Grape with Leaf Blight": "Grape - Leaf Blight",
164
+ "Healthy Grape": "Grape - Healthy",
165
+ "Orange with Citrus Greening": "Orange - Citrus Greening",
166
+ "Peach with Bacterial Spot": "Peach - Bacterial Spot",
167
+ "Healthy Peach": "Peach - Healthy",
168
+ "Pepper Bell with Bacterial Spot": "Pepper - Bacterial Spot",
169
+ "Healthy Pepper Bell": "Pepper - Healthy",
170
+ "Potato with Early Blight": "Potato - Early Blight",
171
+ "Potato with Late Blight": "Potato - Late Blight",
172
+ "Healthy Potato Plant": "Potato - Healthy",
173
+ "Healthy Raspberry Plant": "Raspberry - Healthy",
174
+ "Healthy Soybean Plant": "Soybean - Healthy",
175
+ "Squash with Powdery Mildew": "Squash - Powdery Mildew",
176
+ "Strawberry with Leaf Scorch": "Strawberry - Leaf Scorch",
177
+ "Healthy Strawberry Plant": "Strawberry - Healthy",
178
+ "Tomato with Bacterial Spot": "Tomato - Bacterial Spot",
179
+ "Tomato with Early Blight": "Tomato - Early Blight",
180
+ "Tomato with Late Blight": "Tomato - Late Blight",
181
+ "Tomato with Leaf Mold": "Tomato - Leaf Mold",
182
+ "Tomato with Septoria Leaf Spot": "Tomato - Septoria Spot",
183
+ "Tomato with Spider Mites or Two-spotted Spider Mite": "Tomato - Spider Mite",
184
+ "Tomato with Target Spot": "Tomato - Target Spot",
185
+ "Tomato Yellow Leaf Curl Virus": "Tomato - Yellow Leaf Curl",
186
+ "Tomato Mosaic Virus": "Tomato - Mosaic Virus",
187
+ "Healthy Tomato Plant": "Tomato - Healthy"
188
  }
189
 
190
  @app.get("/")
fix_map.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ with open('backend/app.py', 'r', encoding='utf-8') as f:
4
+ text = f.read()
5
+
6
+ new_map = """SPECIALIST_MAP = {
7
+ "Apple Scab": "Apple - Scab",
8
+ "Apple with Black Rot": "Apple - Black Rot",
9
+ "Cedar Apple Rust": "Apple - Rust",
10
+ "Healthy Apple": "Apple - Healthy",
11
+ "Healthy Blueberry Plant": "Blueberry - Healthy",
12
+ "Cherry with Powdery Mildew": "Cherry - Powdery Mildew",
13
+ "Healthy Cherry Plant": "Cherry - Healthy",
14
+ "Corn (Maize) with Cercospora and Gray Leaf Spot": "Corn - Gray Leaf Spot",
15
+ "Corn (Maize) with Common Rust": "Corn - Common Rust",
16
+ "Corn (Maize) with Northern Leaf Blight": "Corn - Northern Leaf Blight",
17
+ "Healthy Corn": "Corn - Healthy",
18
+ "Grape with Black Measles": "Grape - Black Measles",
19
+ "Grape with Black Rot": "Grape - Black Rot",
20
+ "Grape with Leaf Blight": "Grape - Leaf Blight",
21
+ "Healthy Grape": "Grape - Healthy",
22
+ "Orange with Citrus Greening": "Orange - Citrus Greening",
23
+ "Peach with Bacterial Spot": "Peach - Bacterial Spot",
24
+ "Healthy Peach": "Peach - Healthy",
25
+ "Pepper Bell with Bacterial Spot": "Pepper - Bacterial Spot",
26
+ "Healthy Pepper Bell": "Pepper - Healthy",
27
+ "Potato with Early Blight": "Potato - Early Blight",
28
+ "Potato with Late Blight": "Potato - Late Blight",
29
+ "Healthy Potato Plant": "Potato - Healthy",
30
+ "Healthy Raspberry Plant": "Raspberry - Healthy",
31
+ "Healthy Soybean Plant": "Soybean - Healthy",
32
+ "Squash with Powdery Mildew": "Squash - Powdery Mildew",
33
+ "Strawberry with Leaf Scorch": "Strawberry - Leaf Scorch",
34
+ "Healthy Strawberry Plant": "Strawberry - Healthy",
35
+ "Tomato with Bacterial Spot": "Tomato - Bacterial Spot",
36
+ "Tomato with Early Blight": "Tomato - Early Blight",
37
+ "Tomato with Late Blight": "Tomato - Late Blight",
38
+ "Tomato with Leaf Mold": "Tomato - Leaf Mold",
39
+ "Tomato with Septoria Leaf Spot": "Tomato - Septoria Spot",
40
+ "Tomato with Spider Mites or Two-spotted Spider Mite": "Tomato - Spider Mite",
41
+ "Tomato with Target Spot": "Tomato - Target Spot",
42
+ "Tomato Yellow Leaf Curl Virus": "Tomato - Yellow Leaf Curl",
43
+ "Tomato Mosaic Virus": "Tomato - Mosaic Virus",
44
+ "Healthy Tomato Plant": "Tomato - Healthy"
45
+ }"""
46
+
47
+ # Replace the specific block in the file
48
+ text = re.sub(r'SPECIALIST_MAP\s*=\s*\{[^}]+\}', new_map, text, count=1)
49
+
50
+ with open('backend/app.py', 'w', encoding='utf-8') as f:
51
+ f.write(text)
52
+
53
+ print("Replaced!")
out.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import urllib.request, json
2
+ url = 'https://huggingface.co/linkanjarad/mobilenet_v2_1.0_224-plant-disease-identification/raw/main/config.json'
3
+ c = json.loads(urllib.request.urlopen(url).read().decode())
4
+ labels = list(c.get('id2label', {}).values())
5
+ print('NEW_MAP = {')
6
+ for x in labels:
7
+ print(f' "{x}": "{x}",')
8
+ print('}')