Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from mmdet.apis import init_detector, inference_detector
|
3 |
import mmcv
|
|
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
|
9 |
# Modell laden
|
10 |
-
model = init_detector(
|
11 |
|
|
|
12 |
def predict(image):
|
13 |
result = inference_detector(model, image)
|
14 |
-
model.show_result(image, result, out_file=
|
15 |
-
return
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import torch
|
4 |
from mmdet.apis import init_detector, inference_detector
|
5 |
import mmcv
|
6 |
+
import numpy as np
|
7 |
|
8 |
+
# Model-Config & Checkpoint
|
9 |
+
CONFIG_FILE = 'configs/fashionformer/fashionpedia/fashionformer_r50_mlvl_feat_3x.py'
|
10 |
+
CHECKPOINT_FILE = 'checkpoints/fashionformer_r50_mlvl_feat_3x.pth' # Pfad anpassen
|
11 |
|
12 |
# Modell laden
|
13 |
+
model = init_detector(CONFIG_FILE, CHECKPOINT_FILE, device='cpu')
|
14 |
|
15 |
+
# Inferenzfunktion
|
16 |
def predict(image):
|
17 |
result = inference_detector(model, image)
|
18 |
+
img_out = model.show_result(image, result, out_file=None, show=False)
|
19 |
+
return img_out
|
20 |
|
21 |
+
# Gradio UI
|
22 |
+
demo = gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=gr.Image(type="filepath", label="Bild hochladen"),
|
25 |
+
outputs=gr.Image(type="numpy", label="Segmentiertes Ergebnis"),
|
26 |
+
title="FashionFormer – Mode-Segmentierung",
|
27 |
+
description="Dieses Tool erkennt und segmentiert Kleidungsstücke auf Bildern mithilfe des FashionFormer-Modells."
|
28 |
+
)
|
29 |
+
|
30 |
+
demo.launch()
|