mussie1212 commited on
Commit
d0fc0a3
·
verified ·
1 Parent(s): f47f03c

Upload 2 files

Browse files

add app.py file

Files changed (2) hide show
  1. app.py +53 -0
  2. requirements.txt +372 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import PIL.Image as Image
3
+ from ultralytics import ASSETS, YOLO
4
+
5
+
6
+ from PIL import Image
7
+ import gradio as gr
8
+
9
+ model_path = '/home/mussie/Videos/mussie_doc/Model_testing_for_uniliver/new_data_improved_object_detector.pt'
10
+
11
+ model = YOLO(model_path)
12
+
13
+
14
+ def predict_image(img, conf_threshold, iou_threshold):
15
+ """Predicts and plots labeled objects in an image using YOLOv8 model with adjustable confidence and IOU thresholds."""
16
+ # Convert the input image to grayscale
17
+ img = img.convert('L')
18
+
19
+ results = model.predict(
20
+ source=img,
21
+ conf=conf_threshold,
22
+ iou=iou_threshold,
23
+ show_labels=True,
24
+ show_conf=True,
25
+ imgsz=640,
26
+ )
27
+
28
+ for r in results:
29
+ im_array = r.plot()
30
+ im = Image.fromarray(im_array[..., ::-1])
31
+
32
+ return im
33
+
34
+
35
+ iface = gr.Interface(
36
+
37
+ fn=predict_image,
38
+ inputs=[
39
+ gr.Image(type="pil", label="Upload Image"),
40
+ gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
41
+ gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
42
+ ],
43
+ outputs=gr.Image(type="pil", label="Result"),
44
+ title="Ultralytics Gradio",
45
+ description="Upload images for inference. The Ultralytics YOLOv8n model is used by default.",
46
+ # examples=[
47
+ # [ASSETS / "bus.jpg", 0.25, 0.45],
48
+ # [ASSETS / "zidane.jpg", 0.25, 0.45],
49
+ # ],
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiobotocore==2.12.2
2
+ aiofiles==23.2.1
3
+ aiohttp==3.9.3
4
+ aioitertools==0.11.0
5
+ aiosignal==1.3.1
6
+ altair==5.3.0
7
+ amazon-textract-caller==0.2.2
8
+ amazon-textract-response-parser==1.0.2
9
+ amazon-textract-textractor==1.7.9
10
+ annotated-types==0.6.0
11
+ anyio==3.7.1
12
+ apturl==0.5.2
13
+ arxiv==2.1.0
14
+ asgiref==3.5.0
15
+ asttokens==2.4.1
16
+ async-timeout==4.0.3
17
+ attrs==23.2.0
18
+ Babel==2.8.0
19
+ backoff==2.2.1
20
+ bcrypt==4.1.2
21
+ beautifulsoup4==4.12.3
22
+ blinker==1.4
23
+ boto3==1.34.70
24
+ botocore==1.34.51
25
+ Brlapi==0.8.3
26
+ Brotli==1.0.9
27
+ build==1.2.1
28
+ cachetools==5.3.3
29
+ camelot-py==0.9.0
30
+ certifi==2024.2.2
31
+ cffi==1.16.0
32
+ chardet==4.0.0
33
+ charset-normalizer==3.3.2
34
+ chroma-hnswlib==0.7.3
35
+ chromadb==0.4.24
36
+ click==8.1.7
37
+ click-plugins==1.1.1
38
+ cligj==0.7.2
39
+ colorama==0.4.4
40
+ coloredlogs==15.0.1
41
+ comm==0.2.2
42
+ command-not-found==0.3
43
+ ConfigArgParse==1.7
44
+ contourpy==1.2.0
45
+ cryptography==42.0.5
46
+ cupshelpers==1.0
47
+ curl_cffi==0.6.2
48
+ cvzone==1.6.1
49
+ cycler==0.12.1
50
+ dataclasses-json==0.6.4
51
+ dataclasses-json-speakeasy==0.5.11
52
+ dbus-python==1.2.18
53
+ debugpy==1.8.1
54
+ decorator==5.1.1
55
+ defer==1.0.6
56
+ delegator==0.0.3
57
+ Deprecated==1.2.14
58
+ distro==1.7.0
59
+ distro-info==1.1+ubuntu0.2
60
+ docarray==0.32.1
61
+ docx==0.2.4
62
+ duckduckgo_search==5.2.2
63
+ duplicity==0.8.21
64
+ editdistance==0.8.1
65
+ emoji==2.11.0
66
+ entrypoints==0.4
67
+ et-xmlfile==1.1.0
68
+ exceptiongroup==1.2.0
69
+ executing==2.0.1
70
+ faiss-cpu==1.8.0
71
+ Faker==24.8.0
72
+ fastapi==0.103.2
73
+ fasteners==0.14.1
74
+ fastjsonschema==2.19.1
75
+ favicon==0.7.0
76
+ feedparser==6.0.10
77
+ ffmpy==0.3.2
78
+ filelock==3.13.1
79
+ filetype==1.2.0
80
+ fiona==1.9.6
81
+ Flask==2.0.1
82
+ Flask-BasicAuth==0.2.0
83
+ Flask-Cors==4.0.0
84
+ Flask-Login==0.6.3
85
+ flatbuffers==24.3.25
86
+ fonttools==4.50.0
87
+ frozenlist==1.4.1
88
+ fsspec==2024.3.1
89
+ future==0.18.2
90
+ geopandas==0.14.3
91
+ gevent==24.2.1
92
+ geventhttpclient==2.0.12
93
+ gitdb==4.0.11
94
+ GitPython==3.1.43
95
+ google-ai-generativelanguage==0.4.0
96
+ google-api-core==2.18.0
97
+ google-auth==2.28.2
98
+ google-generativeai==0.4.1
99
+ googleapis-common-protos==1.63.0
100
+ gradio==4.32.1
101
+ gradio_client==0.17.0
102
+ greenlet==3.0.3
103
+ grpcio==1.62.1
104
+ grpcio-status==1.62.1
105
+ h11==0.14.0
106
+ hnswlib==0.8.0
107
+ htbuilder==0.6.2
108
+ httpcore==1.0.4
109
+ httplib2==0.20.2
110
+ httptools==0.6.1
111
+ httpx==0.27.0
112
+ huggingface-hub==0.22.2
113
+ humanfriendly==10.0
114
+ idna==3.4
115
+ importlib-metadata==7.0.0
116
+ importlib_resources==6.4.0
117
+ iniconfig==2.0.0
118
+ ipykernel==6.29.3
119
+ ipython==8.22.2
120
+ itsdangerous==2.1.0
121
+ jedi==0.19.1
122
+ jeepney==0.7.1
123
+ Jinja2==3.1.3
124
+ jmespath==1.0.1
125
+ joblib==1.3.2
126
+ jsonpatch==1.33
127
+ jsonpath-python==1.0.6
128
+ jsonpointer==2.4
129
+ jsonschema==4.21.1
130
+ jsonschema-specifications==2023.12.1
131
+ jupyter_client==8.6.1
132
+ jupyter_core==5.7.2
133
+ keyring==23.5.0
134
+ kiwisolver==1.4.5
135
+ kubernetes==29.0.0
136
+ langchain==0.1.16
137
+ langchain-community==0.0.33
138
+ langchain-core==0.1.43
139
+ langchain-decorators==0.5.5
140
+ langchain-experimental==0.0.57
141
+ langchain-google-genai==1.0.1
142
+ langchain-text-splitters==0.0.1
143
+ langdetect==1.0.9
144
+ langsmith==0.1.40
145
+ language-selector==0.1
146
+ launchpadlib==1.10.16
147
+ lazr.restfulclient==0.14.4
148
+ lazr.uri==1.0.6
149
+ lockfile==0.12.2
150
+ locust==2.24.1
151
+ louis==3.20.0
152
+ lxml==5.1.0
153
+ macaroonbakery==1.3.1
154
+ Mako==1.1.3
155
+ Markdown==3.6
156
+ markdown-it-py==3.0.0
157
+ markdownlit==0.0.7
158
+ MarkupSafe==2.0.1
159
+ marshmallow==3.21.1
160
+ matplotlib==3.8.3
161
+ matplotlib-inline==0.1.6
162
+ mdurl==0.1.2
163
+ mmh3==4.1.0
164
+ monotonic==1.6
165
+ more-itertools==8.10.0
166
+ mpmath==1.3.0
167
+ msgpack==1.0.3
168
+ multidict==6.0.5
169
+ mypy-extensions==1.0.0
170
+ nbformat==5.10.4
171
+ nest-asyncio==1.6.0
172
+ netifaces==0.11.0
173
+ networkx==3.2.1
174
+ nltk==3.8.1
175
+ numexpr==2.10.0
176
+ numpy==1.24.4
177
+ nvidia-cublas-cu12==12.1.3.1
178
+ nvidia-cuda-cupti-cu12==12.1.105
179
+ nvidia-cuda-nvrtc-cu12==12.1.105
180
+ nvidia-cuda-runtime-cu12==12.1.105
181
+ nvidia-cudnn-cu12==8.9.2.26
182
+ nvidia-cufft-cu12==11.0.2.54
183
+ nvidia-curand-cu12==10.3.2.106
184
+ nvidia-cusolver-cu12==11.4.5.107
185
+ nvidia-cusparse-cu12==12.1.0.106
186
+ nvidia-nccl-cu12==2.19.3
187
+ nvidia-nvjitlink-cu12==12.4.99
188
+ nvidia-nvtx-cu12==12.1.105
189
+ oauthlib==3.2.2
190
+ olefile==0.46
191
+ onnx==1.16.0
192
+ onnxruntime==1.17.1
193
+ onnxsim==0.4.36
194
+ opencv-python==4.9.0.80
195
+ openpyxl==3.1.2
196
+ opentelemetry-api==1.24.0
197
+ opentelemetry-exporter-otlp-proto-common==1.24.0
198
+ opentelemetry-exporter-otlp-proto-grpc==1.24.0
199
+ opentelemetry-instrumentation==0.45b0
200
+ opentelemetry-instrumentation-asgi==0.45b0
201
+ opentelemetry-instrumentation-fastapi==0.45b0
202
+ opentelemetry-proto==1.24.0
203
+ opentelemetry-sdk==1.24.0
204
+ opentelemetry-semantic-conventions==0.45b0
205
+ opentelemetry-util-http==0.45b0
206
+ orjson==3.10.0
207
+ overrides==7.7.0
208
+ packaging==23.2
209
+ pandas==2.2.1
210
+ paramiko==2.9.3
211
+ parso==0.8.3
212
+ pdfminer.six==20231228
213
+ pdfplumber==0.11.0
214
+ pexpect==4.8.0
215
+ pillow==10.3.0
216
+ platformdirs==4.2.0
217
+ plotly==5.20.0
218
+ pluggy==1.4.0
219
+ pluginbase==1.0.1
220
+ posthog==3.5.0
221
+ prometheus_client==0.20.0
222
+ prompt-toolkit==3.0.43
223
+ promptwatch==0.4.4
224
+ proto-plus==1.23.0
225
+ protobuf==4.25.3
226
+ psutil==5.9.8
227
+ psycopg2-binary==2.9.9
228
+ ptyprocess==0.7.0
229
+ pulsar-client==3.4.0
230
+ pure-eval==0.2.2
231
+ py==1.10.0
232
+ py-cpuinfo==9.0.0
233
+ pyarrow==15.0.2
234
+ pyasn1==0.5.1
235
+ pyasn1-modules==0.3.0
236
+ pycairo==1.20.1
237
+ pycparser==2.21
238
+ pycups==2.0.1
239
+ pydantic==2.7.2
240
+ pydantic_core==2.18.3
241
+ pydash==8.0.0
242
+ pydeck==0.8.1b0
243
+ pydub==0.25.1
244
+ Pygments==2.17.2
245
+ PyGObject==3.42.1
246
+ pyinotify==0.9.6
247
+ PyJWT==2.3.0
248
+ pymacaroons==0.13.0
249
+ pymdown-extensions==10.7.1
250
+ PyMuPDF==1.24.1
251
+ PyMuPDFb==1.24.1
252
+ PyNaCl==1.5.0
253
+ pyOpenSSL==24.1.0
254
+ pyparsing==2.4.7
255
+ pypdf==4.1.0
256
+ PyPDF2==2.12.1
257
+ pypdfium2==4.28.0
258
+ PyPika==0.48.9
259
+ pyproj==3.6.1
260
+ pyproject_hooks==1.0.0
261
+ pyRFC3339==1.1
262
+ pytesseract==0.3.10
263
+ pytest==8.1.1
264
+ python-apt==2.4.0+ubuntu3
265
+ python-dateutil==2.9.0.post0
266
+ python-debian==0.1.43+ubuntu1.1
267
+ python-dotenv==1.0.0
268
+ python-iso639==2024.2.7
269
+ python-magic==0.4.27
270
+ python-multipart==0.0.9
271
+ pytz==2022.1
272
+ pyxdg==0.27
273
+ PyYAML==6.0.1
274
+ pyzmq==25.1.2
275
+ rapidfuzz==3.8.1
276
+ referencing==0.34.0
277
+ regex==2023.12.25
278
+ reportlab==3.6.8
279
+ requests==2.31.0
280
+ requests-oauthlib==1.4.0
281
+ rich==13.7.1
282
+ roundrobin==0.0.4
283
+ rpds-py==0.18.0
284
+ rsa==4.9
285
+ ruff==0.4.6
286
+ s3fs==2024.3.1
287
+ s3transfer==0.10.1
288
+ safetensors==0.4.2
289
+ scikit-learn==1.4.1.post1
290
+ scipy==1.12.0
291
+ seaborn==0.13.2
292
+ SecretStorage==3.3.1
293
+ semantic-version==2.10.0
294
+ sentence-transformers==2.6.1
295
+ sgmllib3k==1.0.0
296
+ shapely==2.0.3
297
+ shellingham==1.5.4
298
+ simplejson==3.19.2
299
+ six==1.16.0
300
+ smmap==5.0.1
301
+ sniffio==1.3.0
302
+ soupsieve==2.5
303
+ SQLAlchemy==2.0.29
304
+ st-annotated-text==4.0.1
305
+ stack-data==0.6.3
306
+ starlette==0.27.0
307
+ streamlit==1.33.0
308
+ streamlit-camera-input-live==0.2.0
309
+ streamlit-card==1.0.0
310
+ streamlit-embedcode==0.1.2
311
+ streamlit-extras==0.4.2
312
+ streamlit-faker==0.0.3
313
+ streamlit-image-coordinates==0.1.6
314
+ streamlit-keyup==0.2.4
315
+ streamlit-toggle-switch==1.0.2
316
+ streamlit-vertical-slider==2.5.5
317
+ sympy==1.12
318
+ systemd-python==234
319
+ tabulate==0.9.0
320
+ tenacity==8.2.3
321
+ TExtractor==0.1.2
322
+ thop==0.1.1.post2209072238
323
+ threadpoolctl==3.3.0
324
+ tiktoken==0.6.0
325
+ tokenizers==0.15.2
326
+ toml==0.10.2
327
+ tomli==2.0.1
328
+ tomlkit==0.12.0
329
+ toolz==0.12.1
330
+ torch==2.2.2
331
+ torchvision==0.17.2
332
+ tornado==6.4
333
+ tqdm==4.66.2
334
+ traitlets==5.14.2
335
+ transformers==4.39.3
336
+ triton==2.2.0
337
+ typer==0.12.3
338
+ types-requests==2.31.0.20240406
339
+ typing-inspect==0.9.0
340
+ typing_extensions==4.8.0
341
+ tzdata==2024.1
342
+ ubuntu-drivers-common==0.0.0
343
+ ubuntu-pro-client==8001
344
+ ufw==0.36.1
345
+ ultralytics==8.2.2
346
+ unattended-upgrades==0.1
347
+ unstructured==0.13.2
348
+ unstructured-client==0.18.0
349
+ urllib3==2.2.1
350
+ usb-creator==0.3.7
351
+ uvicorn==0.23.2
352
+ uvloop==0.18.0
353
+ validators==0.28.0
354
+ wadllib==1.3.6
355
+ Wand==0.6.13
356
+ watchdog==4.0.0
357
+ watchfiles==0.21.0
358
+ wcwidth==0.2.13
359
+ websocket-client==1.7.0
360
+ websockets==11.0.3
361
+ Werkzeug==2.0.2
362
+ wikipedia==1.4.0
363
+ wrapt==1.16.0
364
+ wsproto==1.0.0
365
+ xdg==5
366
+ xkit==0.0.0
367
+ XlsxWriter==3.2.0
368
+ xmltodict==0.13.0
369
+ yarl==1.9.4
370
+ zipp==1.0.0
371
+ zope.event==4.4
372
+ zope.interface==5.4.0