FrezzyI commited on
Commit
c2fd87e
·
verified ·
1 Parent(s): 5bd55f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -24
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 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_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()
 
 
 
 
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()