Spaces:
Sleeping
Sleeping
Green Doctor Deployer commited on
Commit ·
5675d5f
1
Parent(s): a9d8feb
Fix specialist string map keys
Browse files- backend/app.py +38 -38
- fix_map.py +53 -0
- 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 |
-
"
|
| 151 |
-
"
|
| 152 |
-
"
|
| 153 |
-
"
|
| 154 |
-
"
|
| 155 |
-
"
|
| 156 |
-
"
|
| 157 |
-
"
|
| 158 |
-
"
|
| 159 |
-
"
|
| 160 |
-
"
|
| 161 |
-
"
|
| 162 |
-
"
|
| 163 |
-
"
|
| 164 |
-
"
|
| 165 |
-
"
|
| 166 |
-
"
|
| 167 |
-
"
|
| 168 |
-
"Pepper
|
| 169 |
-
"Pepper
|
| 170 |
-
"
|
| 171 |
-
"
|
| 172 |
-
"
|
| 173 |
-
"
|
| 174 |
-
"
|
| 175 |
-
"
|
| 176 |
-
"
|
| 177 |
-
"
|
| 178 |
-
"
|
| 179 |
-
"
|
| 180 |
-
"
|
| 181 |
-
"
|
| 182 |
-
"
|
| 183 |
-
"
|
| 184 |
-
"
|
| 185 |
-
"
|
| 186 |
-
"
|
| 187 |
-
"
|
| 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('}')
|