Nunzio commited on
Commit
ff83735
·
1 Parent(s): c07b4af

fixed errors

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. utils/imageHandling.py +3 -3
app.py CHANGED
@@ -42,7 +42,7 @@ def run_prediction(image: gr.Image, selected_model: str)-> tuple[torch.Tensor]:
42
  with gr.Blocks(title="Semantic Segmentation Predictors") as demo:
43
  gr.Markdown("## Semantic Segmentation with Real-Time Networks")
44
  gr.Markdown('A small user interface created to run semantic segmentation on images using city scapes like predictions and real time segmentation networks.')
45
- gr.Markdown("Upload an image and choose your preferred model for segmentation.")
46
 
47
  with gr.Row():
48
  with gr.Column():
@@ -54,7 +54,7 @@ with gr.Blocks(title="Semantic Segmentation Predictors") as demo:
54
  image_input = gr.Image(type="pil", label="Upload image")
55
  submit_btn = gr.Button("Run prediction")
56
  with gr.Column():
57
- result_display = gr.Image(label="Model prediction", visible=False)
58
  error_text = gr.Markdown("", visible=False)
59
 
60
  submit_btn.click(
 
42
  with gr.Blocks(title="Semantic Segmentation Predictors") as demo:
43
  gr.Markdown("## Semantic Segmentation with Real-Time Networks")
44
  gr.Markdown('A small user interface created to run semantic segmentation on images using city scapes like predictions and real time segmentation networks.')
45
+ gr.Markdown("Upload an image and choose your preferred model for segmentation, or otherwise use one of the preloaded images.")
46
 
47
  with gr.Row():
48
  with gr.Column():
 
54
  image_input = gr.Image(type="pil", label="Upload image")
55
  submit_btn = gr.Button("Run prediction")
56
  with gr.Column():
57
+ result_display = gr.Image(label="Model prediction", visible=True)
58
  error_text = gr.Markdown("", visible=False)
59
 
60
  submit_btn.click(
utils/imageHandling.py CHANGED
@@ -63,10 +63,10 @@ def print_mask(mask:torch.Tensor, numClasses:int=19)->None:
63
  (119, 11, 32) # 18: bicycle
64
  ]
65
 
66
- new_mask = torch.zeros((mask.shape[0], mask.shape[1], 3),dtype=torch.uint8)
67
- new_mask[mask == 255] = (0,0,0)
68
  for i in range (numClasses):
69
- new_mask[mask == i] = colors[i][:3]
70
  return new_mask.permute(2,0,1)
71
 
72
  # %% postprocessing
 
63
  (119, 11, 32) # 18: bicycle
64
  ]
65
 
66
+ new_mask = torch.zeros((mask.shape[0], mask.shape[1], 3), dtype=torch.uint8)
67
+ new_mask[mask == 255] = torch.tensor([0, 0, 0], dtype=torch.uint8)
68
  for i in range (numClasses):
69
+ new_mask[mask == i] = torch.tensor(colors[i][:3], dtype=torch.uint8)
70
  return new_mask.permute(2,0,1)
71
 
72
  # %% postprocessing