Spaces:
Running
Running
Alex Hortua
commited on
Commit
·
4ef921e
1
Parent(s):
8faf799
Adding a default list of test
Browse files- src/app.py +2 -1
- src/testing.py +32 -3
src/app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
| 4 |
from utils import load_model, segment_person, resize_image, split_stereo_image
|
| 5 |
-
|
| 6 |
# Load model and processor once
|
| 7 |
processor, model = load_model()
|
| 8 |
|
|
@@ -80,6 +80,7 @@ demo = gr.Interface(
|
|
| 80 |
gr.Image(label="Stereo_pair"),
|
| 81 |
gr.Image(label="3D Anaglyph Image")
|
| 82 |
],
|
|
|
|
| 83 |
title="3D Person Segmentation Viewer",
|
| 84 |
description="Upload a person photo and optionally a background image. Outputs anaglyph and stereo views."
|
| 85 |
)
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
| 4 |
from utils import load_model, segment_person, resize_image, split_stereo_image
|
| 5 |
+
from testing import get_image_names
|
| 6 |
# Load model and processor once
|
| 7 |
processor, model = load_model()
|
| 8 |
|
|
|
|
| 80 |
gr.Image(label="Stereo_pair"),
|
| 81 |
gr.Image(label="3D Anaglyph Image")
|
| 82 |
],
|
| 83 |
+
examples= get_image_names(),
|
| 84 |
title="3D Person Segmentation Viewer",
|
| 85 |
description="Upload a person photo and optionally a background image. Outputs anaglyph and stereo views."
|
| 86 |
)
|
src/testing.py
CHANGED
|
@@ -1,4 +1,33 @@
|
|
| 1 |
-
from app import create_anaglyph
|
| 2 |
-
|
| 3 |
# Provide paths to your test images
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Provide paths to your test images
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
def get_image_names():
|
| 6 |
+
# Get background images
|
| 7 |
+
background_dir = "public/images/backgrounds"
|
| 8 |
+
background_images = [f for f in os.listdir(background_dir) if f.endswith(('.jpg', '.jpeg', '.png'))]
|
| 9 |
+
|
| 10 |
+
# Get people images
|
| 11 |
+
people_dir = "public/images/people"
|
| 12 |
+
people_images = [f for f in os.listdir(people_dir) if f.endswith(('.jpg', '.jpeg', '.png'))]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
generate_testing_list = []
|
| 16 |
+
|
| 17 |
+
random.shuffle(background_images)
|
| 18 |
+
random.shuffle(people_images)
|
| 19 |
+
|
| 20 |
+
min_length = min(len(background_images), len(people_images))
|
| 21 |
+
|
| 22 |
+
# Get 10 random pairs
|
| 23 |
+
for i in range(min_length):
|
| 24 |
+
background = background_images[i]
|
| 25 |
+
person = people_images[i]
|
| 26 |
+
generate_testing_list.append(list(( os.path.join(people_dir, person), os.path.join(background_dir, background), 10, 100)))
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
return generate_testing_list
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|