Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -429,7 +429,6 @@ async def predict(image):
|
|
429 |
print(error_msg)
|
430 |
return error_msg, None, gr.update(visible=False, choices=[]), None
|
431 |
|
432 |
-
|
433 |
|
434 |
|
435 |
def show_details_html(choice, previous_output, initial_state):
|
@@ -437,6 +436,7 @@ def show_details_html(choice, previous_output, initial_state):
|
|
437 |
return previous_output, gr.update(visible=True), initial_state
|
438 |
|
439 |
try:
|
|
|
440 |
breed = choice.split("More about ")[-1]
|
441 |
description = get_dog_description(breed)
|
442 |
formatted_description = format_description_html(description, breed)
|
@@ -457,6 +457,34 @@ def show_details_html(choice, previous_output, initial_state):
|
|
457 |
print(error_msg)
|
458 |
return f"<p style='color: red;'>{error_msg}</p>", gr.update(visible=True), initial_state
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
|
461 |
def format_description_html(description, breed):
|
462 |
html = "<ul style='list-style-type: none; padding-left: 0;'>"
|
|
|
429 |
print(error_msg)
|
430 |
return error_msg, None, gr.update(visible=False, choices=[]), None
|
431 |
|
|
|
432 |
|
433 |
|
434 |
def show_details_html(choice, previous_output, initial_state):
|
|
|
436 |
return previous_output, gr.update(visible=True), initial_state
|
437 |
|
438 |
try:
|
439 |
+
# Extract the breed name from the choice string
|
440 |
breed = choice.split("More about ")[-1]
|
441 |
description = get_dog_description(breed)
|
442 |
formatted_description = format_description_html(description, breed)
|
|
|
457 |
print(error_msg)
|
458 |
return f"<p style='color: red;'>{error_msg}</p>", gr.update(visible=True), initial_state
|
459 |
|
460 |
+
|
461 |
+
|
462 |
+
|
463 |
+
# def show_details_html(choice, previous_output, initial_state):
|
464 |
+
# if not choice:
|
465 |
+
# return previous_output, gr.update(visible=True), initial_state
|
466 |
+
|
467 |
+
# try:
|
468 |
+
# breed = choice.split("More about ")[-1]
|
469 |
+
# description = get_dog_description(breed)
|
470 |
+
# formatted_description = format_description_html(description, breed)
|
471 |
+
|
472 |
+
# html_output = f"""
|
473 |
+
# <div class="dog-info">
|
474 |
+
# <h2>{breed}</h2>
|
475 |
+
# {formatted_description}
|
476 |
+
# </div>
|
477 |
+
# """
|
478 |
+
|
479 |
+
# initial_state["current_description"] = html_output
|
480 |
+
# initial_state["original_buttons"] = initial_state.get("buttons", [])
|
481 |
+
|
482 |
+
# return html_output, gr.update(visible=True), initial_state
|
483 |
+
# except Exception as e:
|
484 |
+
# error_msg = f"An error occurred while showing details: {e}"
|
485 |
+
# print(error_msg)
|
486 |
+
# return f"<p style='color: red;'>{error_msg}</p>", gr.update(visible=True), initial_state
|
487 |
+
|
488 |
|
489 |
def format_description_html(description, breed):
|
490 |
html = "<ul style='list-style-type: none; padding-left: 0;'>"
|