Update run.py
Browse files
run.py
CHANGED
@@ -39,11 +39,13 @@ def segment(im, interval_s=2):
|
|
39 |
pixel_values = image_processor(im, return_tensors="pt").pixel_values.to(device)
|
40 |
outputs = model(pixel_values=pixel_values)
|
41 |
logits = outputs.logits.cpu().detach().numpy() ** 2
|
42 |
-
|
|
|
|
|
43 |
return imout #, cnt #np.flipud(im)
|
44 |
|
45 |
with gr.Blocks() as demo:
|
46 |
-
inp = gr.Image(sources=["webcam"], streaming=
|
47 |
inp.stream(segment, inputs=inp, outputs=[gr.Image()])
|
48 |
|
49 |
# demo = gr.Interface(
|
|
|
39 |
pixel_values = image_processor(im, return_tensors="pt").pixel_values.to(device)
|
40 |
outputs = model(pixel_values=pixel_values)
|
41 |
logits = outputs.logits.cpu().detach().numpy() ** 2
|
42 |
+
logits_n = (logits[0, 0] - logits[0, 0].min()) / (logits[0, 0].max() - logits[0, 0].min())
|
43 |
+
imout = im.copy()
|
44 |
+
imout[..., 0] = imgout[..., 0] + logits_n / 10
|
45 |
return imout #, cnt #np.flipud(im)
|
46 |
|
47 |
with gr.Blocks() as demo:
|
48 |
+
inp = gr.Image(sources=["webcam"], streaming=True)
|
49 |
inp.stream(segment, inputs=inp, outputs=[gr.Image()])
|
50 |
|
51 |
# demo = gr.Interface(
|