Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -372,43 +372,6 @@ def show_details(choice):
|
|
| 372 |
return f"An error occurred while showing details: {e}"
|
| 373 |
|
| 374 |
|
| 375 |
-
# with gr.Blocks() as iface:
|
| 376 |
-
# gr.HTML("<h1 style='text-align: center;'>πΆ Dog Breed Classifier π</h1>")
|
| 377 |
-
# gr.HTML("<p style='text-align: center;'>Upload a picture of a dog, and the model will predict its breed, provide detailed information, and include an extra information link!</p>")
|
| 378 |
-
|
| 379 |
-
# with gr.Row():
|
| 380 |
-
# input_image = gr.Image(label="Upload a dog image", type="pil")
|
| 381 |
-
# output_image = gr.Image(label="Annotated Image")
|
| 382 |
-
|
| 383 |
-
# output = gr.Markdown(label="Prediction Results")
|
| 384 |
-
|
| 385 |
-
# with gr.Row():
|
| 386 |
-
# btn1 = gr.Button("View More 1", visible=False)
|
| 387 |
-
# btn2 = gr.Button("View More 2", visible=False)
|
| 388 |
-
# btn3 = gr.Button("View More 3", visible=False)
|
| 389 |
-
|
| 390 |
-
# input_image.change(
|
| 391 |
-
# predict,
|
| 392 |
-
# inputs=input_image,
|
| 393 |
-
# outputs=[output, output_image, btn1, btn2, btn3]
|
| 394 |
-
# )
|
| 395 |
-
|
| 396 |
-
# btn1.click(show_details, inputs=btn1, outputs=output)
|
| 397 |
-
# btn2.click(show_details, inputs=btn2, outputs=output)
|
| 398 |
-
# btn3.click(show_details, inputs=btn3, outputs=output)
|
| 399 |
-
|
| 400 |
-
# gr.Examples(
|
| 401 |
-
# examples=['Border_Collie.jpg', 'Golden_Retriever.jpeg', 'Saint_Bernard.jpeg', 'French_Bulldog.jpeg', 'Samoyed.jpg'],
|
| 402 |
-
# inputs=input_image
|
| 403 |
-
# )
|
| 404 |
-
|
| 405 |
-
# gr.HTML('For more details on this project and other work, feel free to visit my GitHub <a href="https://github.com/Eric-Chung-0511/Learning-Record/tree/main/Data%20Science%20Projects/Dog_Breed_Classifier">Dog Breed Classifier</a>')
|
| 406 |
-
|
| 407 |
-
# if __name__ == "__main__":
|
| 408 |
-
# iface.launch()
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
# δ»ι’ι¨ε
|
| 412 |
with gr.Blocks() as iface:
|
| 413 |
gr.HTML("<h1 style='text-align: center;'>πΆ Dog Breed Classifier π</h1>")
|
| 414 |
gr.HTML("<p style='text-align: center;'>Upload a picture of a dog, and the model will predict its breed, provide detailed information, and include an extra information link!</p>")
|
|
@@ -423,33 +386,16 @@ with gr.Blocks() as iface:
|
|
| 423 |
btn1 = gr.Button("View More 1", visible=False)
|
| 424 |
btn2 = gr.Button("View More 2", visible=False)
|
| 425 |
btn3 = gr.Button("View More 3", visible=False)
|
| 426 |
-
|
| 427 |
-
back_button = gr.Button("Back", visible=False)
|
| 428 |
-
|
| 429 |
-
initial_state = gr.State()
|
| 430 |
-
|
| 431 |
input_image.change(
|
| 432 |
predict,
|
| 433 |
inputs=input_image,
|
| 434 |
-
outputs=[output, output_image, btn1, btn2, btn3
|
| 435 |
)
|
| 436 |
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
inputs=[btn, output, initial_state],
|
| 441 |
-
outputs=[output, back_button, initial_state]
|
| 442 |
-
)
|
| 443 |
-
|
| 444 |
-
back_button.click(
|
| 445 |
-
lambda state: (state["explanation"],
|
| 446 |
-
state["buttons"][0] if len(state["buttons"]) > 0 else gr.update(visible=False),
|
| 447 |
-
state["buttons"][1] if len(state["buttons"]) > 1 else gr.update(visible=False),
|
| 448 |
-
state["buttons"][2] if len(state["buttons"]) > 2 else gr.update(visible=False),
|
| 449 |
-
gr.update(visible=state["show_back"])),
|
| 450 |
-
inputs=[initial_state],
|
| 451 |
-
outputs=[output, btn1, btn2, btn3, back_button]
|
| 452 |
-
)
|
| 453 |
|
| 454 |
gr.Examples(
|
| 455 |
examples=['Border_Collie.jpg', 'Golden_Retriever.jpeg', 'Saint_Bernard.jpeg', 'French_Bulldog.jpeg', 'Samoyed.jpg'],
|
|
@@ -458,6 +404,6 @@ with gr.Blocks() as iface:
|
|
| 458 |
|
| 459 |
gr.HTML('For more details on this project and other work, feel free to visit my GitHub <a href="https://github.com/Eric-Chung-0511/Learning-Record/tree/main/Data%20Science%20Projects/Dog_Breed_Classifier">Dog Breed Classifier</a>')
|
| 460 |
|
| 461 |
-
|
| 462 |
if __name__ == "__main__":
|
| 463 |
-
iface.launch()
|
|
|
|
|
|
| 372 |
return f"An error occurred while showing details: {e}"
|
| 373 |
|
| 374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
with gr.Blocks() as iface:
|
| 376 |
gr.HTML("<h1 style='text-align: center;'>πΆ Dog Breed Classifier π</h1>")
|
| 377 |
gr.HTML("<p style='text-align: center;'>Upload a picture of a dog, and the model will predict its breed, provide detailed information, and include an extra information link!</p>")
|
|
|
|
| 386 |
btn1 = gr.Button("View More 1", visible=False)
|
| 387 |
btn2 = gr.Button("View More 2", visible=False)
|
| 388 |
btn3 = gr.Button("View More 3", visible=False)
|
| 389 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
input_image.change(
|
| 391 |
predict,
|
| 392 |
inputs=input_image,
|
| 393 |
+
outputs=[output, output_image, btn1, btn2, btn3]
|
| 394 |
)
|
| 395 |
|
| 396 |
+
btn1.click(show_details, inputs=btn1, outputs=output)
|
| 397 |
+
btn2.click(show_details, inputs=btn2, outputs=output)
|
| 398 |
+
btn3.click(show_details, inputs=btn3, outputs=output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
|
| 400 |
gr.Examples(
|
| 401 |
examples=['Border_Collie.jpg', 'Golden_Retriever.jpeg', 'Saint_Bernard.jpeg', 'French_Bulldog.jpeg', 'Samoyed.jpg'],
|
|
|
|
| 404 |
|
| 405 |
gr.HTML('For more details on this project and other work, feel free to visit my GitHub <a href="https://github.com/Eric-Chung-0511/Learning-Record/tree/main/Data%20Science%20Projects/Dog_Breed_Classifier">Dog Breed Classifier</a>')
|
| 406 |
|
|
|
|
| 407 |
if __name__ == "__main__":
|
| 408 |
+
iface.launch()
|
| 409 |
+
|