TheOneReborn commited on
Commit
2b8f512
·
1 Parent(s): d728d1b

fix: normalize image for output

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -47,10 +47,12 @@ def segment_image(image):
47
  image = PILImage.create(image)
48
  prediction, _, _ = LEARNER.predict(image)
49
 
50
- print("Prediction shape:", prediction.shape)
51
- print("Unique values:", numpy.unique(prediction))
52
 
53
- return numpy.array(prediction, dtype=numpy.uint8)
 
 
 
54
 
55
 
56
  demo = gradio.Interface(
 
47
  image = PILImage.create(image)
48
  prediction, _, _ = LEARNER.predict(image)
49
 
50
+ prediction_array = numpy.array(prediction, dtype=numpy.uint8)
 
51
 
52
+ # Normalize class indices to 0-255 for proper visualization
53
+ prediction_array = (prediction_array / prediction_array.max()) * 255
54
+
55
+ return prediction_array.astype(numpy.uint8)
56
 
57
 
58
  demo = gradio.Interface(