Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -534,12 +534,6 @@ dog_breeds = ["Afghan_Hound", "African_Hunting_Dog", "Airedale", "American_Staff
|
|
534 |
"Wire-Haired_Fox_Terrier"]
|
535 |
|
536 |
|
537 |
-
def gpu_wrapper(f):
|
538 |
-
@wraps(f)
|
539 |
-
async def wrapped(*args, **kwargs):
|
540 |
-
return await spaces.GPU(f)(*args, **kwargs)
|
541 |
-
return wrapped
|
542 |
-
|
543 |
class MultiHeadAttention(nn.Module):
|
544 |
|
545 |
def __init__(self, in_dim, num_heads=8):
|
@@ -619,7 +613,7 @@ def preprocess_image(image):
|
|
619 |
|
620 |
return transform(image).unsqueeze(0)
|
621 |
|
622 |
-
@
|
623 |
async def predict_single_dog(image):
|
624 |
"""
|
625 |
Predicts the dog breed using only the classifier.
|
@@ -652,7 +646,7 @@ async def predict_single_dog(image):
|
|
652 |
|
653 |
return probabilities[0], breeds[:3], relative_probs
|
654 |
|
655 |
-
@
|
656 |
async def detect_multiple_dogs(image, conf_threshold=0.3, iou_threshold=0.55):
|
657 |
|
658 |
results = model_yolo(image, conf=conf_threshold, iou=iou_threshold)[0]
|
@@ -735,7 +729,7 @@ def create_breed_comparison(breed1: str, breed2: str) -> dict:
|
|
735 |
|
736 |
return comparison_data
|
737 |
|
738 |
-
@
|
739 |
async def predict(image):
|
740 |
"""
|
741 |
Main prediction function that handles both single and multiple dog detection.
|
@@ -888,6 +882,7 @@ def show_details_html(choice, previous_output, initial_state):
|
|
888 |
|
889 |
def main():
|
890 |
with gr.Blocks(css=get_css_styles()) as iface:
|
|
|
891 |
|
892 |
gr.HTML("""
|
893 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|
|
|
534 |
"Wire-Haired_Fox_Terrier"]
|
535 |
|
536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
class MultiHeadAttention(nn.Module):
|
538 |
|
539 |
def __init__(self, in_dim, num_heads=8):
|
|
|
613 |
|
614 |
return transform(image).unsqueeze(0)
|
615 |
|
616 |
+
@spaces.GPU
|
617 |
async def predict_single_dog(image):
|
618 |
"""
|
619 |
Predicts the dog breed using only the classifier.
|
|
|
646 |
|
647 |
return probabilities[0], breeds[:3], relative_probs
|
648 |
|
649 |
+
@spaces.GPU
|
650 |
async def detect_multiple_dogs(image, conf_threshold=0.3, iou_threshold=0.55):
|
651 |
|
652 |
results = model_yolo(image, conf=conf_threshold, iou=iou_threshold)[0]
|
|
|
729 |
|
730 |
return comparison_data
|
731 |
|
732 |
+
@spaces.GPU
|
733 |
async def predict(image):
|
734 |
"""
|
735 |
Main prediction function that handles both single and multiple dog detection.
|
|
|
882 |
|
883 |
def main():
|
884 |
with gr.Blocks(css=get_css_styles()) as iface:
|
885 |
+
spaces.init()
|
886 |
|
887 |
gr.HTML("""
|
888 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|