Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ from torchvision import transforms
|
|
13 |
|
14 |
# ----------------- HELPER FUNCTIONS ----------------- #
|
15 |
|
16 |
-
ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
|
17 |
|
18 |
LABELS_TO_IDS = {
|
19 |
"Background": 0,
|
@@ -132,9 +132,9 @@ def create_legend_image(labels_to_ids: dict[str, int], filename="legend.png"):
|
|
132 |
|
133 |
# ----------------- MODEL ----------------- #
|
134 |
|
135 |
-
URL = "https://huggingface.co/facebook/sapiens/resolve/main/sapiens_lite_host/torchscript/
|
136 |
-
CHECKPOINTS_DIR = os.path.join(ASSETS_DIR, "checkpoints")
|
137 |
-
model_path = os.path.join(
|
138 |
|
139 |
if not os.path.exists(model_path):
|
140 |
os.makedirs(CHECKPOINTS_DIR, exist_ok=True)
|
@@ -199,19 +199,19 @@ with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Monochrome(radius_size=sizes.radi
|
|
199 |
with gr.Column():
|
200 |
input_image = gr.Image(label="Input Image", type="pil", format="png")
|
201 |
|
202 |
-
example_model = gr.Examples(
|
203 |
inputs=input_image,
|
204 |
examples_per_page=10,
|
205 |
examples=[
|
206 |
os.path.join(ASSETS_DIR, "examples", img)
|
207 |
for img in os.listdir(os.path.join(ASSETS_DIR, "examples"))
|
208 |
],
|
209 |
-
)
|
210 |
with gr.Column():
|
211 |
result_image = gr.Image(label="Segmentation Result", format="png")
|
212 |
run_button = gr.Button("Run")
|
213 |
|
214 |
-
gr.Image(os.path.join(ASSETS_DIR, "legend.png"), label="Legend", type="filepath")
|
215 |
|
216 |
run_button.click(
|
217 |
fn=segment,
|
|
|
13 |
|
14 |
# ----------------- HELPER FUNCTIONS ----------------- #
|
15 |
|
16 |
+
#ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
|
17 |
|
18 |
LABELS_TO_IDS = {
|
19 |
"Background": 0,
|
|
|
132 |
|
133 |
# ----------------- MODEL ----------------- #
|
134 |
|
135 |
+
URL = "https://huggingface.co/facebook/sapiens/resolve/main/sapiens_lite_host/torchscript/depth/checkpoints/sapiens_0.3b/sapiens_0.3b_render_people_epoch_100_torchscript.pt2?download=true"
|
136 |
+
#CHECKPOINTS_DIR = os.path.join(ASSETS_DIR, "checkpoints")
|
137 |
+
model_path = os.path.join(os.path.dirname(__file__), "sapiens_0.3b_goliath_best_goliath_mIoU_7673_epoch_194_torchscript.pt2")
|
138 |
|
139 |
if not os.path.exists(model_path):
|
140 |
os.makedirs(CHECKPOINTS_DIR, exist_ok=True)
|
|
|
199 |
with gr.Column():
|
200 |
input_image = gr.Image(label="Input Image", type="pil", format="png")
|
201 |
|
202 |
+
'''example_model = gr.Examples(
|
203 |
inputs=input_image,
|
204 |
examples_per_page=10,
|
205 |
examples=[
|
206 |
os.path.join(ASSETS_DIR, "examples", img)
|
207 |
for img in os.listdir(os.path.join(ASSETS_DIR, "examples"))
|
208 |
],
|
209 |
+
)'''
|
210 |
with gr.Column():
|
211 |
result_image = gr.Image(label="Segmentation Result", format="png")
|
212 |
run_button = gr.Button("Run")
|
213 |
|
214 |
+
#gr.Image(os.path.join(ASSETS_DIR, "legend.png"), label="Legend", type="filepath")
|
215 |
|
216 |
run_button.click(
|
217 |
fn=segment,
|