Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,15 +4,19 @@ from pixellib.torchbackend.instance import instanceSegmentation
|
|
| 4 |
|
| 5 |
ins = instanceSegmentation()
|
| 6 |
ins.load_model("https://github.com/ayoolaolafenwa/PixelLib/releases/download/0.2.0/pointrend_resnet50.pkl")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def seg(inp):
|
| 8 |
|
| 9 |
-
results, output = ins.segmentImage(f"{inp}", show_bboxes=
|
| 10 |
#results, output = ins.segmentImage("image.jpg", show_bboxes=True, output_image_name="result.jpg")
|
| 11 |
print (results)
|
| 12 |
-
return
|
| 13 |
|
| 14 |
gr.Interface(
|
| 15 |
fn=seg,
|
| 16 |
inputs=gr.Image(type='filepath'),
|
| 17 |
-
outputs=gr.
|
| 18 |
).launch()
|
|
|
|
| 4 |
|
| 5 |
ins = instanceSegmentation()
|
| 6 |
ins.load_model("https://github.com/ayoolaolafenwa/PixelLib/releases/download/0.2.0/pointrend_resnet50.pkl")
|
| 7 |
+
target_classes = seg.select_target_classes(person=True)
|
| 8 |
+
#seg.segmentImage("sample2.jpg", segment_target_classes= target_classes, show_bboxes=True, output_image_name="a.jpg")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
def seg(inp):
|
| 12 |
|
| 13 |
+
results, output = ins.segmentImage(f"{inp}", segment_target_classes= target_classes, show_bboxes=False, output_image_name="output_image.jpg")
|
| 14 |
#results, output = ins.segmentImage("image.jpg", show_bboxes=True, output_image_name="result.jpg")
|
| 15 |
print (results)
|
| 16 |
+
return results['masks']
|
| 17 |
|
| 18 |
gr.Interface(
|
| 19 |
fn=seg,
|
| 20 |
inputs=gr.Image(type='filepath'),
|
| 21 |
+
outputs=gr.Gallery()
|
| 22 |
).launch()
|