Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ import torch.nn.functional as F
|
|
| 8 |
from torchvision import transforms
|
| 9 |
from PIL import Image
|
| 10 |
from data_manager import get_dog_description
|
| 11 |
-
import wikipedia
|
| 12 |
from urllib.parse import quote
|
| 13 |
|
| 14 |
dog_breeds = ["Afghan_Hound(阿富汗獵犬)", "African_Hunting_Dog(非洲野犬)", "Airedale(艾爾谷犬)",
|
|
@@ -187,10 +186,7 @@ def predict(image):
|
|
| 187 |
description = get_dog_description(breed)
|
| 188 |
|
| 189 |
# Generate Wikipedia link
|
| 190 |
-
|
| 191 |
-
wiki_link = wikipedia.page(f"{breed} dog").url
|
| 192 |
-
except:
|
| 193 |
-
wiki_link = f"https://en.wikipedia.org/wiki/Special:Search?search={quote(breed)}+dog"
|
| 194 |
|
| 195 |
# Formatting the description for better display
|
| 196 |
if isinstance(description, dict):
|
|
@@ -207,7 +203,7 @@ def predict(image):
|
|
| 207 |
description_str = description
|
| 208 |
|
| 209 |
# Add Wikipedia link
|
| 210 |
-
description_str += f"\n\n[Click here to
|
| 211 |
|
| 212 |
return description_str
|
| 213 |
except Exception as e:
|
|
|
|
| 8 |
from torchvision import transforms
|
| 9 |
from PIL import Image
|
| 10 |
from data_manager import get_dog_description
|
|
|
|
| 11 |
from urllib.parse import quote
|
| 12 |
|
| 13 |
dog_breeds = ["Afghan_Hound(阿富汗獵犬)", "African_Hunting_Dog(非洲野犬)", "Airedale(艾爾谷犬)",
|
|
|
|
| 186 |
description = get_dog_description(breed)
|
| 187 |
|
| 188 |
# Generate Wikipedia link
|
| 189 |
+
wiki_link = f"https://en.wikipedia.org/wiki/Special:Search?search={quote(breed)}+dog"
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
# Formatting the description for better display
|
| 192 |
if isinstance(description, dict):
|
|
|
|
| 203 |
description_str = description
|
| 204 |
|
| 205 |
# Add Wikipedia link
|
| 206 |
+
description_str += f"\n\n[Click here to search for {breed} on Wikipedia]({wiki_link})"
|
| 207 |
|
| 208 |
return description_str
|
| 209 |
except Exception as e:
|