FrezzyI commited on
Commit
577532a
·
verified ·
1 Parent(s): 43b6e8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
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
- # Modellpfade
6
- config_file = 'configs/fashionformer/fashionpedia/fashionformer_r50_mlvl_feat_3x.py'
7
- checkpoint_file = 'checkpoints/fashionformer_r50.pth'
8
 
9
  # Modell laden
10
- model = init_detector(config_file, checkpoint_file, device='cpu')
11
 
 
12
  def predict(image):
13
  result = inference_detector(model, image)
14
- model.show_result(image, result, out_file='result.jpg', show=False)
15
- return 'result.jpg'
16
 
17
- gr.Interface(fn=predict,
18
- inputs=gr.Image(type="filepath"),
19
- outputs="image",
20
- title="FashionFormer Segmentierung").launch()
 
 
 
 
 
 
 
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()