Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -126,8 +126,15 @@ def preprocess_image(image):
|
|
126 |
return transform(image).unsqueeze(0)
|
127 |
|
128 |
|
129 |
-
def get_akc_breeds_link():
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
|
133 |
async def predict_single_dog(image):
|
@@ -373,6 +380,21 @@ def show_details_html(choice, previous_output, initial_state):
|
|
373 |
return f"<p style='color: red;'>{error_msg}</p>", gr.update(visible=True), initial_state
|
374 |
|
375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
def format_description_html(description, breed):
|
377 |
html = "<ul style='list-style-type: none; padding-left: 0;'>"
|
378 |
if isinstance(description, dict):
|
@@ -383,11 +405,12 @@ def format_description_html(description, breed):
|
|
383 |
else:
|
384 |
html += f"<li>No description available for {breed}</li>"
|
385 |
html += "</ul>"
|
386 |
-
akc_link = get_akc_breeds_link()
|
387 |
html += f'<p><a href="{akc_link}" target="_blank">Learn more about {breed} on the AKC website</a></p>'
|
388 |
return html
|
389 |
|
390 |
|
|
|
391 |
def go_back(state):
|
392 |
buttons = state.get("buttons", [])
|
393 |
return (
|
|
|
126 |
return transform(image).unsqueeze(0)
|
127 |
|
128 |
|
129 |
+
# def get_akc_breeds_link():
|
130 |
+
# return "https://www.akc.org/dog-breeds/"
|
131 |
+
|
132 |
+
|
133 |
+
def get_akc_breeds_link(breed):
|
134 |
+
base_url = "https://www.akc.org/dog-breeds/"
|
135 |
+
breed_url = breed.lower().replace('_', '-')
|
136 |
+
return f"{base_url}{breed_url}/"
|
137 |
+
|
138 |
|
139 |
|
140 |
async def predict_single_dog(image):
|
|
|
380 |
return f"<p style='color: red;'>{error_msg}</p>", gr.update(visible=True), initial_state
|
381 |
|
382 |
|
383 |
+
# def format_description_html(description, breed):
|
384 |
+
# html = "<ul style='list-style-type: none; padding-left: 0;'>"
|
385 |
+
# if isinstance(description, dict):
|
386 |
+
# for key, value in description.items():
|
387 |
+
# html += f"<li style='margin-bottom: 10px;'><strong>{key}:</strong> {value}</li>"
|
388 |
+
# elif isinstance(description, str):
|
389 |
+
# html += f"<li>{description}</li>"
|
390 |
+
# else:
|
391 |
+
# html += f"<li>No description available for {breed}</li>"
|
392 |
+
# html += "</ul>"
|
393 |
+
# akc_link = get_akc_breeds_link()
|
394 |
+
# html += f'<p><a href="{akc_link}" target="_blank">Learn more about {breed} on the AKC website</a></p>'
|
395 |
+
# return html
|
396 |
+
|
397 |
+
|
398 |
def format_description_html(description, breed):
|
399 |
html = "<ul style='list-style-type: none; padding-left: 0;'>"
|
400 |
if isinstance(description, dict):
|
|
|
405 |
else:
|
406 |
html += f"<li>No description available for {breed}</li>"
|
407 |
html += "</ul>"
|
408 |
+
akc_link = get_akc_breeds_link(breed)
|
409 |
html += f'<p><a href="{akc_link}" target="_blank">Learn more about {breed} on the AKC website</a></p>'
|
410 |
return html
|
411 |
|
412 |
|
413 |
+
|
414 |
def go_back(state):
|
415 |
buttons = state.get("buttons", [])
|
416 |
return (
|