Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -140,12 +140,8 @@ def preprocess_image(image):
|
|
140 |
return transform(image).unsqueeze(0)
|
141 |
|
142 |
|
143 |
-
def
|
144 |
-
|
145 |
-
formatted_breed = ''.join(c for c in breed if ord(c) < 128).lower()
|
146 |
-
# Replace spaces with hyphens and remove any remaining special characters
|
147 |
-
formatted_breed = '-'.join(word for word in formatted_breed.split() if word.isalnum())
|
148 |
-
return f"https://www.akc.org/dog-breeds/{formatted_breed}/"
|
149 |
|
150 |
def predict(image):
|
151 |
try:
|
@@ -160,7 +156,7 @@ def predict(image):
|
|
160 |
breed = dog_breeds[predicted.item()]
|
161 |
|
162 |
description = get_dog_description(breed)
|
163 |
-
akc_link =
|
164 |
|
165 |
if isinstance(description, dict):
|
166 |
description_str = "\n\n".join([f"**{key}**: {value}" for key, value in description.items()])
|
@@ -168,11 +164,13 @@ def predict(image):
|
|
168 |
description_str = description
|
169 |
|
170 |
# Add AKC link as an option
|
171 |
-
description_str += f"\n\n**Want to learn more?** [
|
172 |
|
173 |
# Add disclaimer
|
174 |
-
disclaimer = ("\n\n*Disclaimer: The external link provided leads to the American Kennel Club (AKC)
|
175 |
-
"
|
|
|
|
|
176 |
description_str += disclaimer
|
177 |
|
178 |
return description_str
|
|
|
140 |
return transform(image).unsqueeze(0)
|
141 |
|
142 |
|
143 |
+
def get_akc_breeds_link():
|
144 |
+
return "https://www.akc.org/dog-breeds/"
|
|
|
|
|
|
|
|
|
145 |
|
146 |
def predict(image):
|
147 |
try:
|
|
|
156 |
breed = dog_breeds[predicted.item()]
|
157 |
|
158 |
description = get_dog_description(breed)
|
159 |
+
akc_link = get_akc_breeds_link()
|
160 |
|
161 |
if isinstance(description, dict):
|
162 |
description_str = "\n\n".join([f"**{key}**: {value}" for key, value in description.items()])
|
|
|
164 |
description_str = description
|
165 |
|
166 |
# Add AKC link as an option
|
167 |
+
description_str += f"\n\n**Want to learn more about dog breeds?** [Visit the AKC dog breeds page]({akc_link}) and search for {breed} to find detailed information."
|
168 |
|
169 |
# Add disclaimer
|
170 |
+
disclaimer = ("\n\n*Disclaimer: The external link provided leads to the American Kennel Club (AKC) dog breeds page. "
|
171 |
+
"You may need to search for the specific breed on that page. "
|
172 |
+
"I am not responsible for the content on external sites. "
|
173 |
+
"Please refer to the AKC's terms of use and privacy policy.*")
|
174 |
description_str += disclaimer
|
175 |
|
176 |
return description_str
|