Update app.py
Browse files
app.py
CHANGED
@@ -23,18 +23,7 @@ import gradio as gr
|
|
23 |
feature_extractor = SegformerFeatureExtractor.from_pretrained('nvidia/segformer-b0-finetuned-ade-512-512')
|
24 |
segformer_model = SegformerForSemanticSegmentation.from_pretrained('nvidia/segformer-b0-finetuned-ade-512-512')
|
25 |
|
26 |
-
|
27 |
-
def segment_image(image):
|
28 |
-
inputs = feature_extractor(images=image, return_tensors="pt")
|
29 |
-
outputs = segformer_model(**inputs)
|
30 |
-
segmentation = outputs.logits.argmax(dim=1).squeeze().cpu().numpy()
|
31 |
-
return segmentation
|
32 |
-
|
33 |
-
# Gradio interface at the end of the script
|
34 |
-
iface = gr.Interface(fn=segment_image, inputs=gr.Image(type="pil"), outputs="image")
|
35 |
-
|
36 |
-
# Specify a custom port if needed to avoid conflicts (optional)
|
37 |
-
iface.launch(server_port=7861) # Change port if 7860 is occupied
|
38 |
|
39 |
|
40 |
# Function to extract zip files
|
|
|
23 |
feature_extractor = SegformerFeatureExtractor.from_pretrained('nvidia/segformer-b0-finetuned-ade-512-512')
|
24 |
segformer_model = SegformerForSemanticSegmentation.from_pretrained('nvidia/segformer-b0-finetuned-ade-512-512')
|
25 |
|
26 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
|
29 |
# Function to extract zip files
|