Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,15 @@
|
|
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
|
7 |
-
|
8 |
-
# Model-Config & Checkpoint
|
9 |
-
CONFIG_FILE = 'configs/fashionformer/fashionpedia/fashionformer_r50_mlvl_feat_3x.py'
|
10 |
-
CHECKPOINT_FILE = 'checkpoints/fashionformer_r50_3x.pth' # Pfad anpassen
|
11 |
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
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 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
1 |
from mmdet.apis import init_detector, inference_detector
|
2 |
import mmcv
|
3 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
config_file = 'config/fashionformer_fashionpedia.py'
|
6 |
+
checkpoint_file = 'checkpoints/fashionformer.pth'
|
7 |
|
8 |
+
model = init_detector(config_file, checkpoint_file, device='cpu')
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
def predict(img):
|
11 |
+
result = inference_detector(model, img)
|
12 |
+
model.show_result(img, result, out_file='result.jpg', show=False)
|
13 |
+
return 'result.jpg'
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
gr.Interface(fn=predict, inputs=gr.Image(type="filepath"), outputs="image").launch()
|