Harshad Bhandwaldar commited on
Commit
4c9c630
1 Parent(s): 2b586ad
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="53">
8
+ <item index="0" class="java.lang.String" itemvalue="pathspec" />
9
+ <item index="1" class="java.lang.String" itemvalue="transformers" />
10
+ <item index="2" class="java.lang.String" itemvalue="huggingface-hub" />
11
+ <item index="3" class="java.lang.String" itemvalue="numpy" />
12
+ <item index="4" class="java.lang.String" itemvalue="importlib-metadata" />
13
+ <item index="5" class="java.lang.String" itemvalue="exceptiongroup" />
14
+ <item index="6" class="java.lang.String" itemvalue="fastapi" />
15
+ <item index="7" class="java.lang.String" itemvalue="filelock" />
16
+ <item index="8" class="java.lang.String" itemvalue="platformdirs" />
17
+ <item index="9" class="java.lang.String" itemvalue="zipp" />
18
+ <item index="10" class="java.lang.String" itemvalue="starlette" />
19
+ <item index="11" class="java.lang.String" itemvalue="urllib3" />
20
+ <item index="12" class="java.lang.String" itemvalue="uvicorn" />
21
+ <item index="13" class="java.lang.String" itemvalue="joblib" />
22
+ <item index="14" class="java.lang.String" itemvalue="mypy" />
23
+ <item index="15" class="java.lang.String" itemvalue="nltk" />
24
+ <item index="16" class="java.lang.String" itemvalue="python-dateutil" />
25
+ <item index="17" class="java.lang.String" itemvalue="mypy-extensions" />
26
+ <item index="18" class="java.lang.String" itemvalue="pycodestyle" />
27
+ <item index="19" class="java.lang.String" itemvalue="setuptools" />
28
+ <item index="20" class="java.lang.String" itemvalue="cycler" />
29
+ <item index="21" class="java.lang.String" itemvalue="flake8" />
30
+ <item index="22" class="java.lang.String" itemvalue="markupsafe" />
31
+ <item index="23" class="java.lang.String" itemvalue="mccabe" />
32
+ <item index="24" class="java.lang.String" itemvalue="tomli" />
33
+ <item index="25" class="java.lang.String" itemvalue="itsdangerous" />
34
+ <item index="26" class="java.lang.String" itemvalue="pyparsing" />
35
+ <item index="27" class="java.lang.String" itemvalue="werkzeug" />
36
+ <item index="28" class="java.lang.String" itemvalue="six" />
37
+ <item index="29" class="java.lang.String" itemvalue="pyflakes" />
38
+ <item index="30" class="java.lang.String" itemvalue="black" />
39
+ <item index="31" class="java.lang.String" itemvalue="kiwisolver" />
40
+ <item index="32" class="java.lang.String" itemvalue="setuptools-scm" />
41
+ <item index="33" class="java.lang.String" itemvalue="wordcloud" />
42
+ <item index="34" class="java.lang.String" itemvalue="packaging" />
43
+ <item index="35" class="java.lang.String" itemvalue="typing-extensions" />
44
+ <item index="36" class="java.lang.String" itemvalue="click" />
45
+ <item index="37" class="java.lang.String" itemvalue="contourpy" />
46
+ <item index="38" class="java.lang.String" itemvalue="jinja2" />
47
+ <item index="39" class="java.lang.String" itemvalue="pandas" />
48
+ <item index="40" class="java.lang.String" itemvalue="tqdm" />
49
+ <item index="41" class="java.lang.String" itemvalue="fonttools" />
50
+ <item index="42" class="java.lang.String" itemvalue="regex" />
51
+ <item index="43" class="java.lang.String" itemvalue="matplotlib" />
52
+ <item index="44" class="java.lang.String" itemvalue="pillow" />
53
+ <item index="45" class="java.lang.String" itemvalue="isort" />
54
+ <item index="46" class="java.lang.String" itemvalue="pytz" />
55
+ <item index="47" class="java.lang.String" itemvalue="flask" />
56
+ <item index="48" class="java.lang.String" itemvalue="textblob" />
57
+ <item index="49" class="java.lang.String" itemvalue="nemo-toolkit" />
58
+ <item index="50" class="java.lang.String" itemvalue="gradio" />
59
+ <item index="51" class="java.lang.String" itemvalue="pytube" />
60
+ <item index="52" class="java.lang.String" itemvalue="nemo" />
61
+ </list>
62
+ </value>
63
+ </option>
64
+ </inspection_tool>
65
+ </profile>
66
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (semantic-segmentation-segformer)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/semantic-segmentation-segformer.iml" filepath="$PROJECT_DIR$/.idea/semantic-segmentation-segformer.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/semantic-segmentation-segformer.iml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="jdk" jdkName="Python 3.9 (semantic-segmentation-segformer)" jdkType="Python SDK" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ <component name="PackageRequirementsSettings">
9
+ <option name="versionSpecifier" value="Greater or equal (&gt;=x.y.z)" />
10
+ </component>
11
+ </module>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gluoncv
2
+ import matplotlib.image as mpimg
3
+ import mxnet as mx
4
+ from gluoncv.data.transforms.presets.segmentation import test_transform
5
+ from gluoncv.utils.viz import get_color_pallete
6
+ from matplotlib import pyplot as plt
7
+ from mxnet import image
8
+ import gradio as gr
9
+ import numpy as np
10
+
11
+ # using cpu
12
+ ctx = mx.cpu(0)
13
+
14
+
15
+ FILE_NAME = "result.png"
16
+
17
+ model = gluoncv.model_zoo.get_model("psp_resnet101_ade", pretrained=True)
18
+
19
+ def segmentation(img):
20
+ output = model.predict(img)
21
+ predict = mx.nd.squeeze(mx.nd.argmax(output, 1)).asnumpy()
22
+ mask = get_color_pallete(predict, "ade20k")
23
+ # mask.save("result.png")
24
+ # mmask = mpimg.imread("result.png")
25
+ # plt.imshow(mmask)
26
+ # plt.savefig("result.png")
27
+ return mask
28
+
29
+ image_in = gr.Image()
30
+ image_out = gr.components.Image()
31
+
32
+ Iface = gr.Interface(
33
+ fn=segmentation,
34
+ inputs=image_in,
35
+ outputs=image_out,
36
+ title="Sementic Segmentation - MXNet",
37
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ mxnet>=1.9.1
2
+ gluoncv>=0.10.5
3
+ matplotlib>=3.5.3
4
+ opencv-python>=4.6.0
5
+ gradio