Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- .gitattributes +2 -0
- app.py +121 -15
- jacket.glb +3 -0
- pants.glb +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
jacket.glb filter=lfs diff=lfs merge=lfs -text
|
37 |
+
pants.glb filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -455,7 +455,61 @@ def predict_pants_sizes(waist, leg_length, hips):
|
|
455 |
}, indent=2)
|
456 |
|
457 |
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
with gr.Blocks(title="Body Measurements Predictor") as demo:
|
460 |
gr.Markdown(f"""
|
461 |
# Body Measurements Predictor
|
@@ -489,12 +543,25 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
489 |
predict_button = gr.Button("Predict Shirt Measurements")
|
490 |
|
491 |
with gr.Column():
|
492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
predict_button.click(
|
495 |
-
fn=
|
496 |
inputs=[height_input, weight_input, body_type_input],
|
497 |
-
outputs=
|
498 |
)
|
499 |
|
500 |
gr.Markdown("""
|
@@ -505,7 +572,7 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
505 |
""")
|
506 |
|
507 |
# Second Tab - Brand Size Finder (Shirts)
|
508 |
-
with gr.Tab("Shirt Size Finder
|
509 |
with gr.Row():
|
510 |
with gr.Column():
|
511 |
chest_input = gr.Number(
|
@@ -532,12 +599,25 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
532 |
brand_predict_button = gr.Button("Find Matching Sizes")
|
533 |
|
534 |
with gr.Column():
|
535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
|
537 |
brand_predict_button.click(
|
538 |
-
fn=
|
539 |
inputs=[chest_input, waist_input, shoulder_input],
|
540 |
-
outputs=
|
541 |
)
|
542 |
|
543 |
gr.Markdown("""
|
@@ -574,12 +654,25 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
574 |
pants_predict_button = gr.Button("Predict Pants Measurements")
|
575 |
|
576 |
with gr.Column():
|
577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
|
579 |
pants_predict_button.click(
|
580 |
-
fn=
|
581 |
inputs=[pants_height_input, pants_weight_input, pants_body_type_input],
|
582 |
-
outputs=
|
583 |
)
|
584 |
|
585 |
gr.Markdown("""
|
@@ -590,7 +683,7 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
590 |
""")
|
591 |
|
592 |
# Fourth Tab - Pants Size Finder
|
593 |
-
with gr.Tab("Pants Size Finder
|
594 |
with gr.Row():
|
595 |
with gr.Column():
|
596 |
pants_waist_input = gr.Number(
|
@@ -617,12 +710,25 @@ with gr.Blocks(title="Body Measurements Predictor") as demo:
|
|
617 |
pants_brand_predict_button = gr.Button("Find Matching Pants Sizes")
|
618 |
|
619 |
with gr.Column():
|
620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
|
622 |
pants_brand_predict_button.click(
|
623 |
-
fn=
|
624 |
inputs=[pants_waist_input, pants_leg_input, pants_hips_input],
|
625 |
-
outputs=
|
626 |
)
|
627 |
|
628 |
gr.Markdown("""
|
|
|
455 |
}, indent=2)
|
456 |
|
457 |
|
458 |
+
def format_shirt_predictions(predictions):
|
459 |
+
formatted = "### Shirt Measurements Predictions\n"
|
460 |
+
formatted += f"**Height:** {predictions['input']['height']} cm\n"
|
461 |
+
if 'weight' in predictions['input']:
|
462 |
+
formatted += f"**Weight:** {predictions['input']['weight']} kg\n"
|
463 |
+
if 'body_type' in predictions['input']:
|
464 |
+
formatted += f"**Body Type:** {predictions['input']['body_type']}\n"
|
465 |
+
formatted += "\n**Predictions:**\n"
|
466 |
+
for key, value in predictions['shirt_predictions'].items():
|
467 |
+
formatted += f"- **{key}:** {value['value']} {value.get('unit', '')}\n"
|
468 |
+
return formatted
|
469 |
+
|
470 |
+
def format_brand_predictions(predictions):
|
471 |
+
formatted = "### Brand Size Recommendations\n"
|
472 |
+
formatted += f"**Chest:** {predictions['input_measurements']['chest']} cm\n"
|
473 |
+
formatted += f"**Waist:** {predictions['input_measurements']['waist']} cm\n"
|
474 |
+
formatted += f"**Shoulder:** {predictions['input_measurements']['shoulder']} cm\n"
|
475 |
+
formatted += "\n**Recommendations:**\n"
|
476 |
+
for brand in predictions['brand_recommendations']:
|
477 |
+
formatted += f"- **Brand:** {brand['brand']}\n"
|
478 |
+
for size in brand['matching_sizes']:
|
479 |
+
formatted += f" - **Size:** {size['size']}\n"
|
480 |
+
formatted += f" - **Chest Range:** {size['fit_details']['chest_range']}\n"
|
481 |
+
formatted += f" - **Waist Range:** {size['fit_details']['waist_range']}\n"
|
482 |
+
formatted += f" - **Shoulder Range:** {size['fit_details']['shoulder_range']}\n"
|
483 |
+
return formatted
|
484 |
+
|
485 |
+
def format_pants_predictions(predictions):
|
486 |
+
formatted = "### Pants Measurements Predictions\n"
|
487 |
+
formatted += f"**Height:** {predictions['input']['height']} cm\n"
|
488 |
+
if 'weight' in predictions['input']:
|
489 |
+
formatted += f"**Weight:** {predictions['input']['weight']} kg\n"
|
490 |
+
if 'body_type' in predictions['input']:
|
491 |
+
formatted += f"**Body Type:** {predictions['input']['body_type']}\n"
|
492 |
+
formatted += "\n**Predictions:**\n"
|
493 |
+
for key, value in predictions['pants_predictions'].items():
|
494 |
+
formatted += f"- **{key}:** {value['value']} {value.get('unit', '')}\n"
|
495 |
+
return formatted
|
496 |
+
|
497 |
+
def format_pants_brand_predictions(predictions):
|
498 |
+
formatted = "### Pants Size Recommendations\n"
|
499 |
+
formatted += f"**Waist:** {predictions['input_measurements']['waist']} cm\n"
|
500 |
+
formatted += f"**Hips:** {predictions['input_measurements']['hips']} cm\n"
|
501 |
+
formatted += f"**Leg Length:** {predictions['input_measurements']['leg_length']} cm\n"
|
502 |
+
formatted += "\n**Recommendations:**\n"
|
503 |
+
for brand in predictions['brand_recommendations']:
|
504 |
+
formatted += f"- **Brand:** {brand['brand']}\n"
|
505 |
+
for size in brand['matching_sizes']:
|
506 |
+
formatted += f" - **Size:** {size['size']}\n"
|
507 |
+
formatted += f" - **Waist Range:** {size['fit_details']['waist_range']}\n"
|
508 |
+
formatted += f" - **Hips Range:** {size['fit_details']['hips_range']}\n"
|
509 |
+
formatted += f" - **Leg Length Range:** {size['fit_details']['leg_length_range']}\n"
|
510 |
+
return formatted
|
511 |
+
|
512 |
+
# Update Gradio interface to use formatted predictions
|
513 |
with gr.Blocks(title="Body Measurements Predictor") as demo:
|
514 |
gr.Markdown(f"""
|
515 |
# Body Measurements Predictor
|
|
|
543 |
predict_button = gr.Button("Predict Shirt Measurements")
|
544 |
|
545 |
with gr.Column():
|
546 |
+
output_markdown = gr.Markdown(label="Shirt Measurements Predictions")
|
547 |
+
with gr.Column(scale=2, min_width=300):
|
548 |
+
model3d = gr.Model3D(
|
549 |
+
value="jacket.glb", # Path to your .glb file on server
|
550 |
+
clear_color=[0.0, 0.0, 0.0, 0.0], # Transparent background
|
551 |
+
camera_position=[0, 0, 5], # Initial camera position
|
552 |
+
visible=False # Initially hidden
|
553 |
+
)
|
554 |
+
|
555 |
+
def update_model_visibility(height, weight, body_type):
|
556 |
+
predictions = format_shirt_predictions(
|
557 |
+
json.loads(predict_shirt_measurements(height, weight, body_type))
|
558 |
+
)
|
559 |
+
return predictions, gr.update(visible=True)
|
560 |
|
561 |
predict_button.click(
|
562 |
+
fn=update_model_visibility,
|
563 |
inputs=[height_input, weight_input, body_type_input],
|
564 |
+
outputs=[output_markdown, model3d]
|
565 |
)
|
566 |
|
567 |
gr.Markdown("""
|
|
|
572 |
""")
|
573 |
|
574 |
# Second Tab - Brand Size Finder (Shirts)
|
575 |
+
with gr.Tab("Shirt Size Finder"):
|
576 |
with gr.Row():
|
577 |
with gr.Column():
|
578 |
chest_input = gr.Number(
|
|
|
599 |
brand_predict_button = gr.Button("Find Matching Sizes")
|
600 |
|
601 |
with gr.Column():
|
602 |
+
brand_output_markdown = gr.Markdown(label="Brand Size Recommendations")
|
603 |
+
with gr.Column(scale=2, min_width=300):
|
604 |
+
model3d = gr.Model3D(
|
605 |
+
value="jacket.glb", # Path to your .glb file on server
|
606 |
+
clear_color=[0.0, 0.0, 0.0, 0.0], # Transparent background
|
607 |
+
camera_position=[0, 0, 5], # Initial camera position
|
608 |
+
visible=False # Initially hidden
|
609 |
+
)
|
610 |
+
|
611 |
+
def update_model_visibility(chest, waist, shoulder):
|
612 |
+
predictions = format_brand_predictions(
|
613 |
+
json.loads(predict_brand_sizes(chest, waist, shoulder))
|
614 |
+
)
|
615 |
+
return predictions, gr.update(visible=True)
|
616 |
|
617 |
brand_predict_button.click(
|
618 |
+
fn=update_model_visibility,
|
619 |
inputs=[chest_input, waist_input, shoulder_input],
|
620 |
+
outputs=[brand_output_markdown, model3d]
|
621 |
)
|
622 |
|
623 |
gr.Markdown("""
|
|
|
654 |
pants_predict_button = gr.Button("Predict Pants Measurements")
|
655 |
|
656 |
with gr.Column():
|
657 |
+
pants_output_markdown = gr.Markdown(label="Pants Measurements Predictions")
|
658 |
+
with gr.Column():
|
659 |
+
model3d = gr.Model3D(
|
660 |
+
value="pants.glb", # Path to your .glb file on server
|
661 |
+
clear_color=[0.0, 0.0, 0.0, 0.0], # Transparent background
|
662 |
+
camera_position=[0, 0, 5], # Initial camera position
|
663 |
+
visible=False # Initially hidden
|
664 |
+
)
|
665 |
+
|
666 |
+
def update_model_visibility(height, weight, body_type):
|
667 |
+
predictions = format_pants_predictions(
|
668 |
+
json.loads(predict_pants_measurements(height, weight, body_type))
|
669 |
+
)
|
670 |
+
return predictions, gr.update(visible=True)
|
671 |
|
672 |
pants_predict_button.click(
|
673 |
+
fn=update_model_visibility,
|
674 |
inputs=[pants_height_input, pants_weight_input, pants_body_type_input],
|
675 |
+
outputs=[pants_output_markdown, model3d]
|
676 |
)
|
677 |
|
678 |
gr.Markdown("""
|
|
|
683 |
""")
|
684 |
|
685 |
# Fourth Tab - Pants Size Finder
|
686 |
+
with gr.Tab("Pants Size Finder"):
|
687 |
with gr.Row():
|
688 |
with gr.Column():
|
689 |
pants_waist_input = gr.Number(
|
|
|
710 |
pants_brand_predict_button = gr.Button("Find Matching Pants Sizes")
|
711 |
|
712 |
with gr.Column():
|
713 |
+
pants_brand_output_markdown = gr.Markdown(label="Pants Size Recommendations")
|
714 |
+
with gr.Column():
|
715 |
+
model3d = gr.Model3D(
|
716 |
+
value="pants.glb", # Path to your .glb file on server
|
717 |
+
clear_color=[0.0, 0.0, 0.0, 0.0], # Transparent background
|
718 |
+
camera_position=[0, 0, 5], # Initial camera position
|
719 |
+
visible=False # Initially hidden
|
720 |
+
)
|
721 |
+
|
722 |
+
def update_model_visibility(waist, leg_length, hips):
|
723 |
+
predictions = format_pants_brand_predictions(
|
724 |
+
json.loads(predict_pants_sizes(waist, leg_length, hips))
|
725 |
+
)
|
726 |
+
return predictions, gr.update(visible=True)
|
727 |
|
728 |
pants_brand_predict_button.click(
|
729 |
+
fn=update_model_visibility,
|
730 |
inputs=[pants_waist_input, pants_leg_input, pants_hips_input],
|
731 |
+
outputs=[pants_brand_output_markdown, model3d]
|
732 |
)
|
733 |
|
734 |
gr.Markdown("""
|
jacket.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:28df5d061343a86268a5201207aca068ed5ede82b9ee8c43560d528f6d9d75f0
|
3 |
+
size 3333684
|
pants.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2637ec74b17e5bf5116a7afbce1e12bfa1aa7460dca62667ea2bffbb3a260044
|
3 |
+
size 2762056
|